views:

576

answers:

1

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 Apple 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.

+2  A: 

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.

Sixten Otto
I agree; I recently looked into doing this for an app, and decided that if all you really want is local on-disk caching of network responses, then Core Data is probably *not* the way to go. (If the authoritative data store was going to be a local database on the device, then I'd use Core Data.) Take a good look at Three20.
jasoncrawford
Integrating Core Data with Three20 - http://crazyviraj.blogspot.com/2010/09/integrating-coredata-with-three20.html
psychotik