I've got a NSOutlineView backed up NSTreeController which is getting data from an NSManagedObjectContext and everything works perfect except inserting new objects.
I want to insert a new object, then immediately put focus on it and make it editable.
If I create a new NSManagedObject via:
Obj *p = [NSEntityDescription insertNewObjectForEntityForName:@"Obj"
inManagedObjectContext:[self managedObjectContext]];
it gets immediately inserted but I can't seem to select it and get it.
Now, if I insert it via
NSUInteger pathSource[2] = {0, 0};
[self.projectTreeController insertObject:p
atArrangedObjectIndexPath:[NSIndexPath indexPathWithIndexes:pathSource length:2]];
It's immediately selected and I can make it editable.
The problem is that I cannot use both methods (I see double entries), and can't use method #2 without first using #1.
Ideally, I'd like to use method #2 but without making duplicate entries.
So, what's the preferred way to insert/add a new object that's backed up by Core Data?