I only know the first step is to check a row.
Next I think is use a NSMutableArray to record which row is been checked,
and this is my code :
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if ([[tableView cellForRowAtIndexPath:indexPath] accessoryType] == UITableViewCellAccessoryCheckmark){
[[tableView cellForRowAtIndexPath:indexPath] setAccessoryType:UITableViewCellAccessoryNone];
}
else {
[[tableView cellForRowAtIndexPath:indexPath] setAccessoryType:UITableViewCellAccessoryCheckmark];
}
}
So, my question is:
-
How to put this checked row’s indexPath into a Array?
-
How to add a delete button that I can delete all the row I selected?
First off declare a NSMutableArray in youre viewController’s .h file.
Like so:
Change youre didSelectRow method like this:
And in youre cellForRow method add this: