Take the 2-minute tour ×

i'm french so maybe i'll make some mistakes, sorry about that :D

I explain my problem, I have a XMLParser who generates NSString (title, category, url, ...), I would like the stream that is generated is to save the user can read the stream even if it is not connected to the internet.

The flow generated can be found here ==> http://www.recontv.fr/testXml.xml

I try different solutions and each time, I should go about it wrong but its not working. : (

Do you need my code? Did I explain my problem?

Thank you in advance for your help!

PS: I post on differents forum for a answer, if I take it somewhere else, i pick here too.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

NSUserDefaults isn't really meant to be used for saving an array from XML to it. Your main solutions are to save the XML to a file and re-parse when the user needs to access the information offline, or you can save the NSArray itself to a file using either its writeToFile: methods, or NSKeyedArchiver/NSKeyedUnarchiver. In each case you must ensure that the objects in your array conform to the NSCoding protocol.

share|improve this answer
ok, while I waiting, I continu to search and I find the NSCoding protocol, but I didn't know how to make it. I already maked the "encodeWithCoder" and "initWithCoder" class but where do I put the code to save the array ? in the XMLParser or in the AppDelegate (where the parser was initialized) ? –  JioGray Oct 26 '11 at 8:33
You arrange the strings/element you parse into container objects (you can make your own or use a library like wonderxml code.google.com/p/wonderxml), putting them into an array as you go along, then save the array once the parsing is finished. –  jbat100 Oct 26 '11 at 8:50
k thx, i will do that and i return if i have a question but i think not ^^ –  JioGray Oct 26 '11 at 9:14

Your Answer


