tags:

views:

23

answers:

3

I've not found a answer to this question anywhere, but this seems like a typical problem: I have in my "Resources" Folder a XML File that my App needs to show some informations. But I have to check in my Server, if the server has a newer XML available, so I should replace my XML (in the resources folder) for this new one.

How can I achieve that?

Thanks in advance for any help!

+1  A: 

You can let the API, a method to check The most recent modified date. And in the client site, you can get your most recent modified date of the XML file and compare with the one in the server. You can get the description of the XML file and return true or false to replace.

vodkhang
Gonna try this. Thx!
jcdmb
+1  A: 

U need some way to distinguish the new XML from the old one. I assume you have some mechanism to do that. Typically some kind of Version node inside the XML. If the server's version and the one on ur phone is different, get the new one else don't do anything.

Sharath
+1  A: 

I'm not sure you get write access to the Resources section. A better way to do it, is to download the folder to your "Documents" directory. Then when you app checks to load the XML file, it should see if there is a version in the documents directory and load that first. If it doesn't find a replacement one, then it uses the original version.

This means the original XML file can be used if there is some issue with the downloaded one. Which happens, either the network got cutoff and didn't finish, or the server gave the wrong xml file and it doesn't validate.

You can access the document directory using:

NSArray *docPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); 
NSString *destinationpath = [docPaths lastObject];

If you are wanting to check the versions, you can use an element inside the XML to give you the version number or you can use the Last-Modified date. An example of the version could be:

<myxml version="234">

Then you could check this value.

christophercotton
I am already using the method you have just recommended, but I thought I could replace the originial file. If it is not the case, I am glad to know I do not get write access to the Resources section. thx
jcdmb