title: How to create directory using Swift code (NSFileManager)
body: <p>I'm having some trouble with converting Objective-C code to create a directory for Swift.</p>
  
  <p>Objective-C:</p>
  
  <pre><code>    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
      NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents folder
      NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"/MyFolder"];
  
      if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath])
      [[NSFileManager defaultManager] createDirectoryAtPath:dataPath withIntermediateDirectories:NO attributes:nil error:&amp;error];
  </code></pre>