Since
NSKeyedUnarchiver.unarchiveTopLevelObjectWithData
has been deprecated as of macOS 14.0 I am trying to load legacy NSCoder archives now using NSSecureCoding set in the class and using:
coder.unarchivedObject(ofClasses classes: [AnyClass], from data: Data)
to load the archive. The archive loads and most of the class members can be extracted. However, Swift Arrays always come out nil even though
coder.containsValue(forKey:)
returns true. The arrays were encoded with:
var pageUsesClearBackground: Array<Bool> = [true, true, true, true]
coder.encode(pageUsesClearBackground, forKey: "CB_KEY")
Using:
pageUsesClearBackground = coder.decodeObject(forKey: "CB_KEY") as? Array<Bool>
Brings back an array with 0 values, even though if I use the non NSSecureCode version, the Array is populated.
pageUsesClearBackground [Bool] 0 values
I suspect this has something to do with Arrays in Swift are a struct and do not conform to NSCoding. Odd that it worked encoding and decoding them for years. Any idea how to retrieve class members that are Arrays from an archive made before NSSecureCoding?
Apparently, NSSecureCoding is so secure you can't even get the data back.
6
0
2.2k