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.
by Grayson — Sep 19
-(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"];
}
}