I am passing the delegate object as function args , as you can see below:
private func sendHttpRequest(request:NSURLRequest,netWorkDelegate:NetWorkDelegate){
let queue = NSOperationQueue();
NSURLConnection.sendAsynchronousRequest(
request,
queue: queue,
completionHandler: {
response, data, error in
dispatch_async(dispatch_get_main_queue(), {
if(error != nil){
//then delegate connection error
if netWorkDelegate.handleError != nil {
netWorkDelegate.handleError!()
}
}
}
}
I am not sure if this will retain a strong reference to the delegate, and will prevent from releasing the object until executing the block !
Is this safe to use?