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
First you must read the file:
let text = String(contentsOfFile: someFile, encoding: NSUTF8StringEncoding, error: nil)
Then you separate it by line using the componentsSeparatedByString method:
componentsSeparatedByString
let lines : [String] = text.componentsSeparatedByString("\n")