Question: I have Button in tableview I want when I press that button will select all cell rows, how to do that? I tried alot but I got nothing

I'm so confused how to make the button contact the cell

I've tried to make var like this

```
var x = false

```

then I do like

```
if( x == true ) { //Code }

```

and when you press the button it will be true

but I don't know in which func I should put this ? and I don't know how to select all rows

Could someone help me how to Select \ Deselect all rows in cell when pressing button in tableview.

Thank you so much!

Answer: 
```
var isSelectAll = false; //global variable

isSelectAll = true;//on button action
self.tableView.reloadData()//on button action

```

in `cellForRowAtIndexPath` method

```
if(isSelectAll==true)
{
cell.backgroundColor = UIColor.blueColor();
}
else
{
cell.backgroundColor = UIColor.white();
}

```
In cellForRowAtIndexPath:

```
UITableViewCell *cell...

cell.accesoryType = isSelectAll ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;

```