I have a small iPhone app that stores a list of objects. The user can add and remove objects, but this list will remain fairly small (most users would have 10-30 objects). <
Try with NSCoding protocol. Declare your class to implement NSCoding protocol:
@interface Person : NSObject
Previous line promises to implement the following methods:
-(id)initWithCoder:(NSCoder *)coder;
-(void)encodeWithCoder:(NSCoder *)coder;
Your methods should look something like:
-(void)encodeWithCoder:(NSCoder *)coder {
[super encodeWithCoder:coder];
[coder encodeObject:firstName forKey:@"firstName"];
[coder encodeObject:lastName forKey:@"lastName"];
}
-(id)initWithCoder:(NSCoder *)coder {
[super init];
firstName = [[coder decodeObjectForKey:@"firstName"] retain];
lastName = [[coder decodeObjectForKey:@"lastName"] retain];
return self;
}