Many of the ways and methods out there to select multiple rows is either deprecated or doesn't work.
I simply want to select multiple rows in didSelectRowAtIndexPath
and save them into Array or NSUserDefault
. This case I picked NSUserDefault
but I am willing to change it to Array.
This is my code:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
NotificationsTableViewCell *cell = (NotificationsTableViewCell*)[tableView cellForRowAtIndexPath:indexPath];
//set clicked icon after row selected
cell.imgIcon.image=[UIImage imageNamed:@"select-icon"];
//notification id for selected row
Notifications* selected = notifications[indexPath.section];
selectedGroup = selected.NotificationsId;
//save it in nsuserdefaults
[[NSUserDefaults standardUserDefaults] setObject:selectedGroup forKey:@"notificationSelectedID"];
}
-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath{
//deselect the row
}
Note: I am using latest Xcode SDK 8.
Thank you for your helps.
You can declare mutable array and when every time user selects particular row, add required detail for particular row in an array then use NSUserDefaults to store updated array.
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
}