Every time I run the app, and then re-run it, it saves the same items into the NSUserDefaults
even if it is already there.
I tried to fix that with contains
code, but it hasn't worked.
What am I missing?
for days in results! {
let nD = DayClass()
nD.dayOfTheWeek = days[“D”] as! String
let defaults = NSUserDefaults.standardUserDefaults()
if var existingArr = defaults.arrayForKey("D") as? [String] {
if existingArr.contains(days["D"] as! String) == false {
existingArr.append(nd.dayOfTheWeek)
}
} else {
defaults.setObject([nD.dayOfTheWeek], forKey: "D")
}
}