It took me also a while to understand how to use the prototype cells. If you want to access the user interface elements inside a prototype cell, you have to create a subclass of UITableViewCell and assign it to the prototype cell in Interface Builder.
Then you have to define the IBOutlet properties manually e.g.:
@interface OptionSwitchCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UISwitch* switchControl;
@end
After that, you can connect the interface elements through control-dragging from the element to the property definition in the assistant view.
The IBActions instead can be defined inside the owning View Controller. You can control-drag from a interface element to the View Controller header file and create an action. Inside the action implementation you will likely want to know which cell was been triggering the action. I do it like this:
@implementation SomeTableViewController
- (IBAction)toggleActivity:(id)sender {
OptionSwitchCell* cell = (OptionSwitchCell *)[sender superview].superview;
NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
...
}
@end
Another solution for finding the corresponding cell and index path (by jrturton):
- (IBAction)toggleActivity:(id)sender {
CGPoint hitPoint = [sender convertPoint:CGPointZero toView:self.tableView];
NSIndexPath *hitIndex = [self.tableView indexPathForRowAtPoint:hitPoint];
OptionSwitchCell* cell = (OptionSwitchCell *)[self.tableView cellForRowAtIndexPath:hitIndex];
...
}
Although this is a bit quirky, I haven't found a better solution so far. Hope that helps.