I'm trying to save some data in a class named MyPos.h which uses the NSCoding methods:
(void)encodeWithCoder:(NSCoder *)aCoder
(id)initWithCoder:(NSCoder *)aDecoder
These two methods have been implemented in the MyPos.m file.
Now I want the application to save the data when it terminates and load data when it's finished launching. I'd like to implement the to methods in the AppDelegate.m file, but I can't get my head around how to save the instance of the MyPos class that holds the data.
This is one of the two methods in the AppDelegate.m file ... so far:
- (void)applicationWillTerminate:(UIApplication *)application {
NSMutableData *data = [[NSMutableData alloc] init];
NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];
[archiver encodeObject: **HELP_HERE!** forKey:@"myPos"];
[archiver finishEncoding];
[data writeToFile:[self dataFilePath] atomically:YES];}
How can I solve this? Thanks a lot in advance.