1

I'm trying this

[timePicker addTarget:self action:@selector(timeValueChanged:self.pickupTimeTextField datePicker:self.timePicker) forControlEvents:UIControlEventValueChanged];

But it gives me a syntax error. How can I pass through UITextField and UIDatePicker to the method in the selector.

user1898829
  • 3,287
  • 6
  • 31
  • 58
  • possible duplicate of [Passing parameters to addTarget:action:forControlEvents](http://stackoverflow.com/questions/3988485/passing-parameters-to-addtargetactionforcontrolevents) – Martin R Sep 04 '13 at 11:26

2 Answers2

0

It's the method signature in the action parameter. You are attempting to pass parameters to the method, which doesn't make sense.

Try:

[timePicker addTarget:self
               action:@selector(timeValueChanged:datePicker:)
     forControlEvents:UIControlEventValueChanged];
trojanfoe
  • 118,129
  • 19
  • 204
  • 237
0

You can define a method with no parameter and you can use this method for target selector. Also in this method, you can call "timeValueChanged:datePicker:" method.

You may see this for detail: Passing parameters to addTarget:action:forControlEvents

Community
  • 1
  • 1
lykant
  • 519
  • 4
  • 17