Re: NSURLDownload and userInfo
Re: NSURLDownload and userInfo
- Subject: Re: NSURLDownload and userInfo
- From: Adam Leonard <email@hidden>
- Date: Tue, 11 Mar 2008 20:25:33 -0700
Hi,
Oh, sorry, replace everything in that message with NSURLDownload, same
idea.
I agree with your original approach, especially if you just need to
store an int (or an NSNumber in this case).
There is a reason almost every delegate method in Cocoa passes the
delegate object as a parameter, and I am surprised NSURLDownload and
NSURLRequest do not have userInfo ivars like many other Cocoa classes
that do asynchronous operations (NSTimer for instance). In my opinion,
subclassing is the simplest, most MVC compliant, and most Cocoa like
solution.
While I agree that for more complicated situations, multiple classes
might be the best solution, I do not think it should be done in this
case. You don't have to search through an array to match a connection
with data that is irrevocably tied to that connection. Also, one of
the purposes of subclassing is to prevent having to create wrapper
classes. The data is tied to the NSURLDownload object itself, and
there is no need to do any extra work to get it in one of the delegate
methods.
Adam Leonard
On Mar 11, 2008, at 6:37 AM, Trygve Inda wrote:
Or, yet another solution:
Just subclass NSURLConnection (say MyUserInfoURLConnection), add a
userInfo ivar, drop in some accessors, and you are good to go. :)
[userInfoConnection userInfo];
My code is:
NSURLRequest* urlRequest = [NSURLRequest requestWithURL:theURL
cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60.0];
NSURLDownload* urlDownload = [[NSURLDownload alloc]
initWithRequest:urlRequest delegate:self];
[urlDownload setDestination:path allowOverwrite:YES];
Where then can I specify that it use a custom NSURLConnection class?
This is
why my initial approach was to use a custom NSURLDownload class.
Trygve
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden