title: Using NSKeyedArchiver to store custom data model
body: <p>I'm working on a rss reader. It is just a tableview and each cell shows a custom data model RSSEntry. And I have a NSMutableArray allEntries which contains all RSSEntry I got from the server. This is what RSSEntry looks like:</p>
  
  <pre><code>    @interface RSSEntry : NSObject &lt;NSCoding&gt; {
          NSString *_blogTitle;
          NSString *_articleTitle;
          NSString *_articleUrl;
          NSDate *_articleDate;
      }
  </code></pre>
  
  <p>I want to restore data from local archive so when I quit and open this app again, the tableview is populated with data when last refresh.</p>
  
  <p>I've read example in 'Beginning iOS5 Programming', but it only store and restore only one data model. So I don't know how to store this mutable array full of my custom data model and restore it.</p>
  
  <p>I use following code to store and restore data:</p>
  
  <pre><code>// STORE
  NSMutableData *data = [[NSMutableData alloc] init]; 
  NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];
  [archiver encodeObject:entry forKey:kDataKey];
  [archiver finishEncoding];
  
  // RESTORE
  NSData *data = [[NSMutableData alloc] initWithContentsOfFile:[self dataFilePath:kFilename]];
  NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];
  RSSEntry *entries = [unarchiver decodeObjectForKey:kDataKey];
  [unarchiver finishDecoding];
  </code></pre>
  
  <p>I can only store and restore one data model in this way.</p>
  
  <p>Who can give me a hand. I'm new to iOS programming, maybe it's a little dull .sorry.</p>