I am trying to save data by NSUserDefaults . Here is my code
@IBAction func saveBtn(sender: AnyObject) {
var userName = nameLbl.text
UserInfo.append(User(name: userName))
NSUserDefaults.standardUserDefaults().setObject(UserInfo, forKey: "UserInfo")
userName = ""
}
But when i click on save button, it is showing Attempt to set a non-property-list object . I think, UserInfo array need to convert as NSData . Please tell me how can i do that?
NSKeyedArchiveras one solution.