1

I am still studying for passing function as parameter.

Currently, I can do like this.

- (void)getLocation:(void (^)(CLLocation *location))didUpdateLocation andTimeOut:(void (^)(void))timeout andDidFailUpdate:(void (^)(void))didFailUpdate

What I want to know is that "didUpdateLocation" can have multiple parameter? (Instead of just CLLocation *location) ? Currently, I can't find about syntax for that.

1
  • just use like this (void (^)(CLLocation *location, NSString *param2, NSString *param3)) Commented Jan 19, 2016 at 7:28

1 Answer 1

2

Since this is a block you have defined yourself, it can have as many parameters as you want. Just add the parameter you want to the parameter list of the block like this:

- (void)getLocation:(void (^)(CLLocation *location, NSString *otherParameter))didUpdateLocation andTimeOut:(void (^)(void))timeout andDidFailUpdate:(void (^)(void))didFailUpdate
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.