Best practices : use array controller to insert objects into managed object context

  • 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

    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


previous month october 2006 next month
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Go to today