Tuesday, 27 August 2013

How to save a multi-leveled custom object to NSUserDefault's?

How to save a multi-leveled custom object to NSUserDefault's?

I am looking to save an elaborate multi-leveled custom object into
NSUserDefaults. My setup of custom classes is as follow's:
Instructor
@property (strong, nonatomic) NSString *instructorName;
@property (strong, nonatomic) NSMutableArray *classes; // Array of class
object's
Class
@property (strong, nonatomic) NSString *className;
@property (strong, nonatomic) NSMutableArray *students; // Array of
student object's
Student
@property (strong, nonatomic) NSString *studentName;
@property (nonatomic) NSUInteger studentNumber;
@property (nonatomic) NSInteger studentMoney;
I am needing to save the top level "Instructor" object into
NSUserDefault's so that I can access the entire tier of data below it. I
have referenced this post, but I am needing a little bit more help on
getting it solved. In that example he show's two different classes' and
some method's to go along with it. Are those method's written into the
different custom classes themselves? How would I go about practically
using that for my application?
I am needing to save a single "Instructor" object, which has an array of
classes, which are filled with an array of students. How can I save that
one instructor object to NSUserDefault's so I can retrieve it and reload
it for use?

No comments:

Post a Comment