title: uitableview checkbox reset issue
body: <p>I have my uitableview with 20 rows which is showing a number of food items.</p>
  
  <p>Each food item is having a check box along with it.</p>
  
  <p>My problem is: If I check the first row of the check box and then scroll the tableview, the checkmark is reset.</p>
  
  <p>How can I solve this problem? Please help me out.</p>
  
  <p>Code update:</p>
  
  <pre><code>- (IBAction)buttonAction:(id)sender
  {
    if ([sender isKindOfClass:[UIButton class]])
    {
      UIButton *checkboxButton = (UIButton*)sender;
  
      checkboxButton.selected = !checkboxButton.selected;
  
      NSIndexPath *indexPath = [self.myTableView indexPathForCell:(UITableViewCell*)[[checkboxButton superview] superview]];
  
      BOOL selected = [[selectedArray objectAtIndex:[indexPath row]] boolValue];
  
      [selectedArray replaceObjectAtIndex:[indexPath row] withObject:[NSNumber numberWithBool:!selected]];
  
        if (!self.checkedIndexPaths)
            checkedIndexPaths = [[NSMutableSet alloc] init];
  
      if(selected == NO)
      {
            NSLog(@"cvbcvbNO BOOL value");    // ...
  
          //  If we are checking this cell, we do
          [self.checkedIndexPaths addObject:indexPath];
      }
      else
      {
        NSLog(@"cvbvbYES BOOL VALURE");
  
          //  If we are checking this cell, we do
          [self.checkedIndexPaths removeObject:indexPath];
      }
  
  
  
    }
  }
  
  // Customize the appearance of table view cells.
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
  
    static NSString *CellIdentifier = @"Celhgl";
  
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  
    profileName = [appDelegate.sentItemsList objectAtIndex:indexPath.row];
  
    if (cell == nil)
    {
          cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
  
          cb = [[UIButton alloc] initWithFrame:CGRectMake(5,10, unselectedImage.size.width, unselectedImage.size.height)];
          [cb setImage:unselectedImage forState:UIControlStateNormal];
          [cb setImage:selectedImage forState:UIControlStateSelected];
          [cb addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchDown];
          [cell.contentView addSubview:cb];
  
          for (NSIndexPath *path in self.checkedIndexPaths)
          {
              NSLog(@"%d",path.row);
  
              NSLog(@"%d",indexPath.row);
  
             if (path.row == indexPath.row)
            {
              NSLog(@"dfd %d",indexPath.row);
            }
          }
  
     }
  
      if ( tableView == myTableView )
      {
          titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(60, 0, 150, 35)];
          titleLabel.font = [UIFont boldSystemFontOfSize:13];
          titleLabel.textColor = [UIColor blackColor];   
          [cell.contentView addSubview:titleLabel];
          NSString *subjectData = [profileName.sent_subject stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
          [titleLabel setText:[NSString stringWithFormat: @"%@ ", subjectData]];
      }
  
      return cell;
  }
  </code></pre>