I'm having trouble converting / understanding how Obj-C completion handlers work, and how I can convert them to Swift 2.0... Specifically, here is the code:
[BLAH aRandomTaskWithURL:NSURL completion:^(NSURL *compVar) {
//do something with compVar
}];
here is my attempt:
BLAH.aRandomTaskWithURL(myURL,completion: (compVar:NSURL) ) {
print(compVar)
}
the above produces the error "delete compVar:" ... so i delete it, and then it says "cannot invoke type (NSURL) with argument list of type ' ( () -> () )'
I've tryed several times to define the Swift 2.0 equiv of compVar, but to no luck... I've also read ( and followed along with ) the relevant documentation on Swift completion variables, again to no luck. What am I missing?
But, when I add "Void in"
BLAH.aRandomTaskWithURL(myURL, completion: ) { Void in
//do something
}
there is no error, but I don't have access to what should be the completion variable.
here is the actual obj-c code ( i was just trying to keep it general before ):
(void)optimalGIFfromURL:(NSURL*)videoURL loopCount:(int)loopCount completion:(void(^)(NSURL *GifURL))completionBlock {