Read a text file line by line in Swift?
问题 Just started learning Swift, I have got my code to read from the text file, and the App displays the content of the Entire Text file. How can I display line by line and call upon that line multiple times? TextFile.txt contains the following. Banana Apple pear strawberry blueberry blackcurrent the following is what currently have.. if let path = NSBundle.mainBundle().pathForResource("TextFile", ofType: "txt"){ var data = String(contentsOfFile:path, encoding: NSUTF8StringEncoding, error: nil)