ios - Why is array empty after appending object to it -


i working in tableviewcontroller trying fill data plist.

i declared @ top:

var studentsarray:array<studentdata>? 

and doing following in function loads plist:

    var path = nsbundle.mainbundle().urlforresource("students", withextension: "plist")     let tmparray = nsarray(contentsofurl: path!)      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 properties of object, being filled in, goes wrong @ .append , somehow won't that. array's count remains 'nil' when logged.

i'm kind of lost here! appreciated.

doesn't initializing studentsarray anywhere. make sure that. record, array.count should 0 if array empty, not nil. if seeing nil means array nil (aka didnt initialize it).


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -