Theocacao
Leopard
Design Element
Comment on "Using Delayed Messages in Cocoa"
by Grayson — Sep 19
I've never had a problem with the connection being nil. I have noticed that the content isn't already there so `rearrangedObjects` wouldn't work. If the connection actually is nil, then waiting may be the best thing to do but I've always observed changes to the "content" value of an array controller. So far, it's worked for me. I also get to work with it as soon as the content is available and I don't have to worry about timing issues.

-(void)awakeFromNib
{
[myArrayController addObserver:self forKeyPath:@"content" options:0 context:nil];
}

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if (object == myArrayController)
{
[myArrayController rearrangeObjects];
[myArrayController removeObserver:self forKeyPath:@"content"];
}
}
Back to "Using Delayed Messages in Cocoa"
Design Element

Copyright © Scott Stevenson 2004-2015