Data.txt contains stuff like this : "Cat" "Dog" "Mouse"
I want to fill an array with strings from that file (dico[0] = "Cat", dico[1] = "Dog", aso).
I found this, How to call Objective-C's NSArray class method from within Swift? and Read and write data from text file, but when I use this code :
let bundle = NSBundle.mainBundle()
let path = bundle.pathForResource("data", ofType: "txt")
let dico = NSArray(contentsOfFile: path)
println("\(dico[0])")
println("\(dico.count)")
All I get is "nil" and "0".
I guess data in my file aren't written the way they should be and the code I use isn't right, but I can't figure why.
Moreover, when I use this code, it's OK :
let bundle = NSBundle.mainBundle()
let path = bundle.pathForResource("data", ofType: "txt")
let dico = NSString(contentsOfFile: path)
println("\(dico)")
The problem is that I don't want dico to be a string, I want it to be an array.