我运行的是MacRuby 0.5,我有一个方法:
attr_accessor :bookmarkSheet, :mainWindow
def createBookmark(sender)
NSApp.beginSheet(bookmarkSheet,
modalForWindow:mainWindow,
modalDelegate:self,
didEndSelector:nil,
contextInfo:nil)
end这应该会在主窗口上打开一个工作表面板。但是,每当我运行此方法时,我都会得到
2009-10-10 12:27:45.270 Application[45467:a0f] nil is not a symbol有没有想过为什么我会得到这个错误?我似乎找不到任何地方列出我得到这个错误的原因。谢谢
发布于 2009-10-10 19:20:56
Peter是对的,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。在此期间,我的变通方法将会工作得很好。
祝好运,
发布于 2009-10-10 17:21:04
因为您将以didEndSelector:的身份传递nil。你需要在那里传递一个选择器。
发布于 2009-10-10 19:48:03
给所有阅读这篇文章的人一个简短的提示。在MacRuby中发现错误时,即使您不确定,也请通过电子邮件发送邮件列表http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel并提交错误报告:https://www.macruby.org/trac/newticket
你当然也可以在这里发帖,然后在推特上提问,但如果你发现MacRuby有问题,想要修复它,你真的需要提交一份错误报告。
更新:票证字段here。(检查工单上的状态更新)
谢谢,
https://stackoverflow.com/questions/1548391
复制相似问题