【发布时间】:2012-11-10 15:01:27
【问题描述】:
嗨
我想通过 UITableView 从 NSMutableArray 中删除项目,但是应用程序崩溃了。
崩溃是“0 objc_msgSend”。
这是我的代码伙计们:
- (void)viewDidLoad
{
paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
path = [basePath stringByAppendingPathComponent:@"favoris.plist"];
dict = [[NSArray arrayWithContentsOfFile:path] mutableCopy];
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
[dict removeObjectAtIndex:indexPath.row];
[self.tableView reloadData];
}
谢谢
【问题讨论】:
-
嗨,欢迎来到 SO!为了让我们帮助您找出问题所在,如果您发布应用程序崩溃时打印的错误信息,将会非常有帮助。
-
@lnafziger 好吧,对不起,伙计,我刚刚更新了我的帖子;)
-
不需要任何借口。如果您发布它打印的 整个 消息,它会更有帮助。 ;)
-
[MyViewController tableView:tableView commitEditingStyle:editingStyle forRowAtIndexPath:indexPath]还有一个 EXC_BAD_ACCESS 在线:[dict removeObjectAtIndex:indexPath.row]; -
另外,正如@Inafziger 所暗示的,它确实看起来像记忆。你能按照这些说明寻找僵尸吗? stackoverflow.com/questions/5386160/…
标签: iphone objective-c uitableview nsmutablearray plist