iOS7 UISwitch its Event ValueChanged: Calling continuously is this Bug or what..?

Please see the following code: -(void)viewDidLoad { [super viewDidLoad]; UISwitch *mySwitch = [[UISwitch alloc] initWithFrame:CGRectMake(130, 235, 0, 0)]; [mySwitch addTarget:self action:@selector(changeSwitch:) forControlEvents:UIControlEventValueChanged]; [self.view addSubview:mySwitch]; } – (void)changeSwitch:(id)sender{ if([sender isOn]){ NSLog(@”Switch is ON”); } else{ NSLog(@”Switch is OFF”); } }

Change color of UISwitch in “off” state

My solution with #swift2: let onColor = _your_on_state_color let offColor = _your_off_state_color let mSwitch = UISwitch(frame: CGRect.zero) mSwitch.on = true /*For on state*/ mSwitch.onTintColor = onColor /*For off state*/ mSwitch.tintColor = offColor mSwitch.layer.cornerRadius = mSwitch.frame.height / 2.0 mSwitch.backgroundColor = offColor mSwitch.clipsToBounds = true Result:

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)