簡體   English   中英

排隊下載iOS 4中的大量圖像?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM