Hullo,
I would like to remove a warning when unarchiving objects so I tried to implement:
func retrieveRepository(componentName:String, ofClass: AnyClass<NSObject, NSCoding>)->Any?{
let fileUrl = getDocumentsDirectory().appendingPathComponent(componentName)
do{
let rawdata = try Data(contentsOf: fileUrl)
let optionalQueue = try NSKeyedUnarchiver.unarchivedObject(ofClass: ofClass, from:rawdata)
return optionalQueue
} catch {
return nil
}
}
On the ground unarchiveObject needs the name of the class where to unarchive that must adopt both NSObject and NSCoding. Yet this implementation is synthetically wrong. How to correctly implement it instead?
Thanks, Fabrizio
I tried to remove a warning.