ios - UITableviewcell show delete button from using dictionary keys instead of NSMutableArray array data -


this code delete row in tableviewcell.

  - (void)tableview:(uitableview *)tableview commiteditingstyle:(uitableviewcelleditingstyle)editingstyle forrowatindexpath:(nsindexpath *)indexpath     {         if (editingstyle == uitableviewcelleditingstyledelete) {           [keys removeobjectatindex:indexpath.row];  // line error             [_tableview deleterowsatindexpaths:[nsmutablearray arraywithobject:indexpath] withrowanimation:uitableviewrowanimationfade];         } } 

the error line `[keys removeobjectatindex:indexpath.row];' .

i know code should use in nsmutablearray, want use same method dictionary keys plist delete cell.

the editable:

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath{     static nsstring *cellidentifier = @"cell";     customecell *customecell = [self.tableview dequeuereusablecellwithidentifier:cellidentifier];     if (customecell == nil){         customecell =[[customecell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier];     }     customecell.namelbl.text = [keys objectatindex:indexpath.row];     customecell.img.image = [uiimage imagenamed:[[content valueforkey:[keys objectatindex:indexpath.row]] valueforkey:@"image"]];     customecell.statuslabel.text = [[content valueforkey:[keys objectatindex:indexpath.row]] valueforkey:@"status"];     nsdateformatter *dateformatter = [[nsdateformatter alloc] init];     [dateformatter setdateformat:@"yyyy-mm-dd hh:mm"];      // nsstring *datestring = [dateformatter stringfromdate:[nsdate date]];  // current date     nsstring *datestring = [dateformatter stringfromdate:[[content valueforkey:[keys objectatindex:indexpath.row]] valueforkey:@"date"]];     nslog(@"date: %@", datestring);     customecell.datelbl.text=datestring;     return customecell; 

try code

      - (void)tableview:(uitableview *)tableview commiteditingstyle:(uitableviewcelleditingstyle)editingstyle forrowatindexpath:(nsindexpath *)indexpath         {             if (editingstyle == uitableviewcelleditingstyledelete) {                 [_tableview deleterowsatindexpaths:[keys objectatindex:indexpath.row] withrowanimation:uitableviewrowanimationfade];                 [keys removeobjectatindex:indexpath.row];  // line error             }     } 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -