Cocoa bindings one- or bi-directional
Cocoa bindings one- or bi-directional
- Subject: Cocoa bindings one- or bi-directional
- From: Zdzislaw Losvik <email@hidden>
- Date: Thu, 26 May 2005 16:34:29 +0200
I am stuck with that for a longer while.
I thought that binding two objects together causes each of them to be
updated when the other gets updated.
Here is a simple example with to model objects bound to each other:
BinderBrick *brick1 = [[BinderBrick alloc] init];
BinderBrick *brick2 = [[BinderBrick alloc] init];
[brick1 bind:@"intValue" toObject:brick2 withKeyPath:@"intValue"
options:nil];
[brick1 setIntValue:5];
NSLog(@"%d, %d", brick1->_intValue, brick2->_intValue);
[brick2 setIntValue:7];
NSLog(@"%d, %d", brick1->_intValue, brick2->_intValue);
The output is:
2005-05-26 16:08:12.436 Binder[1357] 5, 0
2005-05-26 16:08:12.437 Binder[1357] 7, 7
Judging from the output only receiver of bind... method is listening
for changes. Should I use another binding:
[brick2 bind:@"intValue" toObject:brick1 withKeyPath:@"intValue"
options:nil];
to accomplish bi-directional binding?
I am really confused here. Any help would be really appreciated.
Regards,
Zdzislaw Losvik
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden