休息套件.RKObjectManager 和队列 [英] RestKit. RKObjectManager and queing

查看:40
本文介绍了休息套件.RKObjectManager 和队列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个相当简单的问题.我有 2 个映射的请求发送给我,我彼此紧密连续,称为通过主线程.

I have 2 fairly simple question. I have 2 mapped requests sent i close succession to each other, called by MAIN thread.

第一个请求:[[RKObjectManager sharedManager] loadObjectsAtResourcePath:@"SomePathToServer"delegate:self]

First request: [[RKObjectManager sharedManager] loadObjectsAtResourcePath:@"SomePathToServer"delegate:self]

第二个请求:

[[RKObjectManager sharedManager] loadObjectsAtResourcePath:@"SomeOTHERpathtoServer" delegate:self];

我的问题是:它们是否由对象管理器自动排队?

当我现在运行它们时,第一个请求将触发与网络服务的相当大的同步通信.我在通信过程中发出的第二个请求没有被 RestKit 处理/接收.

When i run them now the first request will trigger a rather large syncing communication with the webservice. The second request i fired off in the midst of that communication and is not handled/Recieved by RestKit.

如果我再次运行我的应用程序,我的代码会检测到同步已完成,现在处理第二个请求 - 接收并映射数据.

If i run my app again, my code detect that the syncing is done, and now the second request is handled - Data is recieved and mapped.

我是否必须手动将我的托管请求添加到队列中?

我还没有在网上找到任何关于它的信息,所以如果我必须手动排队,我想知道是否有人有指南的示例或说明.我只找到了简单请求的队列示例,我没有关于如何将第一个和第二个请求放入队列的想​​法 - 如果需要.非常感谢帮助.托马斯

I havent found anything about it on the net, so if i have to manually queue it, i wonder if someone has an example or directions to a guide. I have only found queing examples for simple requests, and i have no idea on how to put the First and Second request into the queue - if needed. Help is much appreciated. Thomas

推荐答案

RKRequestQueue 将完成这项工作.您可以将RKObjectLoaderRKRequest

RKRequestQueue will do the job. You can add to the queue either RKObjectLoader or RKRequest

示例如下:

RKRequestQueue *queue  =[[RKRequestQueue alloc] init];
    queue.delegate = self;
    queue.concurrentRequestsLimit = 1;
    queue.showsNetworkActivityIndicatorWhenBusy= YES;

    [queue addRequest:[[RKObjectManager sharedManager] objectLoaderWithResourcePath:@"resource" delegate:self]];
    [queue addRequest:[RKClient sharedClient] requestWithResourcePath:@"Another Resource "delegate: self]];

    [queue start];

这篇关于休息套件.RKObjectManager 和队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆