On Fri, Jun 5, 2009 at 3:16 AM, Shawn Erickson <shaw...@gmail.com> wrote:
> On Thu, Jun 4, 2009 at 4:44 PM, Ammar Ibrahim <ammar.ibra...@gmail.com> > wrote: > > > Excuse me for the silly question. But I'm going to be doing hundreds of > > requests, and I have GC ON, how do I create these connections and retain > > them? > > Not sure I understand the question but as a guess... > > Put them in an NSMutableArray or NSMutableSet if you need to keep > track of them? Also don't forget that the delegate methods get passed > a pointer to the connection sending the delegate message. > This is exactly what I did as shown in the code snippets below. "connections" is a class instance of an NSMutableArray. Does this seems correct? What's so weird is that I get a log on my HTTP server that the same URL is being called twice! NSMutableURLRequest *newReqGet = [[NSMutableURLRequest alloc] init]; [newReqGet setHTTPMethod:@"GET"]; [newReqGet setURL:[NSURL URLWithString:[@"/media" stringByAppendingPathComponent:[currentTrack objectForKey:@"Persistent ID"]] relativeToURL:[self serverBaseUrl]]]; NSURLConnection *getConnection = [[NSURLConnection alloc] initWithRequest:newReqGet delegate:self startImmediately:YES]; if (getConnection == nil) { //connection couldn't be created! NSLog(@"Connection couldn't be created: %@", [newReqGet URL]); [self startSyncAfterTimeInterval]; } else { [connections addObject:getConnection]; } _______________________________________________ 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 arch...@mail-archive.com