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") workQueue = DispatchQueue(label: "org.subler.WorkQueue")
arrayQueue = DispatchQueue(label: "org.subler.SaveQueue") 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) let unarchiver = NSKeyedUnarchiver(forReadingWith: data)
unarchiver.requiresSecureCoding = true unarchiver.requiresSecureCoding = true
if let decodedItems = try unarchiver.decodeTopLevelObject(of: [NSArray.classForCoder(), NSMutableArray.classForCoder(), QueueItem.classForCoder()], forKey: NSKeyedArchiveRootObjectKey) as? [QueueItem] {
items = unarchiver.decodeObject(of: [NSArray.classForCoder(), NSMutableArray.classForCoder(), QueueItem.classForCoder()], forKey: NSKeyedArchiveRootObjectKey) as! [QueueItem] items = decodedItems
} else {
items = Array()
}
unarchiver.finishDecoding() unarchiver.finishDecoding()
} else { } catch {
items = Array() items = Array()
} }