Access switch and textfield in tableview from another method
-
27-09-2019 - |
Question
I'm having a tableview with a couple of cells with 4 uiswitches and one textfield inside. Simple question. I need a way to read all the positions of the switches and the string inside the textview by clicking a button. Tableview, textfield, switches and button is working fine. Just need to access the values of the switches and textfield from another method. By tagging the switches or something.
So how can I access the values from another method. Something like in tableview method:
...
UISwitch *switchView = [[option1 alloc] initWithFrame:CGRectZero];
switchView.tag = 3000;
cell.accessoryView = switchView;
...
And something like this in the button method:
...
BOOL status = [self.view viewWithTag:3000].on; //*Not a working method*
Solution
You are in the same class, nop ?
So maybe you could put your switch & co as class variable (declared in the header file). It would be easier ^^
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow