I followed below code to establish https connection in my application to fetch some data in xml format in my iphone (iOS4) application.
- Creating a connection using NSURLConnection
- connection:didReceiveResponse: implementation
- connection:didReceiveData
- connectionDidFailWithError
- connectionDidFinishLoading
I referred exacly following to establish connection:
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html
Everything works fine for a single connection. But if I try 2 (or more) connections simultaneously (each connection being in separate thread), and if first connection is being served, then second connection gets discarded.
The second connection never gets queued up. It is simply discarded. Only first is served.
What can be the issue? My requirement is to create multiple (at least 2) connection simultaneously.
Also, Please share sample code or link or example if possible.
Thanks
It’s not a simple task to run NSURLConnection in separate thread. If you just execute NSURLConnection in separate thread, you can not handle delegate methods because your thread is finished before your code actually executed.
See this article – NSURLConnection in its own thread