NSKeyedUnarchiver에서 이상한 동작이 나타났습니다.NSKeyedUnarchiver가 예상대로 작동하지 않습니다.
NSMutableData *myData = [ NSMutableData data ];
NSKeyedArchiver *archiver = [[ NSKeyedArchiver alloc ] initForWritingWithMutableData:myData ];
NSString *testString = [ NSString stringWithString:@"Hello World!" ];
[ archiver encodeObject:testString forKey:@"test" ];
[ archiver finishEncoding ];
하고 나는 그것을 보관 해제하려면 :
내가이 예를 들어, 난 그냥 문자열을 사용하는 데이터를 보관. 내가
를 사용하는 경우 I는 전무 결과를 얻을 수 있지만, 내가 사용하는 경우 :
NSKeyedUnarchiver *unarchiver = [[ NSKeyedUnarchiver alloc ] initForReadingWithData:myData ];
NSString *result = [ unarchiver decodeObjectForKey:@"test" ];
나는 다시 내 문자열을 얻을. 이제 [NSKeyedUnarchiver unarchiveObjectWithData : myData]는 [[NSKeyedUnarchiver alloc] initForReadingWithData : myData]에 대한 편리한 메소드 일 뿐이지 만 그런 식으로 행동하지 않는 것 같습니다. 내가 잘못.
감사 레자