Perhaps I just can't get my head around the terminology sufficiently to search on the right thing...feel free to enlighten me.

I have an NSTableView, whose content is supplied through bindings to an array controller. Column A is supplied via FieldListController.arrangedObjects.name, Column B via FieldListController.arrangedObjects.value; column B is editable, column A is not.

I'm trying to observe when a cell in Column B is edited by

[thing addObserver:self
        forKeyPath:@"fieldList"
options:(NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew)
           context:nil];

When I edit a field (by double-clicking it) and commit the edit (pressing Return), in my - observeValueForKeyPath:ofObject:change:context: method, "keyPath" is "fieldList" and "object" is the object that owns the fieldList that is being observed.

The NSKeyValueChangeKindKey in the change dictionary is NSKeyValueChangeSetting; NSKeyValueChangeNewKey and NSKeyValueChangeOldKey are both arrays containing all the observed fields in "fieldList". But those "fields" are not the values that are being edited, they are the objects which contain the values that are being edited (i.e., [field value] is what's getting edited (and [field name] is what's displayed in Column A).

OK, so all that makes sense, in that I'm observing "fieldList", and the notification hands me an array (which is fieldList). However, it doesn't tell me *which* field in the array was edited; I have to iterate over all the fields, comparing the values from "old" and "new" to figure out which specific field was edited.

I tried changing the observed keyPath to @"fieldList.value", but that only succeeded in having the table not display anything at all (which doesn't make sense to me either).

Is it possible to know exactly which array element was edited, without registering observers on the entire contents of the array? I figure it has something to do with the keyPath, but the exact something has thus far eluded me.


Thanks!
randy
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com

Reply via email to