title: Writing/reading NSData to file failing
body: <p>I have an in-memory cache that I would like to write out to file on <code>viewWillDisappear</code> and read in back into memory on <code>viewDidLoad</code>. My code:</p>
  
  <pre><code>- (void)viewDidLoad
  {
      [super viewDidLoad];
  
      NSFileManager *fileManager = [[NSFileManager alloc] init];
      NSArray *fileArray = [fileManager URLsForDirectory:NSCachesDirectory inDomains:NSUserDomainMask];
      NSString *filePath = [NSString stringWithFormat:@"%@cache_%d", [fileArray lastObject], self.index];
      NSURL *fileUrl = [NSURL URLWithString:filePath];
      if ([fileManager fileExistsAtPath:filePath]) {
          self.thumbnailsCache = [NSDictionary dictionaryWithContentsOfURL:fileUrl];
      }
  }
  
  - (void)viewWillDisappear:(BOOL)animated
  {
      NSFileManager *fileManager = [[NSFileManager alloc] init];
      NSArray *fileArray = [fileManager URLsForDirectory:NSCachesDirectory inDomains:NSUserDomainMask];
      NSString *filePath = [NSString stringWithFormat:@"%@cache_%d", [fileArray lastObject], self.index];
      NSURL *fileUrl = [NSURL URLWithString:filePath];
      [self.thumbnailsCache writeToURL:fileUrl atomically:YES];
  }
  </code></pre>
  
  <p>Based on some NSLog and debugging, it seems to write the file successfully, but on trying to read it simply says file not found. What am I doing wrong? Thanks.</p>
  
  <p>Edit: <code>self.thumbnailsCache</code> is an <code>NSDictionary</code> of <code>NSData</code> objects.</p>