Re: Tracking multiple NSURLConnections
Re: Tracking multiple NSURLConnections
- Subject: Re: Tracking multiple NSURLConnections
- From: Scott Anguish <email@hidden>
- Date: Tue, 29 Jun 2010 14:59:10 -0400
store the conn_1/conn_2 variables someplace. Then you compare them to the one returned by the delegate method.
On Jun 29, 2010, at 2:53 PM, email@hidden wrote:
> So then if I do this:
>
> NSURLConnection * conn_1 = [[NSURLConnection alloc] initWithRequest:request_1 delegate:delegate startImmediately:startImmediately];
> NSURLConnection * conn_2 = [[NSURLConnection alloc] initWithRequest:request_2 delegate:delegate startImmediately:startImmediately];
>
> Given that my controller is set as the connection's delegate, when data returns this will be called:
> connection:didReceiveData:
>
> connection is an NSURLConnection, but how do I determine which connection returned data? Is there something in the NSURLConnection object that tells me if it was conn_1 or conn_2? What I do with my data depends on knowing this.
> Sorry, if I'm not getting something here.
>
> On Jun 29, 2010 1:21pm, email@hidden wrote:
>> Maybe I'm misunderstanding you, but when your delegate methods (for the connection finishing or failing, receiving data, etc...) get called, you get a reference to the NSURLConnection object that the event refers to. I keep track of multiple connections this way with no problem.
>
>
>
>> Eric C.
>
>> Blog: http://www.onelazyprogrammer.com
>
>> Company: http://www.infusionsofgrandeur.com
>
>
>
>
>
>> On Tue, 29 Jun 2010 16:00:34 email@hidden wrote:
>
>
>
>> > I have and app that needs to send out multiple connection attempts.
>
>> > NSURLConnection doesn't appear to allow one to distinguish between
>
>> > connections. I found a couple of posts at cocoabuilder that provide some
>
>> > guidance, but I wanted to ask about my approach. I'm writing for 10.6, so
>
>> > I'm using a category on NSURLConnection combined with associative
>
>> > references. The methods in the category are below, but basically I
>
>> > associate an integer with a given connection and track the connections
>
>> > using that. So, short of subclassing or following what I've found in the
>
>> > archives, does this make sense? Am I missing any details that might cause
>
>> > this to fail?
>
>
>
> _______________________________________________
>
> 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
_______________________________________________
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