I have a problem that Im not sure how to tackle. I can without any problem make requests to the REST service when passing a single request.
My problem now is at based on that respons i get some values including ID´s. All ID´s retrieved will then need make another request to collect new information.
My guess is to load all the specific request in a array or dictionary and create request from that. Anyone have some useful tips regarding this? The information retrieved will then populate a UITableView.
I suggest you use a Sync-Async Pattern on this problem.
You need to implement two synchronous methods:
Implementing these using synchronous code is easy and testable. You can use simple methods like
dataWithURL…,stringWithContentsOfURL…,sendSynchronousRequest…, or ASIHTTPrequest with ease, and write straight forward unit tests for this. The code will also be extremely easy to maintain and extend, compare to how concurrent code usually ends up.Now to step two, create an asynchronous wrapper, I would use a delegate and a method signature like this:
You already have all the code that do what you need, so all you have to do is impelemnt the asynchronious parts. This code will be well sepearated and straight forward. Probaly not more than this:
I have written a longer blog post on this topic here: http://blog.jayway.com/2011/04/28/sync-asyn-pair-pattern-easy-concurrency-on-ios/