XMPP加载好友列表报错 'NSInternalInconsistencyException', reason: 'Invoked on incorrect queue'

打了个全局断点,发现进入到\XMPPCoreDataStorage.h的头文件的managedObjectContext方法的实现上面 上面有错误说明

大概是这不是安全的context在线程里面(non thread safe)

这时候发现原来在好友列表FetchedResultsController加载方法中,用错了该context

错误:NSEntityDescription *entity = [NSEntityDescription entityForName:@"XMPPUserCoreDataStorageObject.h" inManagedObjectContext:[XMPPRosterCoreDataStorage sharedInstance].managedObjectContext];

正确: NSEntityDescription *entity = [NSEntityDescription entityForName:@"XMPPUserCoreDataStorageObject.h" inManagedObjectContext:[XMPPRosterCoreDataStorage sharedInstance].mainThreadManagedObjectContext];

猜你喜欢

转载自blog.csdn.net/MChuajian/article/details/82148512