I have a list of favorites that are stored in the NSUserDefaults, single favorited are stored by NSDictionary:
NSUserDefaults *userPref = [NSUserDefaults standardUserDefaults];
NSMutableDictionary *bookmark = [NSMutableDictionary new];
[bookmark setValue:author.text forKey:@"author"];
[bookmark setValue:book.text forKey:@"book"];
[bookmarks addObject:bookmark];
[userPref setObject:bookmarks forKey:@"bookmarks"];
[userPref synchronize];
Everything is ok, but now I want to delete a single favorite with the swipe of a cell. I have add the method for show the the delete swipe but I do not know how to remove the single bookmark from nsuserdefaults.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
NSUInteger row = [indexPath row];
[self.listBookamrks removeObjectAtIndex:row];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
withRowAnimation:UITableViewRowAnimationFade];
}