i am on objective-c, macOS.
I am currently rewriting an application to support NSSecureCoding Protocol.
In some classes i have some properties like this
@property id objectValue;
These objects can be of very dynamic kind (NSString, custom object ...)
On loading i did this before:
_objectValue = [coder decodeObjectForKey:@"objectValue"];
With NSSecureCoding i need to specify the class which i cannot do with id obviously.
So here are my questions:
Is it OK to pass a superclass like NSObject even if it's basically an NSString?
_objectValue = [coder decodeObjectOfClass:[NSObject class] forKey:@"objectValue"];
But... doesn't this counteract the idea of NSSecureCoding?
Is there another (better) approach?
Edit:
Just seen that this is possible with multiple classes decodeObjectOfClasses:forKey: - would the correct approach be to list all classes possible?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…