queue downloading of a lot of images in iOS 4?
is there some new framework additions for doing something like this in iOS 4 now? I kow I could use http://allseeing-i.com/ but that would require a big change of my code and would rather use what is available to me.
EDIT SOLUTION:
Here is the solution I ended up with and it is working like a charm for 3000+ images:int j = 0;
do{
NSLog(@"x = %i, items count: %i", j, [items count]);
if ((int)[[self networkQueue] requestsCount] < 100) {
NSString *url =[NSString stringWithFormat:@"http://images.myurl.com/skus/%@/%@_tn.jpg",[[[manufacturers objectAtIndex:i] ManufacturerID] stringValue], [[items objectAtIndex:j] valueForKey:@"PhotoName"]];
NSString *url2 =[NSString stringWithFormat:@"http://images.myurl.com/skus/%@/%@_lg.jpg",[[[manufacturers objectAtIndex:i] ManufacturerID] stringValue], [[items objectAtIndex:j] valueForKey:@"PhotoName"]];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]];
[[self networkQueue] addOperation:request];
ASIHTTPRequest *request2 = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url2]];
[[self networkQueue] addOperation:request2];
if (j==0) {
[[self networkQueue] go];
}
j++;
开发者_如何学编程 }
}
while(j < [items count]);
Just queueing up 100 at a time and as they fall off I add more, looks like my memory consumption starts to creep up a bit as it goes so I am working on that, it goes down after the queue is complete though.
It may take some reworking of your network interface code, but switching to ASI will SO pay off in the long run.
(That's ASIHttpRequest, at http://allseeing-i.com/Tags/ASIHTTPRequest )
精彩评论