Re: Table column bindings to NSArrayController not working
Re: Table column bindings to NSArrayController not working
- Subject: Re: Table column bindings to NSArrayController not working
- From: Sam Stigler <email@hidden>
- Date: Fri, 18 May 2007 12:11:02 +1000
On May 18, 2007, at 5:10 AM, Keary Suska wrote:
on 5/17/07 6:54 AM, email@hidden purportedly said:
I'm having a really strange problem: I'm using bindings for the
main table in my app, which displays content based on Core Data
objects, and that works fine. But for a smaller table, I'm
displaying content bound to an NSArray in my document controller
class (MyDocument).
Ideally, the second table (the one not based on Core Data) would
update after modifications made to its content array (or rather the
bound values of its columns, via an NSArrayController) during the
first table's -(void)tableViewSelectionDidChange:(NSNotification *)
aNotification method. Oddly enough GDB is telling me that that
method is working as it should; the array (called metadata) is being
updated, which leads me to believe there is a problem with the
bindings -- either that, or I did something wrong with how/where I
declared and allocated the array. I'm posting the relevant portions
of my code, as well as my bindings settings for that table, below;
could you please take a look and tell me if I'm doing anything wrong?
At first glance, you are not updating your array in a Key-Value-
Observing
(KVO) compliant way.
I have my metadata array set up as an NSArray of
NSMutableDictionaries. I know I'm updating the dictionaries in a KVC-
compliant way, using -setValue: forKey:, but is there a specifically
KVC-compliant way to add them to the array, or is that taken care of
automatically?
As for KVO, I'll try to add the NSArrayController as an observer of
the NSArray (something I hadn't done before because I figured IB
would take care of it automatically). I'll post back to let you know
if that works.
It also appears that you do not understand how
NSArrayControllers and bindings work, unless there are very
significant
pieces of code missing. For instance, you almost never call -
prepareContent
unless you are subclassing NSArrayController (or any other
NSController
subclass), or instantiating the controller in code.
I actually was just guessing about -prepareContent; I had tried it
without that first and it didn't work either -- it was really a last-
ditch effort sort of thing.
You should probably re-read the key-value coding/observing docs, as
well as
the bindings doc:
http://developer.apple.com/documentation/Cocoa/Conceptual/
CocoaBindings/inde
x.html
I'm just re-reading them now; are you saying that I need to register
the NSArrayController as an observer of the ivar NSArray? My
understanding from a previous read of the doumentation's section on
"Creating a Master-Detail Interface" had been that NSArrayController
somehow took care of that. I'll try doing the registration myself
and see if it makes a difference. Also... I'd thought that NSArray
is KVC compliant, but I now realize that the documentation doesn't
actually say that -- it just has a link to the Key-Value Coding
Programming Guide at the top of the NSArray page. Can anyone confirm
if it is? (If it isn't, that could be my problem right there.) I
assume it is, because IB doesn't raise any exceptions when I run the
program.
Best,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
Thanks again,
Sam
_______________________________________________
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:
40mac.com
This email sent to email@hidden
_______________________________________________
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