第一张和第二张图片我可以成功读取和写入我的thisdata.txt文件,但我只能打印消息
我想让标签显示来自thisdata.text的文本
我该怎么做?
https://i.stack.imgur.com/E94df.png
https://i.stack.imgur.com/nntOL.png
答案 0 :(得分:1)
您需要将string
分配给data
标签。就像:
data.text = readString // If you need to print 'readString'
data.text = readStringProject // If you need to print 'readStringProject'
var readString = ""
do {
readString = try String(contentsOfFile: fileURL)
data.text = readString
} catch let error as NSError {
print("failed to read file")
print(error)
}