Quantcast
Channel: Active questions tagged crash - Stack Overflow
Viewing all articles
Browse latest Browse all 7199

App crashes on fetching dictionary from UserDefaults Swift

$
0
0

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.

enter image description hereenter image description here

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.


Viewing all articles
Browse latest Browse all 7199

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>