var arr = defaults.arrayForKey("kWeeks") as [WeekReport]?
if arr? {
var arr2 = arr!
arr2.append(report)
defaults.setObject(arr2, forKey: "kWeeks") // Crash
defaults.synchronize()
}
I try to set arr2
which will be the add after optional checking. But it crashes on setObject()
with error: EXC_BAD_ACCESS
Ive checked, with println()
and arr2
is not nil and contains the element which is appended in the sample above. And report
is of type WeekReport
.