I am trying to read a .txt file from my Resource folder in a swift iOS project. The function is
class func readFile(){
var filePath = NSBundle.mainBundle().pathForResource("testfile", ofType:"txt")
var dataout = NSString(contentsOfFile: filePath!, encoding: NSUTF8StringEncoding, error: nil)
println(dataout)
}
My text file is
This is a test
The console outputs
Optional(This is a test )
I can't figure out what the Optional() is????