title: Serialization array of custom objects iOS
body: <p>I know there is a lot of resources about that here but yet, I can't find what's going wrong with my code:</p>
  
  <p>I have a class Level and two subclasses of Level: GameLevel and TransitionLevel. Each of this class implements the NSCoding protocol.
  Then, I've got an array of Level (so it contains both classes of GameLevel and TransitionLevel). Saving the archive seems to work fine :</p>
  
  <pre><code>NSString *archivePath = [DOCUMENT_DIRECTORY stringByAppendingPathComponent:@"levels.archive"];
  [NSKeyedArchiver archiveRootObject:levels toFile:archivePath];
  </code></pre>
  
  <p>Note that levels is the array I want to save. I can see the file, it's created and seems to contains what it's supposed to contain.
  But when I want to retrieve this array :</p>
  
  <pre><code>NSString *archivePath = [DOCUMENT_DIRECTORY stringByAppendingPathComponent:@"levels.archive"];
  levels = [NSKeyedUnarchiver unarchiveObjectWithFile:archivePath];
  </code></pre>
  
  <p>I've got this exception:</p>
  
  <pre><code>*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
  </code></pre>
  
  <p>I'm not sure what I'm missing here.</p>