How to save state of the app when app terminates?
<p>I am trying to save the app state by encoding when the app terminates.
I've found the solution related this issue.
But I don't know how to use. </p>

<p>I am really trying to make encoding and decoding like this: 
<a href="http://cocoaheads.byu.edu/wiki/nscoding" rel="nofollow">http://cocoaheads.byu.edu/wiki/nscoding</a></p>

<p>in CustomObject.h </p>

<pre><code>@interface CustomObject : NSObject &lt;NSCoding&gt;
{
   NSArray *someArray;
}
</code></pre>

<p>in CustomObject.m</p>

<pre><code>@implementation CustomObject

// Other method implementations here

- (void) encodeWithCoder:(NSCoder*)encoder {
    [encoder encodeObject:someArray forKey:@"someArray"];
}

- (id) initWithCoder:(NSCoder*)decoder {
    if (self = [super init]) {
      someArray = [[decoder decodeObjectForKey:@"someArray"] retain];
    }
    return self;
}

@end
</code></pre>

<p>My object to save is another NSArray. Not "someArray" in CustomObject. We call it that "MySaveObject".
I want to pass "MySaveObject" to "someArray" in CustomObject.</p>

<p>Actually I don't know how to encode "MySaveObject" and to pass to "someArray" in CustomObject.</p>

<p>Thanks in advance.</p>
