我将委托对象作为函数args传递,如下所示:
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!()
}
}
}
}
我不确定这是否会保留对该委托的强引用,并且会阻止在执行该块之前释放该对象!
这样安全吗?