title: Differences with archiveRootObject:toFile: and writeToFile:
body: <p>Recently, I'm learning about NSKeyedArchiver and NSKeyedUnarchiver. I found that there are three ways to archive an array and I'm trying to figure out the differences.</p>
  
  <p><strong>1.Using <code>archiveRootObject:toFile:</code></strong></p>
  
  <pre><code>    [NSKeyedArchiver archiveRootObject:testArray toFile:filePath];
  </code></pre>
  
  <p><strong>2.Get data from <code>archivedDataWithRootObject:</code> and write it to file</strong></p>
  
  <pre><code>    NSData *data = [NSKeyedArchiver archivedDataWithRootObject:testArray];
      [data writeToFile:filePath atomically:YES];
  </code></pre>
  
  <p><strong>3.Using encodeObject: to get data</strong></p>
  
  <pre><code>    NSMutableData *data = [NSMutableData data];
      NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];
      [archiver encodeObject:testArray forKey:@"testArray"];
      [archiver finishEncoding];
      [data writeToFile:path atomically:YES];
  </code></pre>
  
  <p>After testing, I found that all ways above work fine and write same content to file.</p>
  
  <p>Q1: What's the differences with all the ways above?</p>
  
  <p>Q2: Can I use NSData in the 3rd way?</p>