Create Button with Tag
[_buttonOne setTag:0]; [_buttonTwo setTag:1]; [_buttonThree setTag:2]; [_buttonFour setTag:3];
Then you can add a single IBAction selector, bind selector with buttons:
- (IBAction)buttonSelector:(UIButton *)sender;
Use the above switch-case to do conditional selection
switch ([sender tag]) { case 0: _outLabel.text = formattedDate; outTime = self.datePicker.date; break; case 1: _inLabel.text = formattedDate; inTime = self.datePicker.date; break; case 2: _offLabel.text = formattedDate; offTime = self.datePicker.date; break; case 3: _onLabel.text = formattedDate; onTime = self.datePicker.date; default: break; }
You can also add code for select/Deselect in the above switch-case.
Hope it helps.:)