On 25 Jun '08, at 7:17 AM, Ling Wang wrote:
I can't find a way to identify different NSURLConnection instances in the delegate methods, for NSURLConnection does not offer access to the NSURLRequest used to initialize it.
If your delegate needs to know which connection is which, then it's a better design to use a separate delegate object per connection. That way each delegate can use instance variables to keep whatever state it wants that's associated with each connection (like the HTTP status, data downloaded so far, et cetera.)
I've implemented this kind of thing more times than I can count (really) and always used a single delegate per connection. Typically I make a class that expresses the higher-level task I'm trying to do — like "FeedFetcher" or "MusicTrackDownloader" or "BlogPoster" — and hide all the details including the NSURLConnection inside that class. The instance then becomes the delegate of the URL connection it starts.
(There was a lengthy discussion of this design on this list a few months ago.)
—Jens_______________________________________________ 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]