I've seen a few posts about how you can't save an object based NSMutableArray
in NSUserDefaults
, but that there is a way of doing it using [NSKeyedArchiver]
and encoding it with NSCoder
although I'm struggling to understand how to do it and was hoping someone could help.
Student *student1 = [Student studentWithImage:[UIImage imageNamed:@"default"] withForename:@"John" withSurname:@"Smith" withAddress:@"3 Fake Road, Faketown, FA31 KEE" withDateOfBirth:[dateFormatter dateFromString:@"17-Jul-93"] withAge:24];
[studentArray addObject:student1];
I want this and a few other similar Students
to be saved to my NSMutableArray
studentArray
. I want to then save this array to NSUserDefaults
and load it back up again.
I have seen this post here which looks like is the correct answer to my question, but I need help implementing it to my code as I'm having difficulty understanding it! Thanks