I have created a class HTTPServiceProvider inherited from AFURLSessionManager. Added below code to get the data.
let configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
let manager = AFURLSessionManager(sessionConfiguration: configuration)
let dataTask = manager.dataTaskWithRequest(request) { (response, responseObject, error) in
//Perform some task
}
dataTask.resume()
I want to add dataTask to operationQueue provided by AFURLSesstionManger and cancel all the operation in some other class (BaseController.swift) before calling the same request again.
Tried this code but not working -
self.operationQueue.addOperationWithBlock{
//Added above code
}
And inside BaseController.swift file , called -
HTTPServiceProvide.sharedInstance.operationQueue.cancelAllOperations
But its not working :(
Thanks.
manager.operationQueue.cancelAllOperations()
– Fortitude