I have a NSMutableArray and NSString I want to Archive these and also want to retrieve array and string with out change data inside the array and string.
I given like this,
for Archive,
NSMutableData *data = [[NSMutableData alloc]init];
NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];
[archiver encodeObject:arrayRandomNumberForUser forKey:@"array"];
[archiver encodeObject:stringBingo forKey:@"string"];
[archiver finishEncoding];
for UnArchive,
NSData *data=match.matchData;
NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];
mutableArray = [unarchiver decodeObjectForKey:@"array"];
stringtakenValue = [unarchiver decodeObjectForKey:@"string"];
[unarchiver finishDecoding];
Where, match.matchData is an NSData object getting from gamecenter take turn method.
When called the take turnMethod it is crashed. Here is the Console window error message.
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: ' -[NSXPCEncoder encodeObject:forKey:]: This coder only encodes objects that adopt NSSecureCoding (object is of class 'NSKeyedArchiver').'