这是我删除值的代码。当我重新启动应用程序时, TableView 正在临时删除记录,它也会显示已删除的记录...
-(void)tableView:(UITableView *)atableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
[bookmarks removeObjectAtIndex:indexPath.row];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil] withRowAnimation:UITableViewRowAnimationFade];
[[NSUserDefaults standardUserDefaults] setObject:bookmarks forKey:@"Bookmarks"]; [self.tableView reloadData];
}
}
请帮忙。
最佳答案
试试这个:
// Your code
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
[prefs setObject:bookmarks forKey:@"Bookmarks"];
// saving it all
[prefs synchronize];
关于iphone - UITableView 没有从 NSUserDefaults 中删除记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6058034/