1

I'm trying to translate the following Objective-C callback:

typedef void (^MKLocalSearchCompletionHandler)(MKLocalSearchResponse *response, NSError *error); 

enter image description here

...into its equivalent Swift callback:

typealias MKLocalSearchCompletionHandler = (MKLocalSearchResponse!, NSError!) -> Void 

enter image description here

...obvious I lost my way here.
What would be the correct 'shell' or 'structure' of the Swift callback?

1
  • In general it's better practice to copy and paste your code instead of a screen shot of your code, the former is far more legible. Commented Oct 21, 2014 at 22:39

1 Answer 1

2

The syntax is incorrect. It should be

let handler : MKLocalSearchCompletionHandler = { (r: MKLocalSearchResponse?, e: NSError?) in /*do something*/ } 

and better to omit the argument type and let compiler infer it

let handler : MKLocalSearchCompletionHandler = { r, e in /*do something*/ } 

BTW, when you post question next time, use text instead of image. So I can copy & paste & modify your code and it is also searchable by others.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.