RestKit ActivityIndicator 用于多个请求
我有一个 IBAction,可以通过 iPad 应用程序中的按钮调用。
IBaction 然后调用三个不同的方法来发起 RestKit 请求。
检查所有三个请求检索的对象的最佳方法是什么?
目标是通过第一个请求显示 ActivityIndicator,并通过检索所有三个请求的对象来停止/隐藏 ActivityIndicator。
我是 RestKit 的新手,所以如果这是一个太简单的问题,请原谅我。我尝试在 RestKit API - 文档的帮助下自己找到解决方案。
I have a IBAction which is called via a button in my iPad App.
The IBaction Calls then three different methods which initiate a RestKit Request.
What would be the best way to check of for all three requests the objects where retrieved?
The goal is to show an activityIndicator with the first request and stop/hide the activityIndicator with the retrieval of objects for all three requests.
I'm new to RestKit, so please forgive me if this is a too simple question. I tried to find a solution by myself with the help of the RestKit API - Documentation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想你使用异步请求。一种简单的解决方案是检查
RKObjectLoderDelegate
的- (void)objectLoader:(RKObjectLoader*)objectLoader didLoadObjects:(NSArray*)objects
方法是否包含所有数据已经加载。启动 RestKit 请求时,您可以向请求添加一个“标签”(在 RestKit 中称为
userData
),并稍后在委托回调中检索该标签。例如,您可以实现以下逻辑:
当您创建请求时,向每个请求添加特定的用户数据:
并检查
didLoadObjects:
中的标签:加载请求时不要忘记处理错误情况请求。
或者,如果此方法不适合您的场景 - 您可以在单独的队列和队列中添加和管理请求。跟踪进度。如果您需要有关第二个选项的更多信息,请告诉我。
I suppose you use asynchronous requests. One simple solution can be a check in your
RKObjectLoderDelegate
's- (void)objectLoader:(RKObjectLoader*)objectLoader didLoadObjects:(NSArray*)objects
method whether all of your data is already loaded.When initiating RestKit requests, you can add a 'tag' (called
userData
in RestKit) to a request and retrieve that tag later in the delegate callbacks.For example, you can implement the following logic:
When you create your requests, add a specific user data to each one:
and check the tags in
didLoadObjects:
Don't forget to handle error situations when loading the requests.
Alternatively, if this approach will not fit your scenario - you can add and manage requests in a separate queue & track the progress. If you'll need more info on the second option just let me know.
有一个简单的方法,在您的 objectLoader 委托中,您可以使用 objectLoader 的内置函数,如下所示:
就这么简单。
There is an easy way, in your objectLoader delegate, you can use objectLoader's the built-in function like this:
Its just that simple.