Tuesday 8 April 2014

NSURLConnection connection getting lost? Delegate methods not called.


If you are creating a asynchronous connection and delegates are not called. The possible reason could be that you are creating the connection request on the    background thread, thats why the callback is lost, you should keep the track of the callback using NSRunLoop.


NSURLConnection * connection = [[NSURLConnection alloc] 
                                initWithRequest:request
                                       delegate:self startImmediately:NO];

[connection scheduleInRunLoop:[NSRunLoop mainRunLoop] 
                      forMode:NSDefaultRunLoopMode];

[connection start];

No comments:

Post a Comment