I am working in a TableViewController that I am trying to fill up with data from a plist.
I declared this at the top:
var studentsArray:Array<StudentData>?
And now I am doing the following in a function that loads my plist:
var path = NSBundle.mainBundle().URLForResource("students", withExtension: "plist")
let tmpArray = NSArray(contentsOfURL: path!)
for studentDict in tmpArray!{
let name = studentDict["name"]as! String
let dateOfBirth = studentDict["dateOfBirth"] as! NSDate
let regular = studentDict["regular"] as! Bool
let photoFileName = studentDict["photoFileName"] as! String
let data = StudentData(name : name, dateOfBirth: dateOfBirth, regular : regular, photoFileName: photoFileName)
self.studentsArray?.append(data)
println(studentsArray!.count)
}
I tried logging the properties of the Object, they are all being filled in, but it goes wrong at the .append and somehow it just won't do that. The array's count remains 'Nil' when logged.
I'm kind of lost here! Any help is appreciated.