The following implementation works correctly, however it does not feel like the most elegant solution. Are there any best practices or different implementations for determining if a UIButton is tapped on a custom UITableViewCell?
- (IBAction)customCellButtonTapped:(id)sender {
UIButton *button = (UIButton *)sender;
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:button.tag inSection:0];
NSManagedObjectContext *context = [self.fetchedResultsController managedObjectContext];
NSManagedObject *object = [self.fetchedResultsController objectAtIndexPath:indexPath];
// Set the value of the object and save the context
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
TTCustomCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
[self configureCell:cell atIndexPath:indexPath];
[cell.customCellButton addTarget:self action:@selector(customCellButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
[cell.customCellButton setTag:indexPath.row];
return cell;
}