Intermittent data loss with background fetch - could NSKeyedUnarchiver return nil from the documents directory?
问题 I have a simple app that stores an array of my custom type (instances of a class called Drug ) using NSCoding in the app’s documents folder. The loading and saving code is an extension to my main view controller, which always exists once it is loaded. Initialisation of array: var drugs = [Drug]() This array is then appended with the result of the loadDrugs() method below. func saveDrugs() { // Save to app container let isSuccessfulSave = NSKeyedArchiver.archiveRootObject(drugs, toFile: Drug