So I'm used to iOS development so I'm pretty happy with NSFetchedResultsController. However, this is not present in the Mac OS X environment. I know that I can use NSArrayController as a replacement. I might be using this class terribly wrong but it worked until now. I initialize the NSArrayController as follows:
NSArrayController* newConversationsController = [NSArrayController new];
newConversationsController.managedObjectContext = context;
newConversationsController.entityName = entityName;
newConversationsController.sortDescriptors = sortDescriptors;
newConversationsController.automaticallyRearrangesObjects = YES;
NSError* error = nil;
[newConversationsController fetchWithRequest:nil merge:NO error:&error];
NSCAssert(!error, error.description);
Then I listen to changes of the NSManagedObjectContext and fetch and reload the NSTableView as follows:
[self.conversationsController fetchWithRequest:nil merge:YES error:&error];
NSAssert(!error, error.description);
[self.tableView reloadData];
As I previously mentioned, I might be using this totally wrong but I don't like to use bindings. Now to the actual issue: Another class of the application might delete an NSManagedObject held by the NSArrayController. The NSArrayController instantly releases this deleted object and makes it impossible for me to figure out which object that was. The final goal is to know what object at what index has been deleted so I can animate the rows of the NSTableView.
I hope it's clear what I'm aiming at. Thanks for any help
there are no sections in a NSTableView so there is no 1:1 replacement
BUT NSArrayController is a close match! It also fetches and sorts CoreData entities.
For the UI you'd use bindings then (but of course you don't have to)
e.g. see:
http://cocoadevcentral.com/articles/000080.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With