开发者

Speed up iPhone application when consuming web service

开发者 https://www.devze.com 2023-01-15 06:38 出处:网络
I have an iPhone application , which is consuming a Soap web service. When am sending a URLrequest, the application is getting slow.My application is a TabBarApplication.From a started calling开发者_运

I have an iPhone application , which is consuming a Soap web service. When am sending a URLrequest, the application is getting slow.My application is a TabBarApplication.From a started calling开发者_运维知识库 web-service to parsing the received data, i can't select Tabs in UITabbarcontroller. How to speed my iPhone app Tabbarcontroller to get selected even when application receiving some data from web-service ? Is the use of NSThread is a good solution ?


Whenever you access the network, do it asynchronously, either by using a separate thread or by using asynchronous NSURLConnection instances. That way, the UI remains reponsive.

This doesn't come for free: All your views will need to manage state because they at first are in the "data loading" state (when they have submitted a request) and then, when the data last piece of data has arrived, they go into the "data loaded" state and need to be refreshed. If the reqeust fails, they go into the "loading failed" state and present a "Retry" button (or something similar).

I've written an application that gets all it's data from a remote web service. It's feels very fast and responsive, probably due to the following facts:

  • It loads all data asynchronously (with NSURLConnection instances).
  • It uses JSON instead of SOAP because it's more compact and quicker to parse.
  • It ueses compression on the HTTP connection.
  • It only loads as few data as possible on each request.
0

精彩评论

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