开发者

UITableView is not deleting record from NSUserDefaults

Here is my code to delete value. Table view is deleting record temporary when I restart my app it will show deleted records also...

-(void)tableView:(UITableView *)atableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        [bookmarks removeObjectAtIndex:indexPath.row];
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil] withRowAnimation:UITabl开发者_如何学JAVAeViewRowAnimationFade];
       [[NSUserDefaults standardUserDefaults] setObject:bookmarks forKey:@"Bookmarks"];  [self.tableView reloadData];
    }
}

Please Help.


Try this :

// Your code    
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];  
[prefs setObject:bookmarks forKey:@"Bookmarks"];    
// saving it all  
[prefs synchronize];  
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜