开发者

UITableView is not deleting record from NSUserDefaults

开发者 https://www.devze.com 2023-03-06 20:09 出处:网络
Here is my code to delete value. Table view is deleting record temporary when I restart my app it willshow deleted records also...

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

精彩评论

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