From: Sean L. <se...@da...> - 2005-09-13 14:55:28
|
On 13 Sep 2005, at 14:43, Free (rupert.barrow) wrote: > Has anyone got Ruby/RubyCocoa and CoreData working ? > Are there any examples out there, of Apps (with GUI) and/or Tools > (without GUI). This isn't quite the same, but bindings/KVO are used by CoreData, so this may be useful to you. I've been working on enhancing RubyCocoa's handling of Key-Value observance to allow binding driven applications. I've written a little helper that allows code like this: class Controller < OSX::NSObject attr_accessor :status, :timeConnected cocoa_property :status, :timeConnected cocoa_depends :status, [ :statusText, :isConnecting, :isConnected, :isDisconnecti ng, :isDisconnected, :isWorking ] cocoa_depends :timeConnected, [ :timeConnectedText ] end (this was from a little proof-of-concept app I wrote to handle activating a PPP connection on my server from by PB) The cocoa_property class method creates wrappers for the setter methods for those properties that trigger KVO notifications. Note this is necessary even with the CVS HEAD RubyCocoa, even with the property support in there. That support will only trigger the notifications when the property is updated from the other side of the ObjC bridge. My code ensures that Ruby code that updates the property also triggers the notifications. The cocoa_depends class method defines dependencies. This is necessary because the bridge seems to prevent the setKeys:triggerChangeNotificationsForDependentKey: class method on NSObject from operating correctly. (I haven't investigated why, but I can guess it's to do with the RubyCocoa wrapper for Ruby classes). If you're interested I can post this, alternately is there any interest in getting these into the trunk? Is there perhaps a more elegant way of achieving this? Sean -- Sean Legassick se...@da... |