title: Best way to persist NSDictionary indefinitely
body: <p>I've got an app that relies on a single moderately large (300kb) data pull onload, of data that changes significantly on regular intervals of about once every 2-3 months.  It is reasonably fast to load, but I'm trying to build in more robust support for offline usage and not having to reload it each time for no reason.  The data is JSON that is serialized directly to a deep, multilevel NSDictionary structure that is easy to use.  So, I'm happy keeping the NSDictionary format if I can.</p>
  
  <p><strong>The Usage Scenarios/Ideas:</strong></p>
  
  <ul>
  <li><p>The dictionary persists automatically while the app is in background of course, so resuming it doesn't have to to reload it on viewWillAppear if it exists.</p></li>
  <li><p>More significantly when the app terminates, it needs to reload the data to memory without a new request each time.  It seems too large and inappropriate to store in UserDefaults.  Yet too complex to put in CoreData or SQLLite for just persistence attempts.</p></li>
  <li><p>I've thought about flat file store, but am not sure plist conversion is the best format, and am unfamiliar with a way to serialize/deserialize a massive NSDictionary to regular text.</p></li>
  <li><p>Finally, it ultimately needs to know to refresh itself if the data eventually becomes stale.  I've considered using NSURLConnection various cache options, but am not sure of the appropriate options for such a scenario.</p></li>
  </ul>
  
  <p>Looking for suggested best-approaches for this scenario.</p>
  
  <p><strong>EDIT The rough solution I went with, saving to file:</strong></p>
  
  <p>Called in the AppDelegate on load/exit appropriately, with URL load as a fallback.</p>
  
  <pre><code>- (void) saveResultsToFile {
      NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
      NSString *documentsDirectory = [paths objectAtIndex:0];
      NSString *path = [documentsDirectory stringByAppendingPathComponent:@"schedule.plist"];
      BOOL writeSuccess = [_routeData writeToFile:path atomically:YES];
  }
  
  - (void) readResultsFromFile {
      NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
      NSString *documentsDirectory =  [paths objectAtIndex:0];
      NSString *path = [documentsDirectory stringByAppendingPathComponent:@"schedule.plist"];
      _routeData = [[NSMutableDictionary alloc] initWithContentsOfFile:path];
  }
  </code></pre>