MacRuby and NSError

Just a note for other people that might be cracking their heads trying to meld MacRuby and NSError ** parameters. The answer was already sitting on my computer, I just never through to look at the MacRuby Core Data XCode templates, but that’s beside the point. For those of you searching, you just need to do the following.

      error = Pointer.new_with_type(‘@’)
      unless managed_object_context.save(error)
        NSLog error[0].inspect
        NSApplication.sharedApplication.presentError(error[0])
      end
 

The NSLog error[0].inspect will output #<NSError:0x80057a640>. Exactly what we want.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]
This entry was posted in Computers, Programming and tagged , . Bookmark the permalink.

One Response to MacRuby and NSError

  1. Jason Heiss says:

    Thanks for posting this.

    For anyone cutting-n-pasting note that the quotes around the @ in the Pointer.new_with_type line will need to be changed from smart/curly quotes to standard straight quotes. Otherwise you get: undefined method `‚Äò’