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,437
  • 6
  • 34
  • 62
  • 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
  • 120,358
  • 21
  • 212
  • 242
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
  • 516
  • 4
  • 17