3

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?

AMAN77
  • 6,218
  • 9
  • 45
  • 60
david
  • 3,310
  • 7
  • 36
  • 59

0 Answers0