closures - Converting an Objective-C block to Swift 2.0 -


objective-c block:

[networhandler composerequestwithmethod:methodrespondtoappointment                                         paramas:queryparams        //nsdictionary                                    oncomplition:^(bool success, nsdictionary *response){     //                                   nslog(@"dict: %@", response);     }]; 

now want represent in swift. how should it?

update:

let handler = networkhandler.sharedinstance() as! networkhandler         let dict = ["":""]          handler.composerequestwithmethod("", paramas: dict) { (success, response) -> void in          } 

this worked me.

in swift, if trailing argument closure can use shortened version of anbu.karthik's answer:

networhandler.composerequestwithmethod(methodrespondtoappointment, paramas: queryparams) { success, response in //      nslog(@"dict: %@", response) } 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -