I have a custom class called
Person
that stores various attributes about someone when they enter information.class Person {
var name: String?
var age: String?
var html_url: String? init(json: NSDictionary)
{
self.name = json["name"] as? String
self.age = json["age"] as? String
self.html_url = json["html_url"] as? String /
}
}
Once the dictionary is created, it is then placed into an array. I am having problems saving the array into
NSUserDefaults
when a button is tapped.personArray.append(newPerson)
NSUserDefaults.standardUserDefaults().setObject(personArray, forKey: "personArray") NSUserDefaults.standardUserDefaults().synchronize()
Would anyone be able to help me actually save an array of custom objects (custom dictionaries) via NSUserDefaults?