FROM : Sean McBride
DATE : Fri Apr 18 23:54:59 2008
Hi all,
Consider an app that uses bindings and Core Data. It has a tableview
bound to an array controller. There is an 'Add' button that creates a
new entity to be shown in the table. It could be implemented by:
1) sending add: to the array controller.
2) using a custom IBAction method that creates a new entity and adds it
to the managed object context.
#1 is nice because the array controller will automatically select the
newly added object (if selectsInsertedObjects is YES). However, I find
myself often needing to use method #2 because I must supply some initial
data to create the new entity. In that case, the array controller sees
the new entity but does not select it.
What is the "right" way to get it selected? Should I just pass the new
NSManagedObject up to my view-controller and call
[theArrayController:setSelectedObjects:[NSArray
arrayWithObject:newManagedObject]]? If so, how do I do it in the tree
controller case? There is no setSelectedObjects:.
Thanks,
--
____________________________________________________________
Sean McBride, B. Eng <email_removed>
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
DATE : Fri Apr 18 23:54:59 2008
Hi all,
Consider an app that uses bindings and Core Data. It has a tableview
bound to an array controller. There is an 'Add' button that creates a
new entity to be shown in the table. It could be implemented by:
1) sending add: to the array controller.
2) using a custom IBAction method that creates a new entity and adds it
to the managed object context.
#1 is nice because the array controller will automatically select the
newly added object (if selectsInsertedObjects is YES). However, I find
myself often needing to use method #2 because I must supply some initial
data to create the new entity. In that case, the array controller sees
the new entity but does not select it.
What is the "right" way to get it selected? Should I just pass the new
NSManagedObject up to my view-controller and call
[theArrayController:setSelectedObjects:[NSArray
arrayWithObject:newManagedObject]]? If so, how do I do it in the tree
controller case? There is no setSelectedObjects:.
Thanks,
--
____________________________________________________________
Sean McBride, B. Eng <email_removed>
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
| Related mails | Author | Date |
|---|---|---|
| Sean McBride | Apr 18, 23:54 | |
| Ron Lue-Sang | Apr 19, 03:46 | |
| Sean McBride | May 7, 23:09 |






Cocoa mail archive

