Best practices : use array controller to insert objects into managed object context
Best practices : use array controller to insert objects into managed object context
- Subject: Best practices : use array controller to insert objects into managed object context
- From: Dale Schack <email@hidden>
- Date: Mon, 9 Oct 2006 21:52:12 -0600
I have a NSTableView which handles viewing of managed objects, via an
NSArrayController (which is bound to a managedObjectContext, and to a
contentSet). When adding managed objects to the managed object
context, I want to add them such that I can determine where the newly
inserted objects will appear within the table view.
I came across some sample code that showed the following steps:
1) Create a new managed object via
newObj = [NSEntity
insertNewObjectForEntityForName:inManagedObjectContext:]
2) Insert the new managed object into the array controller
[arrayController insertObject:newObj atArrangedObjectIndex:i]
This works fine, in that I get a single object added to the object
context, and it appears at the correct location in the table view.
My question is the following: is this a good methodology to use, or
should I be following a different path? That is, is it valid to add/
insert objects to the controller, after having created the object via
NSEntity?
Thanks,
Dale
_______________________________________________
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