title: UISwitch performing action on value change-iphone sdk
body: <p>I have a <code>UISwitch</code> 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.</p>
  
  <pre><code>-(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);
  }
  </code></pre>
  
  <p>And if once the state changed to ON, how can I remain the same state, if I reload the page?</p>
  
  <p>Please share your thoughts. 
  Thanks</p>