iphone - Crashed while using NSKeyedArchiver -
i have nsmutablearray , nsstring want archive these , want retrieve array , string out change data inside array , string.
i given 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 nsdata object getting gamecenter take turn method.
when called take turnmethod crashed. here console window error message.
terminating app due uncaught exception 'nsinvalidargumentexception', reason: ' -[nsxpcencoder encodeobject:forkey:]: coder encodes objects adopt nssecurecoding (object of class 'nskeyedarchiver').'
i not sure think unarchiver returns nsarray, not nsmutablearray. try
mutablearray = [[unarchiver decodeobjectforkey:@"array"] mutablecopy];
Comments
Post a Comment