I have a table that imports the address book contacts and displays the image, contact name and a checkbox, i've customized my cell with image, label and a button which serves as a checkmark. I'm successfully able to display all contacts and the checkmark also works fine for individual cells, but i'm having trouble implementing select all functionality that will put all the button in the table in selected state and clicking it again will deselect it all. This is what I have done so far.

//This is the class for my custom cell

```
#import "InviteFriendsCell.h"

@implementation InviteFriendsCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

       }

   //This is my checkmark button
-(IBAction)onAddTouched:(id)sender
{
    UIButton *addButton = (UIButton *)sender;
    [addButton setSelected:![addButton isSelected]];
}
@end

```

//This is my tableview display code in FriendListViewController

```
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"friendsCell";

    InviteFriendsCell *cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

       if(cell==nil)
       {
        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"InviteFriendsCell" owner:self options:nil];
        cell = [nib objectAtIndex:0];

       }
    // Configure the cell...

    NSUInteger row = 0; 
    NSUInteger sect = indexPath.section;
    for (NSUInteger i = 0; i < sect; ++ i)
        row += [self tableView:tableView numberOfRowsInSection:i];
    row += indexPath.row;

    cell.thumbImage.layer.cornerRadius=25;
    cell.thumbImage.clipsToBounds=YES;
    cell.thumbImage.image=nil;

        self.persons = CFArrayGetValueAtIndex(self.contactAdd, row);

        NSString *tweet=[[NSString stringWithFormat:@"%@",(__bridge_transfer NSString *)ABRecordCopyCompositeName(self.persons)] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
        [cell.friendName setText:tweet];

        if (ABPersonHasImageData(persons))
        {
            NSData  *imgData = (__bridge NSData *) ABPersonCopyImageDataWithFormat(persons, kABPersonImageFormatThumbnail);
            cell.thumbImage.image = [UIImage imageWithData:imgData];
        }
        else
        {
            cell.thumbImage.image = [UIImage imageNamed:@"name_icon.png"];
        }

    return cell;
}

```

//This is my select all button which should put checkmark to all button in tableview

```
  - (IBAction)selectAll:(UIButton *)sender {

       //This is where I need to implement the code
    }

```

There is a similar question in stack overflow here [Need to create a select all button for UITableView and add selections to an array in iOS](https://stackoverflow.com/questions/14209145/need-to-create-a-select-all-button-for-uitableview-and-add-selections-to-an-arra)

But here the checkmark button is created inside the tableview method, my case is different and I'm unable to implement that code. Is there a better way to do this? I'm using storyboard and xcode 5 and should work for ios 5 or above.