On Nov 13, 2008, at 07:10, [EMAIL PROTECTED] wrote:

I have an NSControl subclass that maintains a list of cells, and an NSMutableArray called "content". I have successfully bound its "content" to the core data based array controller's "arrangedObjects" array. I thought that was all I needed to do to get bindings working, so I made my setContent: accessor method so that it kept my cell list updated with the content list... this did not work. my setContent accessor was called once, during the initialization phase of the app.

I'm not sure what you're saying here, but if you're saying you added a "content" property (getter and setter) to your control, then programatically used [NSObject bind:toObject:withKeyPath:options:] to "bind" the property to an array, then it won't work because that's not what bindings are. I won't go into the gory details because this has been discussed at length on this list in the last month or so, but the short version is that a binding has to be implemented with a lot of fiddly code before it can actually be used, and a binding name is NOT a property name (though it kinda sorta partially seems to work if you mix them up).

It's not usually worth the trouble. It's easier just to use KVO notifications directly.

next, I tried registering for KVO on the array controller's "arrangedObjects" value, thinking that... since it is an array, it IS a "to many" relationship, and I would not only get alerts to changes to the array, but also information about the changes, in the change dictionary under the "NSKeyValueChangeKindKey" key. This sort of worked. I get a notification when the ArrangedObjects is altered, but the information about the change is NOT in evidence. Apparently, this is not a "to many" relationship after all? (ummm... what??!!?!? is this true?)

Nope, it's a long-standing bug in NSArrayController. This is also often discussed on this list, most recently a couple of days ago.

And isn't this KVO a little redundant anyway? doesn't bindings do this already?

The bindings mechanism is built on top of KVO, not the other way around.

isn't there some way for me to automatically get notified BECAUSE "content" is bound to the array controller? (which is what I was trying to do with the setContent: method)

You *are* getting notified, you said, but just not getting the correct change information.

currently, I am thinking that I will have to discover the changes myself, by comparing my content against my cells. it seems a bit redundant (read: wasteful), but that seems to be the order of the day... do everything twice.

That, or observe the underlying array (NSArrayController's contentArray) instead of arrangedObjects, or find a way of doing what you need without knowing what changed, or ...

so in all of this, i am frantically looking for ANY documentation that explains how to duplicate any part of something I see and use every day... namely the smooth interaction between a custom UI element (that works SORT of like a tableview, in that it displays a list of things) and an array controller that happens to use core data for its content. The official apple docs, are... anemic at best, and my google searches have come up empty.

Yup, it's very annoying, because you are trying to do the right thing. Time for Plan B.


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to