Re: Bindings: changing model changes some views but not others (NSTableColumn)
Re: Bindings: changing model changes some views but not others (NSTableColumn)
- Subject: Re: Bindings: changing model changes some views but not others (NSTableColumn)
- From: "Sean McBride" <email@hidden>
- Date: Mon, 4 Dec 2006 14:24:37 -0500
- Organization: Rogue Research
On 2006-12-01 20:32, Scott Stevenson said:
>I mucked around with this for a while, and could probably figure it
>out given enough time, but I'm sure somebody with Cocoa source code
>could do it much faster. If you you have an ADC tech support
>incident, this would be a good time to use it.
Well, I've filed <rdar://4862378>. I'm glad you find it odd too,
whenever I have weirdo bindings problems like this I assume it's me
that's misunderstood something. Thanks for taking the time to take a
look at all this!
>Something interesting is that if you unbind the table view itself
>(just leaving the columns bound), you don't get any row data at all.
>That's clearly wrong, so it suggests what you're seeing is just a
>reflection of something more fundamental.
I'm not so sure about that. It might be 'expected behaviour'. I
believe when you bind NSTableColumns to a NSController-subclass in a NIB
that 'binding magic' kicks in and does the NSTableView bindings
automagically. mmalc hints to it here:
<http://homepage.mac.com/mmalc/CocoaExamples/controllers.html>
"Typically you only need to bind each table column value binding to the
arranged objects of an array controller. When you do this, behind the
scenes, all three table view content bindings are automatically 'hooked
up' for you. It is only when you need to change these three default
content bindings that you need to visit the table view's bindings."
>One other stab in the dark thing you could try:
>
>Bind the table columns directly to the array controller in code. I
>suspect all of this has something to do with the fact that the table
>columns don't realize they're getting their data from an array
>controller. All they know is they're somehow getting this data from
>some array somewhere, which happens to have "arrangedObjects" in the
>name. That may not even be a supported configuration.
>
>If you bind directly to an array controller, the table columns may
>snap to life, addressing the underlying issue. It's amazing how many
>bindings issues are solved by breaking the bindings in multiple steps
>instead of trying to bind to one long keypath.
I tried binding programatically the same way as it's wired in IB, that is:
[titleColumn bind:@"value" toObject:self
withKeyPath:@"catController.arrangedObjects.title"
options:nil];
Same result (makes sense). Then I tried what you suggested, that is:
NSArrayController* controller = [self catController];
[titleColumn bind:@"value" toObject:controller
withKeyPath:@"arrangedObjects.title" options:nil];
And now things work great!
I guess one just can't reliably bind via File's Owner, though I thought
we were supposed to be able to...
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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