NSKeyedArchiver error after cleaned a mistake

I tried to archive a NSDictionary with a NSColor :

data =  [NSKeyedArchiver archivedDataWithRootObject: <vrRoot> requiringSecureCoding:YES error:&error];

and I get this error :

Printing description of error: Error Domain=NSCocoaErrorDomain Code=4864 "value for key 'NS.objects' was of unexpected class 'NSColor' (0x7ff8465d0d88) [/System/Library/Frameworks/AppKit.framework]. Allowed classes are: {( "'NSMutableDictionary' (0x7ff8465f9b48) [/System/Library/Frameworks/CoreFoundation.framework]" )}" UserInfo={NSDebugDescription=value for key 'NS.objects' was of unexpected class 'NSColor' (0x7ff8465d0d88) [/System/Library/Frameworks/AppKit.framework]. Allowed classes are: {( "'NSMutableDictionary' (0x7ff8465f9b48) [/System/Library/Frameworks/CoreFoundation.framework]" )}}

Then I transferred NSColor to NSArray - but the error was the same. I want data save in Core Data, please help me ♡.

Replies

You’ve opted in to secure coding — which is a good thing, to be clear — and that requires that you tell the coder what classes you expect to find in the archive. The NSSecureCoding protocol docs has a link to a doc that explains how to do this.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"