I have the following code inside my UIViewController -
[flipButton addTarget:self.navigationController.delegate action:@selector(changeModeAction:) forControlEvents:UIControlEventTouchUpInside];
As you can see, it calls a method inside it's navigation controller delegate. How do I correctly pass along an object to this method?
You can use the layer property. Add the object you want to pass as the value in the layer dictionary.
[[btn layer] setValue:yourObj forKey:@"yourKey"];
This yourObj
is accessible from the button action function:
-(void)btnClicked:(id)sender
{
yourObj = [[sender layer] valueForKey:@"yourKey"];
}
With this method you can pass multiple values to the button function just by adding new objects in the dictionary with different keys.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With