Re: KVC Problems with Indexed Accessor for To-Many Properties
Re: KVC Problems with Indexed Accessor for To-Many Properties
- Subject: Re: KVC Problems with Indexed Accessor for To-Many Properties
- From: joe OneNinetyTwo <email@hidden>
- Date: Sat, 14 Oct 2006 10:48:27 -0700 (PDT)
Ok, that makes sense. However, I tried for a few
hours, and I still don't see a approach for
implementing this idea. Let's say I create a Datum
object for my array controller, and this Datum (core
data) object contains a NSMutableDictionary.
Whenever the array controller needs to update a row in
the table, it sends the message
objectInDataPointsAtIndex:
I've tried two different ways to write
objectInDataPointsAtIndex: using Datum...
(1) In this version of the method I extract the values
out of my NSData object using the index, and then
place them in the
dictionary of a freshly created datum object, and
return that object to the array Controller. Problem
with this approach
is I end up generating thousands of Datum objects in
my managedObject Space, with one created every time
objectInDataPointsAtIndex is called. I autorelease
them right after creation, but they don't seem to
disappear when
the array controller is done with them. Even if I
could get rid of the unwanted datum objects, I think
this approach still needs
a datum object for every dataPoint, and if so, then it
sort of defeats the purpose of using the indexed
accessors for a "faked"
array. So, I tried the next approach...
(2) In this version of the method I extract the
values out of my NSData object using the index, and
then place them in the
dictionary of a single global datum object, and return
that object to the array Controller. This approach
resulted in an
infinite loop (here's a taste below - read bottom up):
#73210 0x000f1f04 in -[DataSet
objectInDataPointsAtIndex:] at DataSet.m:97
#73211 0x92a13760 in -[NSKeyValueArray objectAtIndex:]
#73212 0x9395a850 in -[NSTableBinder
_visibleRowIndexesForObject:]
#73213 0x9395a1d4 in -[NSTableBinder
observeValueForKeyPath:ofObject:change:context:]
#73214 0x9296facc in
-[NSObject(NSKeyValueObserverNotification)
didChangeValueForKey:]
#73215 0x907d0cc4 in CFDictionarySetValue
#73216 0x929424a4 in -[NSCFDictionary
setObject:forKey:]
#73217 0x929ea6f4 in -[NSObject(NSKeyValueCoding)
setValue:forKeyPath:]
#73218 0x000f1f04 in -[DataSet
objectInDataPointsAtIndex:] at DataSet.m:97
#73219 0x92a13760 in -[NSKeyValueArray objectAtIndex:]
#73220 0x9395a850 in -[NSTableBinder
_visibleRowIndexesForObject:]
#73221 0x9395a1d4 in -[NSTableBinder
observeValueForKeyPath:ofObject:change:context:]
#73222 0x9296facc in
-[NSObject(NSKeyValueObserverNotification)
didChangeValueForKey:]
#73223 0x907d0cc4 in CFDictionarySetValue
#73224 0x929424a4 in -[NSCFDictionary
setObject:forKey:]
#73225 0x929ea6f4 in -[NSObject(NSKeyValueCoding)
setValue:forKeyPath:]
#73226 0x000f1f04 in -[DataSet
objectInDataPointsAtIndex:] at DataSet.m:97
The array controller calls objectInDataPointsAtIndex
which updates Datum's dictionary with values from
NSData,
and once the dictionary is updated, the array
controller learns the datum has been updated, so it
calls
objectInDataPointsAtIndex again, ...
I would love to stick with bindings, but it's still
not obvious how I can do it with a mutable "faked"
array and KVC indexed accessors. - Philip
--- Scott Stevenson wrote:
> The custom class can do whatever notifications are
> necessary when the
> propery is modified. That's how Core Data works, in
> fact.
>
> - Scott
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
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