Hi, I have very frustrating problem.
When I try to release NSKeyedUnarchiver object after decoding an NSArray, "EXC_BAD_ACCESS" error occurs.
But when I don't release it or decode other object (e.g. NSString) everything go well.
I don't understand it... For me, it looks like "decodeObjectForKey" method changes something in "decoder" object (but not allways?!). And in debugger, the only variable which changes after calling this method is "_replacementMap". But I have no idea how to fix this bug.
I hope you can help me.
Here is sample code:
+ (NSArray *)decodeArticles {
NSString *archivePath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"Articles.archive"];
NSData *decoderData = [[NSData alloc] initWithContentsOfFile:archivePath];
NSKeyedUnarchiver *decoder = [[NSKeyedUnarchiver alloc] initForReadingWithData:decoderData];
NSArray *savedArticles = [[decoder decodeObjectForKey:@"articles"] copy];
if (!savedArticles) {
savedArticles = [[NSArray alloc] init];
}
[decoder finishDecoding];
//[decoder release];
return savedArticles;
}