我想排队有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. SQL UNION与订单
- 2. 订单号与Lua
- 3. 排序与订单
- 4. 如何恢复ASINetworkQueue?
- 5. 过滤与订单状态不一致的订单状态与订单状态订单历史记录
- 6. 如何订购,团体,订单与MySQL
- 7. 订单String数组与BashScript
- 8. 订单与关联性
- 9. 与多个订单列
- 10. ASIHTTPRequest和ASINetworkQueue和JSON解析
- 11. 暂停和恢复ASINetworkQueue
- 12. 将采购订单与销售订单链接的查询
- 13. 与订单的区别与条款
- 14. 对于可观察,订阅订单是否保证与通知订单相同?
- 15. 订单和子订单
- 16. 订单和订单明细
- 17. 订单清单,顶级订单未知
- 18. 选择案例与订单在jpa
- 19. SQL查询与不工作的订单
- 20. 订单列表C#与最佳性能
- 21. Cakephp分页与多个订单条件
- 22. Magento API订单ID与增量ID
- 23. 订单通过与学说多个列
- 24. MySQL查询,两个表与订单组
- 25. Magento的订单状态与状态
- 26. 使用.Contains保留与LINQ的订单
- 27. 列出月份与订单数量,AdventureWorks2014
- 28. 与特定产品的mysql订单
- 29. SQL内部连接客户与订单
- 30. MySQL更新与组和订单
请注意,ASIHTTPRequest没有积极开发了:http://allseeing-i.com/%5Brequest_release%5D – vikingosegundo 2011-12-14 00:52:09