Kanny,
On Jul 7, 2008, at 1:37 PM, [EMAIL PROTECTED] wrote:
I am still trying to find a solution to quickly resolve the web server
502 error using NSURLRequest and NSURLConnection. Right now, even if i
set timeoutinterval to 5 seconds, it takes 30 seconds. But more
painful
thing is that during that time, it makes the app unresponsive with the
beach ball spinning. Let me know your strategies to handle 502 error.
I would like something like Safari, it does take time (60-90 sec) to
display the error message, but it doesn't halt the user's interaction
with other tabs or windows of safari.
It sounds from your description that you are doing a synchronous
request on your applications' main thread. Modifying your code to
not make the synchronous request will enable you to avoid locking out
the UI interaction from the user. This sounds like your biggest issue.
So instead of something lie this:
NSURLResponse *urlResponse = nil;
NSError *error = nil;
NSData* data = [NSURLConnection sendSynchronousRequest:myRequest
returningResponse:&urlResponse error:&error];
You would in modify the code to specify a delegate object (in this
example the current object), and create an asynchronous connection:
NSURLConnection* urlConnection = [[NSURLConnection alloc]
initWithRequest:urlRequest delegate:self startImmediately:YES];
Now the request will be scheduled on the main event loop, and you
won't tie up the UI. Your delegate object will be called when you
have data or other information about the connection you have attempted
to have open.
Scott
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]