I am doing this with UISwitchs and UITextFields...
I have declared the UISwitch as Property in the header file, because I want to access its value in several different methods within my class.
I am adding the UISwitch to one of my TableViewCells, using the following code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
mySwitch = [[[UISwitch alloc] initWithFrame:CGRectZero] autorelease];
cell.accessoryView = mySwitch;
mySwitch.on = YES;
return cell;
}
As it is, the retainCounts are all over the place. The mySwitch Retain is 2 by the time the cell has been put on the screen, and every time I tap the switch, the retain count goes up, until it gets to 4, then it seems to stay there.
Obviously I am missing something. If someone can point me in the right direction, it would be greatly appreciated.