通过tableview单元格删除NSUserDefault的对象

我有一个存储在NSUserDefaults中的collections夹列表,单个collections夹由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]; 

一切正常,但现在我想用单元格的滑动来删除单个最爱。 我添加了显示删除刷卡的方法,但我不知道如何从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]; } 

  NSUserDefaults *userPref = [NSUserDefaults standardUserDefaults]; NSMutableDictionary *storedBookMark = [[userPref ObjectForKey:@"bookmarks"]mutable copy]; // If you want to remove an object from the dictionary [storedBookMark removeObjectForKey:@"Your KEy"]; // if you want to empty the dictionary [storedBookMark removeAllObjects]; [userPref setObject: storedBookMark forKey:@"bookmarks"]; [userPref synchronize]; // if you want to store nil // go back to default state .. [userPref setNilValueForKey:@"bookmarks];