MacRuby NSBeginAlertSheet call gives unknown: [BUG] unknown Objective-C immediate: 0x1 (nil)
-
06-06-2021 - |
Frage
As a MacRuby beginner I am working through this tutorial, and want to add a drop-down sheet to warn when the user tries to delete an entry from the app.
Following the code here, which in Obj-C is
- (IBAction)deleteRecord:(id)sender
{
NSString *title = @"Warning!";
NSString *defaultButton = @"Delete";
NSString *alternateButton = @"Don't Delete";
NSString *otherButton = nil;
NSString *message = @"Are you sure you want to delete the selected record(s)?";
if ( [tableView numberOfSelectedRows] == 0 )
return;
NSBeep();
NSBeginAlertSheet(title, defaultButton, alternateButton, otherButton, mainWindow, self, @selector(sheetDidEnd:returnCode:contextInfo:), nil, nil, message);
}
I have in MacRuby:
def removeFriend(sender)
return if @friendsTableView.numberOfSelectedRows == 0
title = 'Warning!'
defaultButton = 'Delete'
alternateButton = 'Don\'t Delete'
otherButton = nil
s = @friendsTableView.numberOfSelectedRows > 1 ? 's' : ''
message = "Are you sure you want to delete the selected record#{s}?"
NSBeginAlertSheet(title, defaultButton, alternateButton, otherButton, @mainWindow, self, :'alertDidEnd:returnCode:contextInfo:', nil, nil, message)
end
and for alertDidEnd:returnCode:contextInfo
:
def alertDidEnd(sheet, returnCode:rCode, contextInfo:cInfo)
<array handling code>
end
When this runs I get a drop-down sheet when the button linked to removeFriend
is clicked, but then if I click "Delete" my app crashes with the following error:
unknown: [BUG] unknown Objective-C immediate: 0x1 (nil)
MacRuby 0.12 (ruby 1.9.2) [universal-darwin10.0, x86_64]
(lldb)
Am I doing something wrong with the way the didAlertEnd
method is implemented, or is this actually a bug?
Lösung
Apparently a MacRuby bug: http://www.macruby.org/trac/ticket/1368
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow