I have an asynchronus request in a class like this,
class Req{
func processRequest(){
NSURLConnection.sendAsynchronousRequest(request, queue: queue, completionHandler:{ (response: NSURLResponse!, data: NSData!, error: NSError!) -> Void in
//Do some operation here
})
}
}
And I am calling this method from one view controller like this,
class classOne{
func classOneFun(){
Req().processRequest()
self.demoFun()
}
func demoFun(){
//Do some operation here
}
}
And I am calling the same function from another view controller like this,
class classTwo{
func classTwoFun(){
Req().processRequest()
self.sampleFun()
}
func sampleFun(){
//Do some operation here
}
}
Now I want to call the demoFun()
or sampleFun()
only after the processRequest()
is completed. If demoFun() or sampleFun()
and processRequest()
are in the same class, then I can call the functions in the completion handler of processRequest(). But, in my case I cannot do that, since I have nearly 20 view controllers that call the processRequest() function. I cannot use SynchronusRequest as it is deprecated in Swift 2.0. So how can I call the other functions once the asynchronus request is completed?