There are several ways you can find the address of the table view object from inside a cell method (e.g. see [http://discussions.apple.com/thread.jspa?messageID=9504961�]). But to test Andreas' suggestion, I would just add an ivar/property to your cell subclass. For example if the table view data source is a controller subclass named MyTableController:
@interface MyCellType : UITableViewCell {
// ,,,
UITableView *tableView;
}
@property (nonatomic, assign) UITableView *tableView;
@implementation MyTableController
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
// ,,,
if (cell == nil) {
// ...
cell.tableView = tableView
I have some other questions and suggestions for you as well (though I would definitely try Andreas' idea first)::
1) Just to check if I understand your original post, when the code in changedModeAction isn't commented out, are you getting taps in the delegate up until the time you first run changedModeAction?
2) Which accessory type is the default? I.e. before you first run changedModeAction: which type is there? If the default isn't UITableViewCellAccessoryDetailDisclosureButton, try making that the default (i.e. set that type in cellForRowAtIndexPath);
3) In the method you posted (repeated below), who is sender and who is self?
- (void) changedModeAction:(id)sender {
// User changed the alarm mode.
switch (modeSegmentedControl.selectedSegmentIndex)
{
case 0:
self.accessoryType=UITableViewCellAccessoryDetailDisclosureButton;
break;
default:
self.accessoryType=UITableViewCellAccessoryDetailNone;
break;
}
}
4) Are you tracking the type change in cellForRowAtIndexPath? Put a NSLog() in cellForRow.. and see if it runs after the switch.