programatic binding (undefined bind method on NSTextField)
I want to bind my NSTextField to my model object. In objective-c I would do something like [mytextfield bind:@"value" toObject:myperson withKeyPath:@"address" options:nil]; But I have problems doing this in MacRuby with the following snippet: mytextfield = NSTextField.alloc.initWithFrame [20, 200, 200, 20] mytextfield.bind('value', toObject:'myperson', withKeyPath:'address') It says that NSTextField does not have a bind method. Do I misunderstand something, or is the bind method really missing and I have to set/remove the observers all myself? Thanks, ALex.
`bind:toObject:withKeyPath` is actually from the `NSKeyValueBindingCreation` category on NSObject which is defined in the Appkit. If it seems to disappear then I would think it is a problem importing `AppKit.framework` somewhere. On Sep 27, 2011, at 3:22 PM, Alex Greif wrote:
I want to bind my NSTextField to my model object. In objective-c I would do something like [mytextfield bind:@"value" toObject:myperson withKeyPath:@"address" options:nil];
But I have problems doing this in MacRuby with the following snippet:
mytextfield = NSTextField.alloc.initWithFrame [20, 200, 200, 20] mytextfield.bind('value', toObject:'myperson', withKeyPath:'address')
It says that NSTextField does not have a bind method.
Do I misunderstand something, or is the bind method really missing and I have to set/remove the observers all myself?
Thanks, ALex.
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
The first line of my code is framework 'AppKit' IMO this should import it. BTW I am using Macruby 0.10
`bind:toObject:withKeyPath` is actually from the `NSKeyValueBindingCreation` category on NSObject which is defined in the Appkit. If it seems to disappear then I would think it is a problem importing `AppKit.framework` somewhere.
On Sep 27, 2011, at 3:22 PM, Alex Greif wrote:
I want to bind my NSTextField to my model object. In objective-c I would do something like [mytextfield bind:@"value" toObject:myperson withKeyPath:@"address" options:nil];
But I have problems doing this in MacRuby with the following snippet:
mytextfield = NSTextField.alloc.initWithFrame [20, 200, 200, 20] mytextfield.bind('value', toObject:'myperson', withKeyPath:'address')
It says that NSTextField does not have a bind method.
Do I misunderstand something, or is the bind method really missing and I have to set/remove the observers all myself?
Thanks, ALex.
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
The following code prints false twice So it seems that the protocol is not applied correctly. Is this a bug or do I need some other require/framework statements? BTW the result is the same if i use "framework 'Cocoa'" -------- code ------------- framework 'AppKit' puts NSObject.alloc.init.conformsToProtocol Protocol.protocolWithName('NSKeyValueBindingCreation') puts NSTextField.alloc.initWithFrame([1,2,3,4]).conformsToProtocol Protocol.protocolWithName('NSKeyValueBindingCreation')
participants (2)
-
Alex Greif
-
Shannon Love