views:

174

answers:

3

I need to take existing classes for an iPhone application and store them in a preference/plist/some other data storage format. A good comparison of what I need to store is a gradebook, with the following class structure:

GBGradebook + NSArray (GBAssignment) + NSArray (GBClasses) + NSArray (GBStudent)

GBStudent + NSString *studentName ...

GBAssignment + GBGrade *grade ...

GBGrade + NSNumber *pointsReceived + NSNumber *maxPoints ...

That's the basic class structure. What is the best way to store this data?

+8  A: 

Here's a tutorial on how to do exactly that using the NSCoding protocol and NSKeyedArchiver (and its counterpart, NSKeyedUnarchiver): http://cocoaheads.byu.edu/wiki/nscoding

Basically you implement two methods and you're done.

Dave DeLong
+1  A: 

I'm not an expert at it, but Core Data may also be an option. There is also SQLLitePersistentObjects.

mahboudz
A: 

Core Data is your best bet. There's a bit of a learning curve, but it is designed to address your storage question as well as provide other benefits, such as SQL-like querying.

Alex Reynolds