开发者

iPhone Synchronous request

I am making a synchronous request to the web service and unable to show the loading... alert. As I am u开发者_运维知识库nable 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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜