title: "No such file or directory" Error when creating directory
body: <p>I am attempting to save thumbnails of user generated photos in a subdirectory in the documents directory, but I am unable to create the subdirectory in the first place. When I attempt to create the subdirectory in the documents directory I get this error (No such file or directory):</p>
  
  <pre><code>Error Domain=NSCocoaErrorDomain Code=4 "The operation couldn’t be completed. (Cocoa error 4.)"
  UserInfo=0x17ef9c90 {NSFilePath=/var/mobile/Applications/FD0CC480-97FE-4E50-931F-5341DB6AD92B/Documents/com.Jonathan.App-Name/707F0431-7A09-4D33-B122-13C48AD4CA53, 
  NSUnderlyingError=0x17e51520 "The operation couldn’t be completed. No such file or directory"}
  </code></pre>
  
  <p>I'm so confused. I know the directory doesn't exist because I'm trying to create it! The only thing I can think of is that the documents directory is incorrect, but that is straight from the Apple Docs.</p>
  
  <p>Am I incorrectly trying to create the subdirectory?</p>
  
  <pre><code>- (NSURL *)documentsDirectory
  {
      NSFileManager *sharedFM = [NSFileManager defaultManager];
  
      NSArray *possibleURLs = [sharedFM URLsForDirectory:NSDocumentDirectory
                                               inDomains:NSUserDomainMask];
  
      NSURL *appSupportDir = nil;
      NSURL *appDirectory = nil;
  
      if ([possibleURLs count] &gt;= 1)
      {
          // Use the first directory (if multiple are returned)
          appSupportDir = [possibleURLs objectAtIndex:0];
      }
  
      // If a valid app support directory exists, add the
      // app's bundle ID to it to specify the final directory.
      if (appSupportDir)
      {
          NSString *appBundleID = [[NSBundle mainBundle] bundleIdentifier];
  
          appDirectory = [appSupportDir URLByAppendingPathComponent:appBundleID];
      }
  
      return appDirectory;
  }
  
  - (NSURL *)thumbnailDirectoryWithName:(NSString *)theName
  {
      NSURL *directory = [[self documentsDirectory] URLByAppendingPathComponent:theName];
      NSURL *thumbnailsDirectory = [directory URLByAppendingPathComponent:@"Thumbnails"];
  
      NSError *error;
  
      if ([[NSFileManager defaultManager] fileExistsAtPath:[thumbnailsDirectory path]] == NO)
      {
          [[NSFileManager defaultManager] createDirectoryAtURL:thumbnailsDirectory withIntermediateDirectories:NO attributes:nil error:&amp;error];
  
          if (error)
          {
              NSLog(@"[Thumbnail Directory] %@", [error description]);
  
              return nil;
          }
      }
  
      return thumbnailsDirectory;
  }
  </code></pre>
  
  <p>I have also tried <code>createDirectoryAtPath:</code> and <code>stringByAppendingPathComponent:</code> with no avail.</p>
  
  <p>The <code>NSURL *directory</code> in <code>thumbnailDirectoryWithName:</code> returns:</p>
  
  <pre><code>/var/mobile/Applications/FD0CC480-97FE-4E50-931F-5341DB6AD92B/Documents/com.Jonathan.App-Name/707F0431-7A09-4D33-B122-13C48AD4CA53
  </code></pre>
  
  <p>The last component of the file path, 707F0431-7A09-4D33-B122-13C48AD4CA53, is the unique identifier for an Entity in Core Data, which enables me to uniquely name a directory.</p>
  
  <p>Any help is greatly appreciated!</p>