I am in the process of converting my app from Objective C to Swift. I doing well in all areas with this exception. In my objective c file I have a UITableView that allows multiple selections. When the user selects a cell, information from that object is stored in an array. and when the user clicks the cell again, that object is removed. I am trying to figure out how this works in Swift 3 and I can add the object, but I just cannot seem to figure out how to remove that object from the array. Please advise. Below is my code from Objective C that I am trying to convert over.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
RibbonsInfo *ribbonsInfo = [ribbonsArray objectAtIndex:indexPath.row];
UITableViewCell *cell = [ribbonTableView cellForRowAtIndexPath:indexPath];
if (ribbonTableView.allowsMultipleSelection == YES) {
if(cell.accessoryType == UITableViewCellAccessoryNone) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
[selectedRibbons addObject:ribbonsInfo];
}
else {
cell.accessoryType = UITableViewCellAccessoryNone;
[selectedRibbons removeObject:ribbonsInfo];
}
}
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}