Error of Unexpected class while encode/decode an NSArray with NSSecureCoding
NSCoder
provides an additional method decodeObjectOfClasses:forKey:
, where a set of expected objects could be passed. This allows to decode nested structures.
Just pass a set with the NSArray
and your ClassA
and ClassB
class:
NSSet *classes = [NSSet setWithObjects:[NSArray class], [ClassA class] ,[ClassB class], nil];
NSArray* array = [unarchiver decodeObjectOfClasses:classes forKey:@"AirdropDataKey"];