Weird KVO problem
Weird KVO problem
- Subject: Weird KVO problem
- From: "Mike R. Manzano" <email@hidden>
- Date: Sun, 25 Nov 2007 00:29:22 -0800
Sorry for all the KVC/KVO/KVB postings lately, but I'm finding it hard
to understand their behavior. Here is my latest problem (don't even
ask me how I got here; most of this code is the result of a desperate
attempt to figure all this out):
- (void) ping
{
NSLog( @"selection:%@", [_blogAccountsController
valueForKeyPath:@"selection.serviceURL"] ) ;
}
- (void) awakeFromNib
{
[_blogAccountsController addObserver:self
forKeyPath:@"selection.serviceURL"
options:0 context:nil] ;
// observeValueForKeyPath:ofObject:change:context: is only ever called
// if the following two lines are uncommented.
// [self performSelector:@selector(ping)
// withObject:nil afterDelay:0] ;
}
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context
{
NSLog( @"attr at keyPath changed: %@ on object: %@" , keyPath ,
object ) ;
}
_blogAccountsController is an NSArrayController bound to a Core Data
context to an entity named "blog" which in turn contains a serviceURL
attribute.
Without the performSelector:withObject:afterDelay: message in -
awakeFromNib, my observeValueForKeyPath is never called. However, if I
uncomment those lines, observeValueForKeyPath is called just fine.
What's going on here?
Thanks,
Mike
_______________________________________________
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