I am having trouble with NSKeyedArchiver. I create an archive with
archive = [NSDictionary dictionaryWithObjectsAndKeys:
pruneTableP2, @"depth table",
nil];
archiveData = [NSKeyedArchiver archivedDataWithRootObject: archive
requiringSecureCoding: NO
error: nil];
I then get a "The data isn’t in the correct format" error when I go to unarchive it with unarchivedObjectOfClass:. The subsequent call to a depreciated method works however.
archive = [NSKeyedUnarchiver unarchivedObjectOfClass: [NSDictionary class]
fromData: fileData
error: &error];
if( archive == nil )
{
archive = [NSKeyedUnarchiver unarchiveObjectWithData: fileData];
NSLog( @"%@", [error localizedFailureReason]);
}
What am I doing wrong?
Can you show the details of
pruneTableP2
? Especially its type?It's an NSMutableData object.
pruneTableP2 NSConcreteMutableData * 274337280 bytes 0x00006000002b8120
I copied the pruneTableP2 into an NSData object and now unarchivedObjectOfClass: will read in the archive. It doesn't like NSMutableData. But now it throws out a couple of warnings.
2021-11-03 22:31:46.749411-0500 Cube Console[8846:238300] [general] *** -[NSKeyedUnarchiver validateAllowedClass:forKey:] allowed unarchiving safe plist type ''NSData' (0x1ed406558) [/System/Library/Frameworks/CoreFoundation.framework]' for key 'NS.objects', even though it was not explicitly included in the client allowed classes set: '{( "'NSDictionary' (0x1ed4065d0) [/System/Library/Frameworks/CoreFoundation.framework]" )}'. This will be disallowed in the future. 2021-11-03 22:31:46.749801-0500 Cube Console[8846:238300] [general] *** -[NSKeyedUnarchiver validateAllowedClass:forKey:] allowed unarchiving safe plist type ''NSString' (0x1ed434848) [/System/Library/Frameworks/Foundation.framework]' for key 'NS.keys', even though it was not explicitly included in the client allowed classes set: '{( "'NSDictionary' (0x1ed4065d0) [/System/Library/Frameworks/CoreFoundation.framework]" )}'. This will be disallowed in the future.