我正在编写一个应用程序来显示门户网站的一些新闻.使用来自Internet的JSON文件获取新闻,然后使用CoreData模型将其存储到NSMutableArray中.显然,用户无法从Internet上的JSON文件中删除新闻,但他可以在本地隐藏它们.问题出现在这里,我有以下代码:
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
if( !moc ){
moc = [[NewsFetcher sharedInstance] managedObjectContext];
}
[[dataSet objectAtIndex:indexPath.row] setEliminata:[NSNumber numberWithBool:YES]];
NSError *error;
if( ![moc save:&error] ){
NSLog( @"C'è stato un errore!" );
}
[dataSet removeObjectAtIndex:indexPath.row];
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
}
Run Code Online (Sandbox Code Playgroud)
这条线:
[dataSet removeObjectAtIndex:indexPath.row];
导致我的应用程序崩溃,出现以下错误:
2010-07-12 19:08:16.021 ProvaVideo [284:207] * - [_ PFArray removeObjectAtIndex:]:无法识别的选择器发送到实例0x451c820 2010-07-12 19:08:16.022 ProvaVideo [284:207]*终止app到期到未捕获的异常'NSInvalidArgumentException',原因:'*** - [_ PFArray removeObjectAtIndex:]:无法识别的选择器发送到实例0x451c820'
我试图理解为什么它不起作用但我不能.如果我重新启动应用程序,则会正确地以逻辑方式取消新应用程序.有什么建议??提前致谢.
接口:
@interface ListOfVideo : UITableViewController <NSFetchedResultsControllerDelegate> {
NSMutableArray *dataSet;
}
@property …Run Code Online (Sandbox Code Playgroud)