I'm using cocoa-binding to bind NSTableView
to Core Data
like the following
_arrayController = [[MyArrayController alloc] init];
[_arrayController setEntityName:@"User"];
[_arrayController setManagedObjectContext:self.managedObjectContext];
[_arrayController setUsesLazyFetching:NO];
[self.tableView bind:NSContentBinding toObject:self.arrayController withKeyPath:@"arrangedObjects" options:nil];
[_arrayController fetch:nil];
and everything seems to work well.
But one thing I don't understand is the effect of automaticallyPreparesContent
and automaticallyRearrangesObjects
properties of NSArrayController. According to the documentation, both are NO
by default and I didn't change them either.
Doc says
If flag is YES and a managed object context is set, the initial content is fetched from the managed object context using the current fetch predicate. The controller also registers as an observer of its managed object context. It then tracks insertions and deletions of its entity using the context's notifications, and updates its content array as appropriate.
and I think it means, if the flag is NO, content array isn't updated with newly inserted objects to managed object context. But it is updated when I insert a new managed object to the managed object context. What do I misunderstand?
And, about automaticallyRearrangesObjects
Doc says
Sets whether or not the receiver automatically rearranges its content to correspond to the current sort descriptors and filter predicates.
which means, I think, if the flag is NO, content isn't rearranged even if array controller's sort descriptors or filter predicate are changed. But it is! When I change filter predicate or sort descriptors, rows on table view, which is bound to the array controller, are rearranged.
I'm quite confused of what I don't know or do misunderstand about NSArrayController's behaviors.