我想排隊有10個請求,我想按順序加載它。 我該怎麼辦?你有什麼想法嗎?ASINetworkQueue與訂單
1
A
回答
2
ASINetworkQueue按照它們插入隊列的順序運行所有請求。它是先進先出(FIFO)系統。
如果你想確保它們都是一個接一個地運行而不是並行的,那麼你可以將併發設置爲1.隊列將從第一個請求開始並逐個運行,直到它到達最後一個請求
ASINetworkQueue *networkQueue = [[ASINetworkQueue alloc] init];
// Here we add all our 10 requests, the order in which we add
// them determines the order they will execute
// Set the concurrency to 1 and fire off the queue
[networkQueue setMaxConcurrentOperationCount:1];
[networkQueue go];
2
檢查AFNetworking因爲不再維護ASIHTTPRequest。您可以使用它NSOperationQueue,其中有屬性maxConcurrentOperationCount
。如果將其設置爲1:
將最大操作數設置爲1會有效地爲處理操作創建一個串行隊列。
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"https://gowalla.com/users/mattt.json"]];
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
NSLog(@"Name: %@ %@", [JSON valueForKeyPath:@"first_name"], [JSON valueForKeyPath:@"last_name"]);
} failure:nil];
NSOperationQueue *queue = [[[NSOperationQueue alloc] init] autorelease];
[queue setMaxConcurrentOperationCount:1];
[queue addOperation:operation];
[queue addOperation:anotherOperation];
相關問題
- 1. 問題與ASINetworkQueue?
- 2. ASINetworkQueue和MBProgressHUD
- 3. 排序與訂單
- 4. 訂單號與Lua
- 5. SQL UNION與訂單
- 6. 如何恢復ASINetworkQueue?
- 7. 過濾與訂單狀態不一致的訂單狀態與訂單狀態訂單歷史記錄
- 8. 如何訂購,團體,訂單與MySQL
- 9. 與CanCan的狂歡訂單
- 10. 更改訂單yAxys與EPPlus
- 11. 與多個訂單列
- 12. 訂單與關聯性
- 13. 訂單樣式與ZF
- 14. 訂單String數組與BashScript
- 15. find_each與訂單和限制
- 16. row_number()over()與訂單組合
- 17. 與聯盟的SQL訂單
- 18. 沒有設置的ASINetworkQueue DownloadDestinationPath
- 19. 暫停和恢復ASINetworkQueue
- 20. ASIHTTPRequest和ASINetworkQueue和JSON解析
- 21. ASINetworkQueue委託方法不叫
- 22. ASINetworkQueue請求allways失敗 - ios
- 23. 添加總體訂單與案例訂單
- 24. 將採購訂單與銷售訂單鏈接的查詢
- 25. 如何顯示的客戶訂單記錄與訂單項目
- 26. 與訂單的區別與條款
- 27. 訂單清單不能與ol type =「a」
- 28. FIX問題與新的訂單單
- 29. 對於可觀察,訂閱訂單是否保證與通知訂單相同?
- 30. 訂單和子訂單
請注意,ASIHTTPRequest沒有積極開發了:http://allseeing-i.com/%5Brequest_release%5D – vikingosegundo 2011-12-14 00:52:09