Указатели на данные, возвращаемые методами-делегатами в MacRuby

I'm working on a small MacRuby project, using 0.5b1, which is implementing the delegate methods required for Growl (the app is using Growl for notifications).

I would like to be able to respond to the Growl callbacks when the notification is clicked, however when you register the Growl delegate with ::GrowlApplicationBridge.setGrowlDelegate self it asks the delegate for a NSDictionary* with the Growl registration information.

I have tried returning a standard NSDictionary instance, trying to coerce the object into a pointer etc, but every time I seem to get a segmentation fault (I guess this is because I'm passing back an object, not a pointer to the object).

I'm wondering if it is possible to obtain a pointer to the object its self, or using p = Pointer.new("NSDictionary") is it possible to assign the data somehow (using p.assign(dict) results in a type error as it is expecting an Integer).

I guess that the other option is to write an ObjC class to act as the delegate and just hook into that from Ruby, but that somewhat defeats the purpose....

12.10.2009 21:33:18

A ruby hash is a NSDictionary in MacRuby. You should be able to do something along the lines of:

framework 'Growl'

def registrationDictionaryForGrowl
  {'TicketVersion' => 1, 'AllNotifications' => nil, 'ApplicationId' => 'test'}


Although, I don't have the keys set properly for the growl dictionary (which I believe is due to passing nil to the AllNotifications key. Hopefully, passing in an array of real notifications should work):

2009-10-27 15:47:12.305 macruby[61552:903] GrowlApplicationBridge: Error writing registration dictionary at /var/folders/8Z/8ZW9lfcxHlWsi+jWQGSXXk+++TI/-Tmp-/macruby-61552-96CEC625-EEE2-49D3-8532-0184DB93E0F4.growlRegDict: Property list invalid for format
27.10.2009 19:52:38
This seems promising.. I cant remember if I tried this myself, but from memory I was actually returning a new NSDictionary... I'll have to dig up the code and give it a try... thanks!
Matthew Savage 6.11.2009 12:00:01