objective c - set checkmark in uitableView as the data is being loaded in the cell in ios -


i want checkmark data when data being loaded in uitablecell. know works when put in didselect section can use in cellforrowatindexpath. if yes how use it? have tried doesn't show checkmarks.

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *simpletableidentifier = @"addgoalstableviewcell";  addgoalstableviewcell *cell = (addgoalstableviewcell *)[self.tableview dequeuereusablecellwithidentifier:simpletableidentifier];  if (cell == nil) {     nsarray *nib = [[nsbundle mainbundle] loadnibnamed:@"addgoalstableviewcell" owner:self options:nil];     cell = [nib objectatindex:0]; } cell.addgoalstext.font = [uifont fontwithname:@"avenirnext-medium" size:17]; cell.addgoalstext.textcolor = [uicolor colorwithred:102.0f/255.0f green:102.0f/255.0f blue:102.0f/255.0f alpha:1.0f];     cell.addgoalstext.text = [[goalsarray objectatindex:indexpath.row] valueforkey:@"name"];     pfobject *currentuser = [[goalsarray objectatindex:indexpath.row] valueforkey:@"user"];     user *user = [[user alloc] initwithuserid:[currentuser valueforkey:@"userid"] username:[currentuser valueforkey:@"name"] anduserpassword:[currentuser valueforkey:@"password"]];      if(user==nil)     {      }     else if([[user userid]isequaltostring:[[nsstring stringwithformat:@"%@", [[[uidevice currentdevice] identifierforvendor] uuidstring] ] lowercasestring]])     {         [self.tableview beginupdates];         uitableviewcell *cell = [self.tableview cellforrowatindexpath:indexpath];         cell.accessorytype = uitableviewcellaccessorycheckmark;  <------here         [self.tableview reloadrowsatindexpaths:@[indexpath] withrowanimation:uitableviewrowanimationnone];         [self.tableview endupdates];     }   return cell; } 

please refer following code

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {     static nsstring *cellidentifier = @"cell";     uitableviewcell* cell = [tableview dequeuereusablecellwithidentifier:cellidentifier];      if(cell == nil )     {         cell =[[[uitableviewcell alloc] initwithstyle:uitableviewcellstylesubtitle reuseidentifier:cellidentifier] autorelease];     }     if ([indexpath compare:self.lastindexpath] == nsorderedsame)      {         cell.accessorytype = uitableviewcellaccessorycheckmark;     }      else      {         cell.accessorytype = uitableviewcellaccessorynone;     }     return cell; }  // uitableview delegate method -(void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath {     self.lastindexpath = indexpath;      [tableview reloaddata]; } 

and lastindexpath property(retain) nsindexpath* lastindexpath;


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -