I have the app where I use UserDefaults to store a dictionary.
I can see that multiple users of my app experienced crashes. I can't reproduce that crash but I have logs showing me this:
Can anybody tell me what could be the cause of the issue by looking at the logs?
Thank you in advance.
That's how I set that dictionary:
var inspectionPDFUpdateTimes: Dictionary<Int, Date> = Dictionary<Int, Date>() { didSet { defaults.set(inspectionPDFUpdateTimes, forKey: .kInspectionPDFUpdateTimes) } }
That's how I retrieve it:
inspectionPDFUpdateTimes = getDictionary(key: UserDefaultsKeys.kInspectionPDFUpdateTimes.rawValue)private func getDictionary<X, Y> (key: String) -> Dictionary<X, Y> { guard let data = defaults.object(forKey: key) as? Data else { return emptyDict() } guard let decodedDict = NSKeyedUnarchiver.unarchiveObject(with: data) as? Dictionary<X, Y> else { return emptyDict() } return decodedDict }
Want to point out that it doesnt crash for everybody. I couldn't reproduce this crash on multiple devices. Also users tried to delete and reinstall the app. I assume this crash happens before it's loaded with any data.