我有数组字典(里面还有数组和字典)。
我UITableViewCellEditingStyleDelete
在我的 UITableView 中添加了,所以我想从字典中删除特定的字典数组。
数据的控制台视图:
{
A = (
{
address = "Talala (gir)";
"main_id" = 1;
mobile = 8878876884;
name = "Amit Patel";
},
{
address = "Junagdh";
"main_id" = 5;
mobile = 4894679865;
name = "Arjun Patel";
}
);
J = (
{
address = "Taveli";
"main_id" = 6;
mobile = 87886356085878;
name = "Jasmin Patel";
},
{
address = "Gujarat";
"main_id" = 4;
mobile = 6636633368;
name = "Jatin ";
}
);
R = (
{
address = "Mumbai";
"main_id" = 2;
mobile = 999686322;
name = "Rajan Patel";
}
);
S = (
{
address = "Rajkot";
"main_id" = 3;
mobile = 8866086549;
name = "Sumit Patel";
}
);
}
我想删除例如:数组的索引来自带有键A1
的字典
我必须尝试使用以下代码
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete)
{
NSDictionary *dic = [[self.finalPDic objectForKey:[self.listOfHeader objectAtIndex:indexPath.section]] objectAtIndex:indexPath.row];
NSLog(@"%@",dic);
[self.finalPDic removeObjectForKey:dic];
NSLog(@"%@",self.finalPDic);
[self.tblView reloadData];
}
if (editingStyle == UITableViewCellEditingStyleInsert)
{
}
}
但我无法从 main 中删除任何记录NSMutableDictionary
。