user304804
user304804

Reputation: 59

iPhone Synchronous request

I am making a synchronous request to the web service and unable to show the loading... alert. As I am unable to access UI while synchoronous request.

Can you anybody please guide me to show the activity indicator whle I am making synchoronous request.

Is it possible to show the loading message if run the synchronous request in background thread.

Regards, Malleswar

Upvotes: 0

Views: 883

Answers (2)

justin
justin

Reputation: 104698

yes it is possible to do this.

you should never block the main thread of an application with a UI as you've described -- always consider this in your designs.

there are a few approaches to accomplish this. NSOperation is a good starting point. so you'll create an NSOperation subclass which will perform the request, then notify something that the request has finished, and provide the prepared data.

1) start your progress indicator

2) add the operation

3) stop the indicator once the (NSOperation to controller) transaction has completed. hint: use performSelectorOnMainThread:… from the operation.

Upvotes: 1

Ward Bekker
Ward Bekker

Reputation: 6366

I would recommend running the request in a background thread. I always use the ASIHTTPRequest library for making async requests. In the callback methods you can than put code to toggle the loading alert visibility.

Upvotes: 0

Related Questions