How to get user home directory path (Users/“user name”) without knowing the username in Swift3

前端 未结 3 1050
北荒
北荒 2020-12-19 01:00

I am making a func that edits a text file in the Users/johnDoe Dir.

let filename = \"random.txt\"
let filePath = \"/Users/johnDoe\"
let replacementText = \"         


        
3条回答
  •  一整个雨季
    2020-12-19 01:41

    Maybe

    FileManager.homeDirectoryForCurrentUser: URL
    

    It's listed as "beta" for 10.12, though.

提交回复
热议问题