Use a method that can't throw a objc exceptino to read the queue items from disk.

This commit is contained in:
Damiano Galassi committed 2019-02-08 14:56:18 +01:00
1 parent db374f209f
commit 0b26e50d41
1 file changed
+8 -4
+8 -4
View File
@@ -42,13 +42,17 @@ class Queue {
workQueue = DispatchQueue(label: "org.subler.WorkQueue")
arrayQueue = DispatchQueue(label: "org.subler.SaveQueue")
if let data = try? Data(contentsOf: url) {
do {
let data = try Data(contentsOf: url)
let unarchiver = NSKeyedUnarchiver(forReadingWith: data)
unarchiver.requiresSecureCoding = true
items = unarchiver.decodeObject(of: [NSArray.classForCoder(), NSMutableArray.classForCoder(), QueueItem.classForCoder()], forKey: NSKeyedArchiveRootObjectKey) as! [QueueItem]
if let decodedItems = try unarchiver.decodeTopLevelObject(of: [NSArray.classForCoder(), NSMutableArray.classForCoder(), QueueItem.classForCoder()], forKey: NSKeyedArchiveRootObjectKey) as? [QueueItem] {
items = decodedItems
} else {
items = Array()
}
unarchiver.finishDecoding()
} else {
} catch {
items = Array()
}