Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSArrayController and the single NSMutableArray



Hi All

Must be doing something silly but can't get this to work.

I have an NSArrayController whose contentArray is bound to some object's NSMutableArray (it's an ivar but I don't think this should matter). I can easily make changes to the NSMutableArray through the NSArrayController's add: and remove: methods, but cannot get any programmatic changes to the NSMutableArray (addObject: etc.) to be reported by the NSArrayController back to any bound views.

So I thought to "observe" things a little closer. I did an addObserver to the keypath of the NSMutableArray, and true enough, changing the NSMutableArray through addObject: etc. didn't get reported.

Quoting the spiel before observeValueForKeyPath:

"A value of NSKeyValueChangeInsertion, NSKeyValueChangeRemoval, or NSKeyValueChangeReplacement indicates that mutating messages have been sent to the array returned by a -mutableArrayValueForKey: message sent to the object, or that one of the key-value-coding-compliant array mutation methods for the key has been invoked, or that -willChange:valuesAtIndexes:forKey:/-didChange:valuesAtIndexes:forKey: has otherwise been invoked."

Surely addObject: qualifies as "one of the key-value-coding-compliant array mutation methods"? (Or do I really have to -willChange:valuesAtIndexes:forKey every time I touch the NSMutableArray??)

If it helps any, I ran this on 10.4 prerelease 8A420.



Cheers, Glen Low


--- pixelglow software | simply brilliant stuff www.pixelglow.com aim: pixglen

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.