简体   繁体   English

排队下载iOS 4中的大量图像?

[英]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? 现在在iOS 4中是否有一些新的框架可用于执行此类操作? 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. 我希望可以使用http://allseeing-i.com/,但这将需要对我的代码进行较大的更改,而宁愿使用对我可用的内容。

EDIT SOLUTION: 编辑解决方案:
Here is the solution I ended up with and it is working like a charm for 3000+ images: 这是我最终得到的解决方案,它可以像魅力一样处理3000多个图像:

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. 一次只排队100个,随着它们的减少,我增加了更多,看起来我的内存消耗开始逐渐增加,所以我正在努力,但在队列完成后却减少了。

It may take some reworking of your network interface code, but switching to ASI will SO pay off in the long run. 可能需要重新设计您的网络接口代码,但从长远来看,切换到ASI会有所作为。

(That's ASIHttpRequest, at http://allseeing-i.com/Tags/ASIHTTPRequest ) (这是ASIHttpRequest,位于http://allseeing-i.com/Tags/ASIHTTPRequest

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM