Re: NSArrayController nib binding vs code binding
Re: NSArrayController nib binding vs code binding
- Subject: Re: NSArrayController nib binding vs code binding
- From: Quincey Morris <email@hidden>
- Date: Mon, 18 Jul 2011 18:57:28 -0700
On Jul 18, 2011, at 18:41, Trygve Inda wrote:
> The other possibly related issue is that I have my table delegate defined in
> the nib and seem to get
>
> -(void)tableViewSelectionDidChange:(NSNotification *)aNotification
>
> Before awakeFromNib which means my binding has not taken place yet. Do I
> need to set the delegate in awakeFrmNib rather than in the nib directly?
Assuming there's nothing else going here that you haven't mentioned, I can't see any reason why you shouldn't bind the array controller in the nib file, even if the thing being bound to is being created programmatically.
If you do that, I hope you'll immediately see that the *real* problem is a lack of KVO compliance in your data model. You essentially have a data model property "myClassInstance" (in effect, since you probably don't have an actual property for this), but you're not providing KVO compliance for that property. If you didt, it wouldn't matter if it was nil (i.e. you hadn't created it yet) at the time the binding happened, but when you finally did get around to creating it the KVO compliance would inform the array controller that its content had changed.
Does that make sense? I'm not sure I explained myself very well. I'm saying you attended to the KVO compliance to the "places" property of MyClass, but you didn't attend to KVO compliance of a necessary "myClassInstance" property of whatever creates it.
(If you take the trouble to get the KVO compliance right *everywhere*, the payoff is that all of those irritating timing problems around nib loading are non-problems.)
_______________________________________________
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