ios - Set integer 'variable' using result of NSString -
this question has answer here:
i'm using single action handle 10 uiswitches sending tag value it. have number of integers initialised when launched thus;
int switch_1 = 0; int switch_2 = 0; etc
when particular switch switched on, want set integer corresponding integer 'variable' 1
so, if switch 2 tag 2 turned on, puts '1' in corresponding int 'switch_2' integer.
i getting string right name via 'stringwithformat' appending tag value don't know how write 1 corresponding integer variable it.
any appreciated. essentially, want write integer 'variable' name same name generated string value.
thanks
you can use array each index represents switch, following:
int swticharray[10] = {0}; // if have 10 switches
while in action handling action of multiple buttons, that:
switcharray[tagofswitch] = 1; // if tags staring 0 onwards 9
Comments
Post a Comment