我尝试了以下代码段,但无法将其写入文件
let helperPath = "/Users/apple/Documents/UITestHelper.txt"
let fileManager = FileManager.default
if fileManager.fileExists(atPath: helperPath) {
do {
try "hello".write(toFile: helperPath, atomically: true, encoding: String.Encoding.utf8)
} catch let error as NSError {
print("An error took place: \(error)")
}
我看到的错误是错误域= NSPOSIXErrorDomain代码= 1 \“不允许操作\”}}