My app is accessing data from a remote XML file. I have no issues receiving and parsing the data. However, I’d like to take the most current XML data and store it locally so – in the event that the user’s internet service isn’t available – the local data from the previous load is used.
Is there a simple way to do this? Or am I going to have to create an algorithm that will create a plist as the xml data is parsed? That seems rather tedious… I was wondering if there was an easier way to save the data as a whole.
Thanks in advance!
I don’t know what format your XML data is in as you receive it, but using NSData might be helpful here, because it has very easy-to-use methods for reading/writing data from either a URL or a pathname.
For example:
You can also easily convert an NSData object to/from a raw buffer (pointer/length) in memory, so if your data is already downloaded you might do: