This question is largely based on this one:
Link
The main difference being that I want to pass in arguments to the closure as well. Say I have something like this:
func someFunctionThatTakesAClosure(completionClosure: (venues: Dictionary<String, AnyObject>, error: NSError) -> ()) {
// function body goes here
var error: NSError?
let responseDictionary: Dictionary<String, AnyObject> = ["test" : "test2"]
completionClosure(venues: responseDictionary, error: error!)
}
No error here. But when I call this function in my main view controller I have tried several ways but all of the result in different errors:
venueService.someFunctionThatTakesAClosure(completionClosure(venues: Dictionary<String, AnyObject>, error: NSError){
})
or like this:
venueService.someFunctionThatTakesAClosure((venues: Dictionary<String, AnyObject>, error: NSError){
})
or even like this:
venueService.someFunctionThatTakesAClosure(completionClosure: (venues: Dictionary<String, AnyObject>, error: NSError) -> (){
});
I'm probably just way tired, but any help would be greatly appreciated!