That’s quite an old example and some of the functions changed a little in the mean time. In particular, check out the FileManager documentation in the app.
Try this.
let fm = FileManager.iCloud()
let dir = fm.documentsDirectory()
let path = fm.joinPath(dir, "myfile.txt")
fm.writeString(path, "Hello world")
let text = fm.readString(path)
await QuickLook.present(text)
Hope that helps.