【发布时间】:2023-03-29 06:24:01
【问题描述】:
我有一个将核心数据与 iCloud 集成的应用程序。我的视图控制器中有以下通知。
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadFetchedResults:) name:NSPersistentStoreCoordinatorStoresDidChangeNotification object:coreDataController.psc];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadFetchedResults:) name:NSPersistentStoreDidImportUbiquitousContentChangesNotification object:coreDataController.psc];
视图控制器包含一个使用NSFetchedResultsController 加载核心数据的UITableView。我不确定在以下方法(由上面的通知调用)中放入什么来刷新表格。我已经尝试重新加载表并重新获取数据但无济于事。我知道 iCloud 正在完成它的工作,因为如果我完全重新加载视图控制器,更改的数据就会显示出来。
- (void)reloadFetchedResults:(NSNotification*)note {
NSLog(@"Underlying data changed ... refreshing!");
//_fetchedResultsController=nil;
//[self fetchedResultsController];
[theTableView reloadData];
}
任何帮助将不胜感激,谢谢!
【问题讨论】:
-
您真的在刷新数据源吗?还是只是重新加载表格?
-
好吧,我已经尝试调用
NSFetchResultsController委托方法来重新获取数据,(注释掉的位)但这也没有用。