views:

211

answers:

2

I have a web server which contains a list of "interesting locations". These are "hard coded" on the web server, and maintained from an administrator on the server-side. Users can't add or remove anything.

From within my app, I want to make a button "fetch locations", and the app should then contact the web server and ask for that "interesting locations" list.

I'm using Core Data and have an InterestingLocation entity in my model. The goal is to get the data from the web server and persist it on the device with Core Data, so that it is accessible even without internet connection.

My idea was to use XML on the server side and output the InterestingLocation "objects" in an XML file. There are about 100 of them only, so not really huge.

On the client side (device), maybe XML-RPC?

Would be happy about some suggestions and further information where/how to get started :)

+4  A: 

My advice is keep it simple. On the server side, use RESTful principles to make the interface as simple as possible.

Then, all you'll need to do in your iPhone app is use an NSURLConnection to fetch the URL. NSURLConnection is a very nice, asynchronous way of downloading files from remote locations.

After that, it's a simple matter of parsing the XML or JSON and creating the appropriate Core Data objects. I generally like to do import operations like this on a separate managed object context in a separate thread. When you save the managed object context, use the NSManagedObjectContextDidSaveNotification to merge in the changes with your main managed object context.

Alex
thanks. on the server side I would just output an plain old XML file with all the "interesting location" items. straightforward stuff so far.
openfrog
A: 

What kind of server do you have? If the server is java based I'd recommend looking at HessianKit by Fredrik Olsson. Encode/Decode to ordinary Objective-C types and put in NSArrays and NSDictionaries will make the experience smoother.

epatel
PHP. But I see Hessian can work with PHP as well, right? So you suggest Hessian would be faster or easier to use?
openfrog
I have only tested it short with PHP, I used this version http://sourceforge.net/projects/hessianphp/ My test was posted Sept 9 2009 here http://groups.google.com/group/cocoaheads-oresund The best thing with Hessian is that it translates ObjC types to and from PHP (or Java) automagically...
epatel
I also made a simple XML parser that also work fine on the iPhone, have a look here http://www.memention.com/blog/2009/10/31/The-XML-Runner.html
epatel