On Dec 30, 2008, at 7:32 PM, Nic Williams wrote:

In this code sample: http://gist.github.com/41855 I am getting a
Pointer instance instead of an NSManagedObject_Recipe instance (from
Core Data). Subsequently the setValue:forKey: call at the end of the
delegate/callback method fails.

The top method addImage(sender) launches an NSOpenPanel, which
delegates to the second/last method
addImageSheetDidEnd:returnCode:contextInfo: when the panel is closed.

But instead of passing through the NSManagedObject_Recipe instance to
the contextInfo: recipe value, I am getting a Pointer.

Is this correct? Or how do I get my NSManagedObject_Recipe instance
from the Pointer. MacRuby src for Pointer class doesn't suggest it has
any methods for getting the pointed-to thing.

   rb_cPointer = rb_define_class("Pointer", rb_cObject);
   rb_undef_alloc_func(rb_cPointer);
   rb_define_singleton_method(rb_cPointer, "new_with_type",
rb_pointer_new_with_type, 1);
   rb_define_method(rb_cPointer, "assign", rb_pointer_assign, 1);
   rb_define_method(rb_cPointer, "[]", rb_pointer_aref, 1);

You can do pointer[0] to dereference it.

A Pointer object can be created from a C array of elements, which is why Pointer responds to #[] (so that you can dereference a particular slot).

Laurent
_______________________________________________
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel

Reply via email to