[問題] Core Data Fetch與GCD的問題
想問一個關於CoreData的Fetch和GCD的問題
因為我的database有11萬筆資料
所以我在AppDelegate 的didFinishLaunchingWithOptions: 裡面用GCD進行Fetching
==in AppDelegate -application:didFinishLaunchingWithOptions:
// 把fetchRC的delegate設為tableVC
self.fetchedResultsController.delegate = self.tableViewController;
// 用GCD進行fetch
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
^{
NSError *error = nil;
if (![self.fetchedResultsController performFetch:&error])
{
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
self.fetchObjects = [self.fetchedResultsController fetchedObjects];
// 加入這行之後 tableView才會更新
[self.tableViewController.tableView reloadData];
});
==
這樣的話App開啟的時候會直接顯示我的table view
但是等fetch跑完之後table view的data並沒有更新
tableViewController裡面的NSFetchedResultsControllerDelegate methods被沒有被呼叫
於是我在GCD裡的最後一行 加入了reloadDta強迫tableView重新載入資料
但是reloadData執行完後 table view卻等了5秒鐘才更新
請問
1) NSFetchedResultsControllerDelegate methods沒被呼叫是正常的嗎?
2) 有沒有辦法加速在reload完之後 更新tableView的速度?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 60.198.45.233
※ 編輯: leondemon 來自: 60.198.45.233 (09/11 03:34)
推
09/11 06:50, , 1F
09/11 06:50, 1F
→
09/11 06:51, , 2F
09/11 06:51, 2F
→
09/11 06:51, , 3F
09/11 06:51, 3F
→
09/11 17:00, , 4F
09/11 17:00, 4F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 3 篇):
MacDev 近期熱門文章
PTT數位生活區 即時熱門文章