func getTextFileStr(filename:String!) -> String! { if let path = Bundle.main.path(forResource: filename, ofType: "txt") { do { let data = try String(contentsOfFile: path, encoding: .utf8) return data } catch { print(error) } } return "" }
方法有些简单,就是这么简单。