title: Reading and writing NSMutableDictionary to a plist file
body: <p>I am trying to save <code>NSMutableDictionary</code> in <code>applicationDidEnterBackground</code> of <code>AppDelegate.m</code> an to a <code>plist</code> file. Immediately after saving it, I try to check if the file exists and read it back, but the file is not found.</p>
  
  <pre><code>NSString *photoCacheFilename = @"photoCache.plist";
  [photoDict writeToFile:photoCacheFilename atomically:YES];
  NSLog(@"File name: %@", photoCacheFilename);
  BOOL isFile = [[NSFileManager defaultManager] fileExistsAtPath:photoCacheFilename];
  if(isFile)
  {
      NSLog (@"File found");
      NSMutableDictionary *newDictionary = [[NSMutableDictionary alloc] initWithContentsOfFile:photoCacheFilename];
  }
  else
  {
      NSLog (@"File not found");
  }
  </code></pre>
  
  <p>I modified the code as suggested by some users, but still the file is not found. I am not sure if I am checking for the existence of file correctly.</p>
  
  <pre><code>NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  NSString *documentsPath = [paths objectAtIndex:0];
  NSString *photoCacheFilename = [documentsPath stringByAppendingPathComponent:@"photoCache.plist"];
  
  [photoDict writeToFile:photoCacheFilename atomically:YES];
  
  BOOL isFile = [[NSFileManager defaultManager] fileExistsAtPath:photoCacheFilename];
  if(isFile)
  {
      NSLog (@"File found");
      NSMutableDictionary *newDictionary = [[NSMutableDictionary alloc] initWithContentsOfFile:photoCacheFilename];
  }
  else
  {
      NSLog (@"File not found");
  }
  </code></pre>