Keyed Archiverクラスを初めて使用しようとしていますが、この単純なテスト(OCUnit)の最後のアサートに失敗しています。
- (void) testNSCoding
{
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:5];
[dict setObject:@"hello" forKey:@"testKey"];
NSMutableData* data = [NSMutableData data];
NSKeyedArchiver *ba = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];
[ba encodeRootObject:dict];
[ba finishEncoding];
STAssertTrue(data.length != 0, @"Archiver gave us nothing.");
NSKeyedUnarchiver *bua = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];
id decodedEntity = [bua decodeObjectForKey:@"root"];
[bua finishDecoding];
STAssertNotNil(decodedEntity, @"Unarchiver gave us nothing.");
}
アーカイバがアーカイブ中であることを確認しました。問題はアーカイブ解除に存在すると想定しています。Archives and Serializations Guideによると、Unarchiverの使用方法に問題があるのではないかと思います。
ありがとう!