title: How to get user home directory path (Users/"user name") without knowing the username in Swift3
body: <p>I am making a func that edits a text file in the Users/johnDoe Dir. </p>
  
  <pre><code>let filename = "random.txt"
  let filePath = "/Users/johnDoe"
  let replacementText = "random bits of text"
  do {
  
   try replacementText.write(toFile: filePath, atomically: true, encoding: .utf8)
  
  }catch let error as NSError {
  print(error: + error.localizedDescription)
  }
  </code></pre>
  
  <p>But I want to be able to have the path universal. Something like </p>
  
  <pre><code>let fileManager = FileManager.default
      let downloadsURL =  FileManager.default.urls(for: .downloadsDirectory, in: .userDomainMask).first! as NSURL
      let downloadsPath = downloadsURL.path
  </code></pre>
  
  <p>but for the JohnDoe folder. I haven't been able to find any documentation on how to do this. The closest thing I could find mentioned using NSHomeDirectory(). And I am not sure how to use it in this context. </p>
  
  <p>when I try adding it like...</p>
  
  <pre><code>let fileManager = FileManager.default
      let downloadsURL =  FileManager.default.urls(for: NSHomeDirectory, in: .userDomainMask).first! as NSURL
      let downloadsPath = downloadsURL.path
  </code></pre>
  
  <p>I get an error:</p>
  
  <blockquote>
    <p>"Cannot Convert value of type 'String' to expected argument type 'FileManager.SearchPathDirectory'"</p>
  </blockquote>
  
  <p>I've tried it .NSHomeDirectory, .NSHomeDirectory(), NShomeDirectory, NShomeDirectory()</p>