I have a place in my program where I need to send some data to the server, get a response, and put it into a dictionary.
I’m quite new to this, and until now, I have been sending a synchronous request to the server. This is easy, because I can just get the response and set it in my dictionary through the function that does the call.
However, doing things asynchronously clearly complicates matters.
How can I easily and elegantly determine when my request has finished processing, and then continue doing what I was doing, without locking up the entire program?
Thankful for any and all answers / tutorials.
Edit: As a response to the comment below, what I find confusing is that my response will show up in connectionDidFinishLoading after an indeterminate amount of time, and I really don’t know how to continue doing what I was doing in the method that called the request, without taking a wild guess with NSTimer or whatever.
NSNotification would be a great way to handle async connections.
First , Create a notification like this b4 sendin the request.
Next in the connectionDidFinishLoading method, have another notification like this,
Have this notification code next to the line where u obtain ur dictionary data.
The above notification will send a note to the first notification created, which will inturn trigger the updateView (in this example) method. You can have ur processing of obtained data in that method. Hope this helps. Cheers. 🙂 Happy coding 🙂