title: Accessing temp directory in Swift
body: <p>I was trying to access temp directory in Swift. In Objective-C, I could use the following code to do so:</p>
  
  <pre><code>- (NSString *)tempDirectory {
  
      NSString *tempDirectoryTemplate =
      [NSTemporaryDirectory() stringByAppendingPathComponent:@"XXXXX"];
      const char *tempDirectoryTemplateCString = [tempDirectoryTemplate fileSystemRepresentation];
      char *tempDirectoryNameCString           = (char *)malloc(strlen(tempDirectoryTemplateCString) + 1);
      strcpy(tempDirectoryNameCString, tempDirectoryTemplateCString);
      char *result                             = mkdtemp(tempDirectoryNameCString);
      if (!result) {
          return nil;
      }
      NSString *tempDirectoryPath = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:tempDirectoryNameCString length:strlen(result)];
      free(tempDirectoryNameCString);
      return tempDirectoryPath;
  }
  </code></pre>
  
  <p>However, I'm a bit confuse about the type conversion and casting from Objective-C to Swift, such as  <code>const char *</code> or <code>CMutablePointer&lt;CChar&gt;</code>. Is there any documents that I should look into?</p>
  
  <p>Thanks.</p>