I was wondering what the simplest and cleanest to read a text file into an array of strings is in swift.
Text file:
line 1 line 2 line 3 line 4
Swift 4:
do { let contents = try String(contentsOfFile: file, encoding: String.Encoding.utf8) let lines : [String] = contents.components(separatedBy: "\n") } catch let error as NSError { print(error.localizedDescription) }