tags:

views:

28

answers:

1

Hi,

I have a few custom UITableViewCells -

http://img11.imageshack.us/i/customfacilitiescell.png/

which are added to this UIViewController -

http://img189.imageshack.us/i/facilitycontroller.png/

Now, on clicking a button in the controller, I'd like to get the on/off status of all the UISwitches in the controller.

Thanks,
Teja

+1  A: 

Simple answer: you should never store model data in your views. This is a universally good idea, but an absolute must when dealing with UITableViews. Otherwise, as soon as a cell is scrolled off screen, your data is lost.

Store the on/off status of your switches in a model object (such as mutable array) and use this data to update your UI (and vice versa update the model when the user makes a change in the UI).

Ole Begemann
Thanks, I was trying to do that, but couldn't. Then I came across this method, which solved all my problems.`[(UISwitch *)[cell facSwitch] addTarget:self action:@selector(facSwitchOptionChanged:) forControlEvents:UIControlEventValueChanged];`
Tejaswi Yerukalapudi