是否可以从 fetchedResultsController fetchedObjects 中移除对象?
例如我有以下代码:
NSPredicate *predicate = [NSPredicate predicateWithFormat"pack.packName IN %@", allowedPackNames];
for (int i = 0; i < [tempFetchResults.fetchedObjects count]; i++){
Author *author = [tempFetchResults.fetchedObjects objectAtIndex:i];
NSSet *filteredQuotes = [author.quotes filteredSetUsingPredicate:predicate];
if ([filteredQuotes count] > 0){
author.quotes = filteredQuotes;
} else {
//remove this author from the fetchedObjects array
}
}
我该怎么做?
从数据存储中删除对象:
[self.managedObjectContext deleteObjectbject];
[self.managedObjectContext save:nil];
[self.fetchedResultsController self.fetchedResultsController.fetchRequest];
[tableView reloadData];
要从获取的结果 Controller 数组中删除对象,您需要更改谓词。确保禁用缓存(或更改缓存名称)以使其正常工作。
关于iphone - 从 fetchedResultsController fetchedObjects 中移除一个对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15828983/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |