0

When my user logs in, I have multiple:

 [[RKObjectManager sharedManager] 
     getObjectsAtPath:path
     parameters:nil<br/> success:
         ^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {

Now, I want to wait for all of them to finish to show the next page. I thought about putting them one inside another and return from the block until it reaches the last one, but this seems to kill the purpose of having async calls.

I thought about having a dictionary where I set the keys to YES and NO once a specific part is done, and wait for all the keys to be set to YES, but this seems prone to locks/concurrency problems.

So, any ideas to do this?!

Thanks!

4

1 回答 1

0

字典路由应该可以工作并且不应该有任何线程问题,因为成功和错误回调都在主线程上运行。

或者,如果您不关心哪些已完成,哪些未完成,您可以使用一个简单的计数器。

或者,您可以使用 的operationQueueRKObjectManager在每个成功块中检查是否仍有任何任务需要完成(尽管如果您正在使用 ,您需要考虑有效性sharedManager以及同时队列中可能有多少其他事情)。

于 2013-07-04T16:23:43.157 回答