May I ask the advice of the experts here?
I have successfully added archiving to a non-doc based Application. (Yes...I am going through Hillegass, with a twist! 🙂
1) Adopted NSCoding in the model class
2) Call archiveRootObject like this.
3) call unarchiveObjectWithFile like this.
Here is what puzzles me.
Both
are clearly called with the correct "coder" argument. I just wonder **how** these two methods receive the **correct** instance of coder. Particularly puzzling is the call in "init" which does not even handle the returned object, yet it obviously finds it's way to "initWithCoder". 🙂
Thanks in advance, as usual
I have successfully added archiving to a non-doc based Application. (Yes...I am going through Hillegass, with a twist! 🙂
1) Adopted NSCoding in the model class
2) Call archiveRootObject like this.
Code:
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
{
....preparatory stuff
[NSKeyedArchiver archiveRootObject: self toFile: savedValuesFile];
...more stuff }
Code:
-(id) init
{
....preparatory stuff
return [NSKeyedUnarchiver unarchiveObjectWithFile:savedValuesFile];
}
Here is what puzzles me.
Both
and-(id) initWithCoder: (NSCoder *) coder
-(void) encodeWithCoder: (NSCoder *) coder
are clearly called with the correct "coder" argument. I just wonder **how** these two methods receive the **correct** instance of coder. Particularly puzzling is the call in "init" which does not even handle the returned object, yet it obviously finds it's way to "initWithCoder". 🙂
Thanks in advance, as usual