if let path = Bundle.main.path(forResource: "README", ofType: "txt") {
do {
textView.text = try String(contentsOfFile: path, encoding: .utf8)
} catch let error {
// Handle error here
}
}
Just drop the file anywhere into the project browser and make sure it is added to the right target.
Just to expand on the answer, you can also place them in a folder and use:
+ pathForResource:ofType:inDirectory:.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…