1

At Apple's site, they say: "Because this call can potentially take several minutes to fail (particularly when using a cellular network in iOS), you should never call this function from the main thread of a GUI application."

In my case, the Application has nothing (literally nothing), to do in between the calling of WebService and the response returned. (There is no other activity My Application can Perform in between as per Specifications).

What should I do?

Is there any reason, (as per the situation) that can convince -- I should go for Asynchronous Call to WebService.

Any suggestions, as I am not very familiar to it ???

1 Answer 1

3

You should always go for asynchronous calls - otherwise you freeze whole UI of your app, due to blocking the main thread.

In other words: user will have his phone blocked when the request will be processed.

7
  • Can't I use ActivityIndicatorView during that time period?
    – viral
    Jan 4, 2012 at 12:17
  • This has nothing to do with any particular view - you just block rendering of your UI. If your app will be in this state for too long, system will issue warnings and finally kill your app for being unresponsive. Jan 4, 2012 at 12:18
  • But What if the nextView (to be loaded),is created based on response to the call. I mean, Async call loads the nextview immediately (all blank).What should i do then(other than reloading the view again)?
    – viral
    Jan 4, 2012 at 12:23
  • Create your nextView when you get response from your asynchronous call. It's particularly useful, when you use ASIHTTPRequest with blocks, see: allseeing-i.com/ASIHTTPRequest/How-to-use#using_blocks from ASIHTTPRequest library. Jan 4, 2012 at 12:25
  • 1
    @codeCube You can't use ActivityIndicatorView during that time because the UI is locked. (Depending on how you do it, the best case is that it appears but doesn't animate.) Jan 4, 2012 at 12:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.