I have a UISwitch and I need to load the value in a string into an array when change the switch state change to OFF to ON. I have used the following code, but not working.
-(IBAction)toggleSwitch1:(id)sender {
if (addSwitch.on) {
[addSwitch addTarget:self action:@selector(addName:) forControlEvents:UIControlEventValueChanged];
NSLog(@"%@",userName);
}else {
NSLog(@"No");
}
}
-(void)addName:(UIControl*)sender {
[alertList addObject:userName];
NSLog(@"AlertList: %@", alertList);
}
And if once the state changed to ON, how can I remain the same state, if I reload the page?
Please share your thoughts.
Thanks
In
viewDidLoaduse this one: