Re: Are Bindings Redundant?
Re: Are Bindings Redundant?
- Subject: Re: Are Bindings Redundant?
- From: Allan Odgaard <email@hidden>
- Date: Sat, 5 Jun 2004 06:37:00 +0200
On 5. Jun 2004, at 5:39, James DiPalma wrote:
ehm... like bind things together? observe values? use array
operators? etc.
Bindings themselves do not observe values nor do they use array
operators.
The essence is probably the bind:toObject:withKeyPath:options: selector
documented in NSKeyValueBindingCreation:
Creates a relationship between the receivers binding and
the property of observableController specified by keyPath
So we have keyPath (where array operators is just a special case of key
paths) and we have 'observableController', which hints that key-value
observing will be used.
But argue all you want :) I was not trying to provide a definition
above, merely asking what the OP had in mind... and I really do think
that bindings is just an umbrella term, as hinted e.g. by this quote:
Cocoa Bindings provides extensible controllers, protocols
for models and views to adopt, and additions to classes
in Foundation and the Application Kit [...]
Bindings are not associations; [...]
And in this context, associations is what?
bindings require objects like views and cells to implement behavior
like observing data [...]
Maybe according to the documentation ;)
% gcc -x objective-c -framework Cocoa - <<EOF
#import <Cocoa/Cocoa.h>
@interface foo : NSObject
{ NSString* value; }
@end
@implementation foo
@end
int main ()
{
[NSAutoreleasePool new];
foo* obj1 = [foo new];
foo* obj2 = [foo new];
// uses KVO for obj2.value and KVC for obj1.value
[obj1 bind:@"value" toObject:obj2 withKeyPath:@"value" options:nil];
[obj2 setValue:@"wow!" forKey:@"value"];
NSLog(@"%@", [obj1 valueForKey:@"value"]);
return 0;
}
EOF
% ./a.out
2004-06-05 06:26:03.636 a.out[2589] wow!
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.