Created
December 28, 2016 16:35
-
-
Save fbukevin/455a884f7f65c835d543ae62e859e745 to your computer and use it in GitHub Desktop.
Load general text file in Swift 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func loadText(file: String, handler: (String) -> Void){ | |
if let path = Bundle.main.path(forResource: file, ofType: "txt") { | |
do { | |
let context = try String(contentsOfFile: path, encoding: .utf8) | |
handler(context) | |
} catch { | |
print(error.localizedDescription) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment