I have a tableView with multiple of switches(one switch for each row).
what is the best way to save the state for the switches?
and in what methods should I save and retrieve the data?
I have a tableView with multiple of switches(one switch for each row). what is
Share
Save the data in an array, you haven’t given any context but you may be using an array of some sort already to drive the number of rows in the table and the rest of the content?
You set the value of the switch in the
cellForRowAtIndexPath:method. I’ve assumed the following:NSNumberobjectsSo, when you’ve got your cell and are about to return it:
Your setter method is a little more complicated because all of your switches will be calling the same action method. Therefore you need to find out which row the switch was in. This would be in the method you’ve connected to Value Changed of the switch