彼得是对的,didEndSelector: 期待一个选择器,你应该尝试类似:
def bookmark_created
puts "Bookmark created"
end
def createBookmark(sender)
NSApp.beginSheet(bookmarkSheet,
modalForWindow:mainWindow,
modalDelegate:self,
didEndSelector:"bookmark_created:",
contextInfo:nil)
end
请注意我是如何在要调用的方法名称后添加一个冒号的。此外,它看起来像 MacRuby 测试版的一个错误,我鼓励您在 MacRuby 跟踪器上报告该错误:http: //www.macruby.org/trac/newticket
这是Apple文档给出的示例:
- (void)showCustomDialog: (NSWindow *)window
// User has asked to see the dialog. Display it.
{
if (!myCustomDialog)
[NSBundle loadNibNamed: @"MyCustomDialog" owner: self];
[NSApp beginSheet: myCustomDialog
modalForWindow: window
modalDelegate: nil
didEndSelector: nil
contextInfo: nil];
[NSApp runModalForWindow: myCustomDialog];
// Dialog is up here.
[NSApp endSheet: myCustomDialog];
[myCustomDialog orderOut: self];
}
如您所见,您应该能够将结束选择器设置为 nil。与此同时,我的解决方法可以正常工作。
祝你好运,