Sync problems with NSArrayController + NSSortDescriptor + NSTextField
Sync problems with NSArrayController + NSSortDescriptor + NSTextField
- Subject: Sync problems with NSArrayController + NSSortDescriptor + NSTextField
- From: Dado Colussi <email@hidden>
- Date: Sun, 11 Jan 2009 18:54:38 +0100
Hello,
*** A short description of the problem ***
NSTextField that is bound to NSArrayController's 'selection.attribute'
such that the attribute is part of the NSArrayController's sort
descriptors gets out of sync when modified.
*** A longer description of the problem ***
I have an NSTableView with a single column bound to an
NSArrayController that manages an entity in an XML Core Data storage.
I have programmatically added one NSSortDescriptor to the array
controller for attribute 'name'. I have bound the table's 'content'
and 'selectionIndexes' to the array controller, and left the
'sortDescriptors' unbound. From mmalc's controller examples I
understand that this prevents the user from manipulating the sort
descriptors when interacting with the table.
In my detail view, I have an NSTextField that is has its 'value' bound
to the array controller's 'selection.name'. I also have other text
fields bound to other attributes in the array controller, essentially
to attributes that are not part of the sort descriptor.
When I modify the text field for attribute 'name' and press enter, the
value in the table view changes, and the item gets sorted properly.
However, the text field reverts to the previous value, as if I had not
changed it, and I lose focus on the text field. Changing selection in
the table refreshes the text field back to sanity. For the sake of
curiosity, I added another NSTextField and bound it to the same
attribute 'name'. I discovered that the problem occurs only with the
text field that is edited. The non-edited text field is updated
correctly. I also tried removing the table entirely, and it did not
help.
I have tried 10.5 and 10.4 SDK's on Leopard, and both show the same
problem. Running the binary on Tiger, or building it from source code
on Tiger, does not produce the problem, but then the array controller
does not sort automatically. In Tiger, I can get around this problem
by sending -rearrangeObjects to the array controller in the text
field's delegate's -controlTextDidEndEditing: method.
Can someone explain me what is going on and how to get around this on
Leopard?
Thanks!
/Dado
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden