I have a list of items/cells in TableView. Table is set to allow multiple selection.
So, i have these methods to select and deselect.
@interface NotificationsViewController : UIViewController <UITableViewDataSource, UITableViewDelegate,UIScrollViewDelegate>
{
NSMutableArray *checkedIndexPaths;
}
-(void)viewDidLoad{
//Setup default array
checkedIndexPaths = [[NSMutableArray alloc]init];
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
NotificationsTableViewCell *cell = (NotificationsTableViewCell*)[tableView cellForRowAtIndexPath:indexPath];
cell.imgIcon.image=[UIImage imageNamed:@"select-icon"];
Notifications* selected = notifications[indexPath.section];
selectedGroup = selected.NotificationsId;
[checkedIndexPaths addObject:selectedGroup];
}
-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath{
NotificationsTableViewCell *cell = (NotificationsTableViewCell*)[tableView cellForRowAtIndexPath:indexPath];
cell.imgIcon.image=[UIImage imageNamed:@""];
Notifications* selected = notifications[indexPath.section];
selectedGroup = selected.NotificationsId;
[checkedIndexPaths addObject:selectedGroup];
}
I want to add each object into array during multiple selection. But with this current coding, it will overwrite the same one, and i have no idea how can i make it multiple object array to store in each click of cell. Thank you for your helps.