Re: [問題] Core Data Fetch與GCD的問題
推
09/11 06:50,
09/11 06:50
→
09/11 06:51,
09/11 06:51
→
09/11 06:51,
09/11 06:51
謝謝D大幫我解決了 App開啟時load data的問題
但是目前遇到了另外一個狀況:
我做了一個字典的功能 並用searchBar可以搜尋單字 然後如法炮製(如下)
// UISearchBarDelegate method
- (void)searchBar:(UISearchBar *)searchBar
textDidChange:(NSString *)searchText
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
, ^{
NSPredicate *predicate = [NSPredicate predicateWithFormat:
@"word BEGINSWITH %@", searchText];
self.searchObjects = [self.fetchedResultsController.fetchedObjects
filteredArrayUsingPredicate:predicate];
dispatch_async(dispatch_get_main_queue(), ^{
[self.tableView reloadData];
});
});
}
結果是cell.textLabel.text的資料是有更新
但畫面上的table cell卻沒有更新
變成要手動捲動table view時cell的textLabel才會更新
當我打"b"的時候 tableView第一個cell 依然是A開頭的字
當我打"bo"的時候 tableView第一個cell 是b
當我打"boy"的時候 tableView第一個cell 指出現是bo
也就都是上一個搜尋的結果
請問這個問題要怎麼解決呢?
=====
自問自答:
我忘了實際顯示的table不是原來的那一個
應該是searchDisplayController.searchResultsTableView 的這個tableView做reload
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 42.72.144.20
※ 編輯: leondemon 來自: 42.72.144.20 (09/11 17:40)
※ 編輯: leondemon 來自: 42.72.144.20 (09/11 17:59)
討論串 (同標題文章)