Skip to content

Instantly share code, notes, and snippets.

@minsOne
Created April 6, 2015 13:14
Show Gist options
  • Select an option

  • Save minsOne/966bf8ebb0506f93b6f3 to your computer and use it in GitHub Desktop.

Select an option

Save minsOne/966bf8ebb0506f93b6f3 to your computer and use it in GitHub Desktop.
func readFile(fileName: String, fileType: String) -> String{
var fileRoot = NSBundle.mainBundle().pathForResource(fileName, ofType: fileType)
var contents = NSString.stringWithContentsOfFile(fileRoot!, encoding: NSUTF8StringEncoding, error: nil)
return contents
}
// example: read file.txt
var contents = readFile("file", fileType: "txt")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment