【发布时间】:2013-07-12 17:03:35
【问题描述】:
我的应用中有 2 个独立的数据存储,它们同时进入后台线程。因此我有这个代码来设置它:
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter addObserver:self.dataStoreManager
selector:@selector(mergeChanges:)
name:NSManagedObjectContextDidSaveNotification
object:nil];
NSPersistentStoreCoordinator *dataStoreBackgroundPSC = self.dataStoreManager.managedObjectContext.persistentStoreCoordinator;
[notificationCenter addObserver:[AppDelegate applicationDelegate].coreDataManager
selector:@selector(mergeChanges:)
name:NSManagedObjectContextDidSaveNotification
object:nil];
NSPersistentStoreCoordinator *journalDataPSC = [AppDelegate applicationDelegate].coreDataManager.persistentStoreCoordinator;
这会导致问题,因为两个对象都会收到通知,还是会以不会对任一数据存储产生负面影响的方式处理它?
编辑: 好吧,事实证明这并不好。备择方案?如果我不在后台线程中保存其中一个,它还需要那个通知吗?
【问题讨论】:
标签: iphone ios objective-c core-data nsmanagedobject