Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSURLConnection delegate methods are not called

Try running the operation on main thread:

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

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

Are you calling this on a background thread? If you are performing this on a background thread, the thread is probably exiting before the delegates can be called.


Try to check length for the received response it should not getting 0 byte of data.


Apart from checking if the request is called from the main thread, you can check if you give back execution time to the system (if you exit "main"). I had some test code that would stay in a loop until the delegate was called : it would never be called, because the system needs to do stuff in order for the delegate to be called, in the main thread.