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.

Need Your Help

How can I create an architecture dependant Debian package for my Python extension?

python debian dpkg lirc

I've written a Python 3 LIRC extension since pylirc doesn't work for Python 3. I'm trying to package it up into a Debian package and have had success in creating the packages python3-lirc_1.2.0-1_a...

Line break based on character found

ios nsstring uilabel line-breaks word-wrap

I want to break an email in a UILabel into two lines by "@" , for example: