开发者

Seeking iPhone App Architecture Advice: Managing Data

开发者 https://www.devze.com 2022-12-08 15:34 出处:网络
I\'ve built a simple iPhone app that parses data from a remote XML feed, converts the information into objects (they\'re videos), and displays the videos in a standard table view->detail view->\"Play

I've built a simple iPhone app that parses data from a remote XML feed, converts the information into objects (they're videos), and displays the videos in a standard table view->detail view->"Play Video" UI. There are hundreds of videos, each with about ten attributes. (The videos are never downloaded, only streamed, using MPMoviePlayerController.) I've relied on the Appl开发者_如何转开发e sample application SeismicXML for much of the app's behavior.

Now I'm ready for the next step: saving the video metadata to the device, so that users aren't forced to wait for the XML retrieval and parsing every time they launch my app. I'm planning to use Core Data to save my Video objects (and their parent Channel objects), but it's all brand new to me.

My question is: Can folks recommend any sample application or design pattern for managing this data? I want to have the app automatically download and parse the XML at launch, but then it should refresh the data only when the user taps a Refresh button, or if the data is older than, say, a day.

Apps that model this behavior are NYTimes, AP, and many others.

Besides the excellent documentation that Apple provides for Core Data, are there any resources out there for architecting an iPhone app that needs to download, save, and periodically refresh its data?

Thanks.

Update on 11/12/2009: Between the Apple sample code for TheElements, TopSongs, CoreDataBooks, PhotoLocations, iPhoneCoreDataRecipes, and XMLPerformance, I've got plenty of grist for the mill here. I'm currently analyzing the samples, and slowly piecing together what I need.


Looks like you found all of the Apple samples, so that's good.

The Pragmatic Programmers have a book on Core Data, and several of the iPhone SDK books out (including theirs) touch on Core Data a little. See also this question.

Edit: forgot to mention Three20 (the guts of the Facebook app, Open Sourced) as an example of a way to do this that isn't Core Data. Rather than re-constructing the downloaded data in some object graph that's persisted with Core Data, Three20 implements disk caching and freshness dating on top of the URL loading system. The app basically still works by making HTTP API calls, and parsing the responses, but doesn't have to talk to the cloud on every screen display, which speeds things up immensely. If you're only downloading this information to display in a big table view, and not anything else, perhaps this model might be easier.

0

精彩评论

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

关注公众号