Core Data and user interface updates
One of the most common problems for Core Date newbies is updating user interface by using NSArrayController when creating a new core data entity by code (not by simply using [arrayController add:nil])
Here is an example for what I mean by code
- (id)newEntity
{
// Create an entry
id entry = [NSEntityDescription insertNewObjectForEntityForName: "Person"
inManagedObjectContext: managedObjectContext ];
// Use entry
// ...
return entity;
}
If you are using bindings depended on NSArrayController.selection, this will happen after the newEntity method finishes its work. The processPendingChanges method will process all core data relevant changes including just inserted entities. This will trigger all the KVO stuff which will then update your UI immediately.
- (id)newEntity
{
// Create an entry
id entry = [NSEntityDescription insertNewObjectForEntityForName: "Person"
inManagedObjectContext: managedObjectContext ];
// This will update the user interface
[managedObjectContext processPendingChanges];
// Use entry
// …
return entity;
}


