0

I'm a student and working on my first app which needs a contact sync system with the web database i.e to check if the contact in your addressbook is already a registered user or not. So what I'm doing is firstly saving all of the contacts in an Array and then trying to make POST request with each contact in that Array. What I want to ask is :

  1. Is this any good to make the request in a loop with all the contact? (Real-world scenario can have 100s of contacts). I've already implemented this but the response is kind of mixed up some time so it's not reliable enough (I haven't used any completion blocks yet)

  2. I've used the synchronous requests too with an activity indicator on UI. I know this is a really bad approach but how can I handle the multiple response from async requests?

  3. What is the recommended way of making multiple requests and handling the response?

Thanks

1 Answers1

0

You could use [NSURLConnection sendAsynchronousRequest:queue:completionHandler:]. As you can see, this method uses completition blocks.

Here is an example

Regarding "1.", if you make asynchronous calls, you are not supposed to get the responses in the same order as you sent them. So, what you have to do, is to check to which calls the responses belong.

Community
  • 1
  • 1
Daniel
  • 20,420
  • 10
  • 92
  • 149