Re: Bindings Faked Array Item Problem
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