这是我删除价值的代码。当我重新启动应用程序时,表视图正在删除记录临时记录,它也会显示已删除的记录...
-(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];