search

Home  >  Q&A  >  body text

Objective-c - NSFetchedResultsController CoreData callback issue

request.predicate = [NSPredicate predicateWithFormat:@"streamBareJidStr=%@",[SXXMPPTools sharedXMPPTools].xmppStream.myJID];



// 从自己写的工具类里的属性中得到上下文
NSManagedObjectContext *ctx = [SXXMPPTools sharedXMPPTools].xmppMessageArchivingCoreDataStorage.mainThreadManagedObjectContext;

// 实例化,里面要填上上面的各种参数
_fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:request managedObjectContext:ctx sectionNameKeyPath:nil cacheName:nil];

_fetchedResultsController.delegate = self;

return _fetchedResultsController;

}

pragma mark fetcedresults proxy method context change

I added this query condition request.predicate = [NSPredicate predicateWithFormat:@"streamBareJidStr=%@",[SXXMPPTools sharedXMPPTools].xmppStream.myJID]; I added this query condition and there will be no callback when the database content changes.
This is the data for reading XMPP chat messages because you need to switch accounts to log in. I don’t want to find out the historical messages of previous accounts, so I need to add this predicate

巴扎黑巴扎黑2841 days ago353

reply all(0)I'll reply

No reply
  • Cancelreply