• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Best practices : use array controller to insert objects into managed object context
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: NSTreeController selection (probably a silly mistake)
  • Next by Date: Code injection and replace methods at runtime
  • Previous by thread: Re: NSTreeController selection (probably a silly mistake) (solved and it was silly)
  • Next by thread: Code injection and replace methods at runtime
  • Index(es):
    • Date
    • Thread