dimanche 24 juillet 2016

Retrieving bool array from NSUserdefaults in swift

I have defined an array like this in my iOS app

var array=[Bool]() and assigning some bool values to this.After that I am storing this array in my user defaults in this way.
userDefaults.setObject(dm.array, forKey: "array")

Now I want to retrievw this array. So I did like this

dm.array=userDefaults.arrayForKey("array") as! Array

But here im getting an error

Down cast from[Anyobject]? to array<anyobject> only unwraps optional; did you mean to use '!'?

Aucun commentaire:

Enregistrer un commentaire