The object has a different class after archiving / disassembling

I am working on an Objective-C codebase for an iPad project using iOS 6.

After I reorganized the class name 'ClassA' into 'ClassB', I found the following test failure:

NSData *encodedObject = [NSKeyedArchiver archivedDataWithRootObject:objectOfClassB]; ServiceOrderOld *decodedObject = [NSKeyedUnarchiver unarchiveObjectWithData:encodedObject]; [[[decodedObject class] should] equal:[objectOfClassB class]]; 

The error message I get reads: "[FAILED], expected to equal ClassB, get ClassB"

What can cause this strange behavior? Any debugging tips?

+4
source share
2 answers

I hope I'm not too late;)

I had the same problem when testing the framework. It turns out that the class in question was also in the test target. I think that then this is a mismatch (but compilation!) With the framework class. I removed the class from the test target and passed the test.

+1
source

It seems that the class really has nothing to do with the archiving mechanism. Did you try to just throw the class when unpacking?

 DesiredClass *object = (DesiredClass*) [NSKeyedUnarchiver unarchiveObjectWithData:encodedObject]; 
0
source

Source: https://habr.com/ru/post/1441743/


All Articles