标签:return catch 文本 oftype txt bundle cat span enc
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 "" }
方法有些简单,就是这么简单。
标签:return catch 文本 oftype txt bundle cat span enc
原文地址:https://www.cnblogs.com/jiduoduo/p/14643426.html