FROM : Mike R. Manzano
DATE : Sun Nov 25 09:29:22 2007
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
DATE : Sun Nov 25 09:29:22 2007
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
| Related mails | Author | Date |
|---|---|---|
| No related mails found. | ||






Cocoa mail archive

