Re: NSURLConnection: synchronous or asynchronous connections?
Re: NSURLConnection: synchronous or asynchronous connections?
- Subject: Re: NSURLConnection: synchronous or asynchronous connections?
- From: Nicko van Someren <email@hidden>
- Date: Thu, 27 Jan 2005 11:46:36 +0000
On 27 Jan 2005, at 11:37, Toby Atkin-Wright wrote:
I'm writing an iPhoto plugin that uploads images to a web site, making
a series of HTTP requests one after another. As I see it, I could
either:
1/ Issue asynchronous requests, and keep track through delegate
methods to update the progress bar, report errors, and trigger
subsequent requests.
-or-
2/ Start a worker thread that issues synchronous requests one after
another, while the main thread waits to hear from the worker and
updates the progress bar etc. accordingly.
I can't decide which approach would be best - I can see pros and cons
of each, but I don't know if one is 'obviously' the best way to work
in Cocoa. (My code is currently working with asynchronous requests,
but as I add more features, I keep thinking it may be easier with a
separate thread.)
Use the asynchronous version. The complexity of managing the extra
thread is at least as large as setting up a delegate and is painful if
you want to cancel the request. Furthermore if you use the synchronous
call on NSURLConnection you can't get progress information; you'll only
know when the request completes or fails.
Cheers,
Nicko
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden