Swift
xxxxxxxxxx
let fileName = "myFileName.txt"
var filePath = ""
let dirs:[String] = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.documentDirectory, FileManager.SearchPathDomainMask.allDomainsMask, true)
if dirs.count > 0 {
let dir = dirs[0] //documents directory
filePath = dir.appending("/" + fileName)
print("Local path = \(filePath)")
} else {
print("Could not find local directory to store file")
return
}
let fileContentToWrite = "Text to be recorded into file"
do {
try fileContentToWrite.write(toFile: filePath, atomically: false, encoding: String.Encoding.utf8)
}
catch let error as NSError {
print("An error took place: \(error)")
}
Linux - 如何安装 anc-api-tools
Linux - 如何安装 curvedns
Python - 检查数字是正数、负数还是 0
Linux - 如何安装 zenmap
C - 计算整数中的位数
C++ - 检查一个数字是否是素数
C++ - 检查闰年
C - 使用动态内存分配查找最大数
JavaScript - 检查字符串是否以某些字符开头和结尾
Kotlin - 反转数字
Linux - 如何安装 zstd
Linux - 如何安装 xbitmaps
Kotlin - 将数字四舍五入到 n 个小数位
Python - 编写 Excel (XLSX) 文件
C++ - 求商和余数
Java - 反转数字
Kotlin - 查找数字的阶乘
Linux - 如何安装 zfs-test
We have been online since 2021 and 1 millions of people around the globe have visited our website since then
More visitors every month