Question

I'm running with MacRuby 0.5 and I have a method:

 attr_accessor :bookmarkSheet, :mainWindow

def createBookmark(sender)
  NSApp.beginSheet(bookmarkSheet, 
   modalForWindow:mainWindow, 
   modalDelegate:self, 
   didEndSelector:nil,
   contextInfo:nil)   
 end

which is supposed to open up a sheet panel on the main window. However, whenever I run this method, I get

2009-10-10 12:27:45.270 Application[45467:a0f] nil is not a symbol

Any thoughts as to why I get this error? I can't seem to find anywhere that lists the reason I am getting this error. Thanks

Was it helpful?

Solution

Peter is right, didEndSelector: is expecting a selector, you should try something like:

def bookmark_created
 puts "Bookmark created"
end

def createBookmark(sender)
  NSApp.beginSheet(bookmarkSheet, 
   modalForWindow:mainWindow, 
   modalDelegate:self, 
   didEndSelector:"bookmark_created:",
   contextInfo:nil)   
 end

Notice how I added a colon after the name of the method to call. Also, it looks like a bug with MacRuby beta release, I would encourage you to report the bug on the MacRuby tracker: http://www.macruby.org/trac/newticket

Here is the example given by Apple's documentation:

- (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];
}

As you can see, you should be able to set the end selector as nil. In the meantime, my workaround will work just fine.

Good luck,

  • Matt

OTHER TIPS

Because you're passing nil as the didEndSelector:. You need to pass a selector there.

Just a quick note for everybody reading this thread. When finding bugs in MacRuby, even if you are not sure, please email the mailing list http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel and file a bug report: https://www.macruby.org/trac/newticket

You can certainly also post here and ask on Twitter but if you find something wrong with MacRuby and you want it fixed, you really really need to file a bug report.

Update: ticket filed here. (check on the ticket for status update)

Thanks,

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top