How to serialize a class into a file on the iphone?
I'm having some trouble with an updated version of my app on the App Store.
I have a database with a person's info. However, if the user has the version 1.0 and updates to 2.0, I need to save this database.
I want to serialize it into a file on the iPhone so that when version 2.0 is being installed, it will completely remove version 1.0 and then deserialize the database Class back into the app.
How can I serialize/deserialize a class?
If the data's simple then look into archives and serialization.
If the data's complex, where you really need database function, then you can use sqlite.
If your class conforms to the NSCoding protocol, you can use NSKeyedArchiver class to serialize it, and then the NSKeyedUnarchiver class to deserialize it. Both classes support using data objects or a file on disk.