0

I'm adding a target to a UISwitch, I'd like to pass both the sender (UISwitch) and an object (NSIndexPath).

I'm not sure on the syntax for this, would be great if anyone could point me in the right direction

[certificateSwitch addTarget:self action:@selector(certificateSwitcher:withIndexPath:) forControlEvents:UIControlEventValueChanged];

method:

- (void)certificateSwitcher:(UISwitch *)sender withIndexPath:(NSIndexPath *)indexpath

also before anyone says put the row number as the UISwitch's tag property, It's not an option, I have some other stuff that relies on the tag of the UISwitch

Thanks

DipakSonara
  • 2,598
  • 3
  • 29
  • 34
Halpo
  • 2,982
  • 3
  • 25
  • 54
  • You can use the solution provided in this answer regarding UIButton and passing mulitple parameters to its selector: https://stackoverflow.com/a/53779104/5324541 – Lloyd Keijzer Dec 14 '18 at 11:59

1 Answers1

2

No, you cannot pass your_Own value .

you should use the tag property Or you can subclassing the UISwitch.

Community
  • 1
  • 1
Kumar KL
  • 15,315
  • 9
  • 38
  • 60