开发者

Best way to load distant data

开发者 https://www.devze.com 2023-02-05 20:17 出处:网络
I\'m currently develo开发者_C百科pping an iPhone app and need your opinion. First, I am developping it for a Football (soccer) Club. It contains many tabs (at least these ones) :

I'm currently develo开发者_C百科pping an iPhone app and need your opinion.

First, I am developping it for a Football (soccer) Club. It contains many tabs (at least these ones) :

  1. News (Where I am displaying last news posted, obviously)
  2. Shop (Where the user can buy stadium seats, and maybe various goodies)
  3. Don't know yet exactly (But it will be related to Facebook/Twitter or stuff like that)

For every of theses tabs, I need to download XML data (using initWithContentOfURL). Right. But, that's where my problem is. Should I :

  • Load every needed xml pages at application start-up, and display a nice loading screen ?
  • Load every needed xml pages at the exact instant the user needs it in the application ?

In the first case, I get a slower application startup, but then, a faster navigation between tabs.

In the second case, my application starts relatively faster (still needs to load News XML, that's the welcome tab), but switching between tabs won't be as fluent as the first case (only the first time the tab is opened, of course).

Any advice?


Take a look at ASIHttpRequest which does provide some pre built caching mechanisms for you that may be appropriate and generally make interacting with web services easier


Load only what you need when you need it.

Furthermore, I wouldn't use initWithContentsOfUrl. It's a synchronous call, and it will lock your app. Instead, use an NSURLConnection to get the data asynchronously.

0

精彩评论

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