[英]queue downloading of a lot of images in iOS 4?
现在在iOS 4中是否有一些新的框架可用于执行此类操作? 我希望可以使用http://allseeing-i.com/,但这将需要对我的代码进行较大的更改,而宁愿使用对我可用的内容。
编辑解决方案:
这是我最终得到的解决方案,它可以像魅力一样处理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]);
一次只排队100个,随着它们的减少,我增加了更多,看起来我的内存消耗开始逐渐增加,所以我正在努力,但在队列完成后却减少了。
可能需要重新设计您的网络接口代码,但从长远来看,切换到ASI会有所作为。
(这是ASIHttpRequest,位于http://allseeing-i.com/Tags/ASIHTTPRequest )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.