I use NSFetchedResultsControllerc UITableView, which displays a list of folders and related unread counts for each item in this folder. I would like to insert / remove animation folders from the View table based on unread count during synchronization / update (in background thread using NSManagedObjectContextDidSaveNotification). Folders without unread items should disappear, and existing folders with new unread items should disappear.
Currently, using the method controller:didChangeObject:atIndexPath:forChangeType:newIndexPath:does not do this unless the View table is completely reloaded or the application is overwritten, which is not ideal.
Isn't NSFetchedResultsControllerthere a way to do this? My initial idea was to create a separate Core Data object that contains only folders with unread items and add / remove folders from this, but it just seems to be hokey.
My NSPredicatelooks something like this:
ANY items.unread == 1
Update:
The above NSPredicate works fine and captures the objects I expect. My problem is that if the application starts and there are 0 unread items in FolderX, it will not appear. If I then update (it goes out and parses the JSON file in the background stream), and FolderX now has 25 unread items, it will not automatically disappear or start NSFetchedResultsChangeInsert, and since it was not turned on in the first place, it also does not call NSFetchedResultsChangeUpdate, so I decided that the solution is to create a separate object that contains only folders with unread items and adds / removes them during synchronization.
I just feel that I am missing something painfully obvious.
2:
, , , Xcode.
:
"" "" " ". NSFetchedResultsController NSPredicate, :
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"unreadCount < 10"];
, , unreadCount 15, 1. ManagedObjectContext ( , ).
controllerWillChangeContent , , , ( unreadCount 15) 5 ( 10), tableView, . , , , .
, "" ( ). , View, "" , , .
NSFetchedResultsController , , ?
: http://dl.dropbox.com/u/521075/BGUpdating.zip