I am trying to figure out exactly what is happening here.

I have a mutable dictionary where each object is also an NSMutableDictionay
containing 9 string objects.

NSMutableDictionary*  myData;    // this is in MyController object.

In a window, I have an NSTableView whose column data is tied to an
NSArrayController. The NSArrayController is bound to myData with IB:

Bind to MyController, keypath: myda...@allvalues

This all works fine, except....

I would expect the following to have the same addresses:

NSMutableDictionary*    myItemA =
[[[MyController myData] allValues] objectAtIndex:0];

NSMutableDictionary*   arrayContItemA =
[[myArrayController arrangedObjects] objectAtIndex:0];

The content is the same (the 9 strings) so it is coming from the right
place, but the addresses of the objects are different so for some reason the
NSArrayController is making a copy of my dictionary object somewhere along
the line.

I understand that the array returned by allValues is not mutable so the
NSArrayController may need to make a mutable copy of it, but the internal
objects are mutable... So why is it copying my objects?

If I add the following just before the above two lines, then the objects
have the same address as expected.

[MyController willChangeValueForKey:@"myData"];
[MyController didChangeValueForKey:@"myData"];

So I gather this is forcing the NSArrayController to write it's
copied/cached values back to myData.

The point is that I need to be able to edit the items in the NSTable, then
write myData back to disk and have the changes be saved. If I never call
will/didChangeValueForKey, then the changes are lost.

Since I am not changing myData directly but it is being changed by the
NSTableView and NSArrayController, why does this happen this way?

Thanks,

Trygve


_______________________________________________

Cocoa-dev mailing list ([email protected])

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