Use a method that can't throw a objc exceptino to read the queue items from disk.
This commit is contained in:
1 file changed
+8
-4
+8
-4
@@ -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()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user