Search code examples
objective-ccocoa-touchuibuttonibaction

Getting a return value from a button's action method


I have a button, and I've set an action in code:

[buttonOk addTarget:self action:@selector(check:) forControlEvents:UIControlEventTouchUpInside];

The check: method returns an int. How can I receive this int?


Solution

  • Create a different method that calls check:. Have this method process the return value.

    - (void)mymethod:(id)sender {
      int value = [self check:sender];
      // use your value or send it somewhere
    }