Re: basic bindings question
Re: basic bindings question
- Subject: Re: basic bindings question
- From: Daniel Child <email@hidden>
- Date: Wed, 14 May 2008 23:54:12 -0400
I think I understood the first half of what you said, and can now see
why making number the receiver of addObserver was totally wrong.
But I seem to have a problem.
If I want to observe the property of an object, and in my case, it
turns out that the M and C are collapsed into a model-controller, then
it's basically a case of asking something to observe itself. In other
words, your "myFoo addObserver: self <THE CONTROLLER> forKeyPath:
@"number" becomes....
- (void) awakeFromNib {
[self addOberver: self forKeyPath: @"number" options: 0 context: NULL];
}
I tried that and got the same message as before (<receiver> may not
respond to addObserver), only this time the receiver is the controller
instead of number.
Is it not possible to collapse M and C for a case where you want to
track a simple text field. It seems it must be.
On May 14, 2008, at 5:11 PM, Ken Thomases wrote:
To illustrate:
@interface Foo : NSObject
{
NSNumber* number; // <-- This is NOT the property
}
// _These_ are the property:
- (NSNumber*) number;
- (void) setNumber:(NSNumber*)newNumber;
@end
// ... in some other code somewhere
Foo* myFoo = /* ... */
[myFoo addObserver:self forKeyPath:@"number"];
This object (self) is observing the myFoo object for changes in its
"number" property.
Think also about the KVO notifications you will receive:
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:
(id)object change:(NSDictionary *)change context:(void *)context;
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden