• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Bindings Faked Array Item Problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bindings Faked Array Item Problem


  • Subject: Re: Bindings Faked Array Item Problem
  • From: Thilo Ettelt <email@hidden>
  • Date: Fri, 17 Mar 2006 16:15:34 +0100
  • Resent-cc: email@hidden
  • Resent-date: Mon, 20 Mar 2006 09:01:33 +0100
  • Resent-from: Thilo Ettelt <email@hidden>
  • Resent-message-id: <email@hidden>
  • Resent-to: Felix Franz <email@hidden>

I find it difficult to comprehend on what to implement and what not. I've tried the following approach:

- (int)countOfMyArray;
- (MyObject *)objectInMyArrayAtIndex:(unsigned int)index;
- (void)insertObject:(MyObject *)obj inMyArrayAtIndex:(unsigned int) index;
- (void)removeObjectFromMyArrayAtIndex:(unsigned int)index;


which led to the problem I have described. What am I doing wrong?


Thx in advance, Thilo

Am 17.03.2006 um 15:18 schrieb Felix Franz:


On Mar 17, 2006, at 2:38 PM, Thilo Ettelt wrote:

Hello,

I'm using bindings (NSTreeController) for feeding an Outline view with data, I have used the appropriate accessor methods and they are called ( -(MyObject *)objectInMyArrayAtIndex:.... etc). But after an object is inserted and then after -objectInMyArrayAt... is called I get an error:
"unexpected state: trying to insert object <NSKVONotifying_MyObject: 0x3b8650> failed. Destination node == nil or destination node did not retain the object"

Sounds like the NSTreeController gets no notification that your "MyArray"-collection is modified.
You could either implement the indexed-accessor-methods (insertObject:in<Key>AtIndex:, replaceObjectIn<Key>AtIndex:, and removeObjectFrom<Key>AtIndex:) and use the mutableArrayValueForKey:
to change the array (Automatic Observer Notification). Or use manual Observer notification and call
the proper willChange:valuesAtIndexes:forKey:/ didChange:valuesAtIndexes:forKey:-
methods when changing your collection. See (file:///Developer/ADC% 20Reference Library/documentation/Cocoa/Conceptual/ KeyValueObserving/Concepts/AutoVsManual.html).


I once had a similar problem which disappeared after implementing the indexed-accessor-methods
and using mutableArrayValueForKey: to change the array.



Hope this helps,


felix


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Prev by Date: NSTreeController w/Core Data: chaining NSManagedObjects in a hierarchy
  • Next by Date: Re: NSUserDefaults
  • Previous by thread: Re: Bindings Faked Array Item Problem
  • Next by thread: AppleScript and sdef
  • Index(es):
    • Date
    • Thread