//获取程序的Home目录
let homeDirectory = NSHomeDirectory()
print(homeDirectory)
//Documnets目录
//方法1
let documentPaths = NSSearchPathForDirectoriesInDomains(.documentDirectory,
.userDomainMask,true)
let documnetPath = documentPaths[0]as!String
print(documnetPath)
//方法2
let documentPath2 = NSHomeDirectory() +"/Documents"
print(documentPath2)
//Library目录-方法1
let libraryPaths = NSSearchPathForDirectoriesInDomains(.libraryDirectory,
.userDomainMask,true)
let libraryPath = libraryPaths[0]as!String
print(libraryPath)
//Library目录-方法2
let libraryPath2 =NSHomeDirectory() +"/Library"
print(libraryPath2)
//Cache目录-方法1
let cachePaths = NSSearchPathForDirectoriesInDomains(.cachesDirectory,
.userDomainMask,true)
let cachePath = cachePaths[0]as!String
print(cachePath)
//Cache目录-方法2
let cachePath2 =NSHomeDirectory() +"/Library/Caches"
print(cachePath2)
//temp目录
//方法1
let tmpDir = NSTemporaryDirectory()
print(tmpDir)
//方法2
let tmpDir2 =NSHomeDirectory() +"/tmp"
print(tmpDir2)