iphone - How can i remove array of dictionary from NSMutableDictionary? -
i have dictionary of array (inside that, array , dictionarry).
i added uitableviewcelleditingstyledelete
in uitableview, want remove specific array of dictionary dictionary.
console view of data:
{ = ( { 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"; } ); }
i want delete example : index of array 1
dictionary key a
i have tried following code
- (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) { } }
but can not delete record main nsmutabledictionary
.
try this
- (void)tableview:(uitableview *)tableview commiteditingstyle:(uitableviewcelleditingstyle)editingstyle forrowatindexpath:(nsindexpath *)indexpath { if (editingstyle == uitableviewcelleditingstyledelete) { nsstring *key = self.listofheader[indexpath.section]; nsmutablearray *users = [self.finalpdic[key] mutablecopy]; [users removeobjectatindex:indexpath.row]; if (users){ self.finaldic[key] = users; }else{ [self.finaldic removeobjectforkey:key]; } [self.tblview reloadrowsatindexpaths:@[indexpath] withrowanimation:uitableviewrowanimationautomatic]; } if (editingstyle == uitableviewcelleditingstyleinsert){ } }
Comments
Post a Comment