Reputation: 7317
I'm working on an Objective-C code base for an iPad project using iOS 6.
After I refactored the name of class 'ClassA' to 'ClassB', I find the following test failing:
NSData *encodedObject = [NSKeyedArchiver archivedDataWithRootObject:objectOfClassB];
ServiceOrderOld *decodedObject = [NSKeyedUnarchiver unarchiveObjectWithData:encodedObject];
[[[decodedObject class] should] equal:[objectOfClassB class]];
The error message I get reads: "[FAILED], expected subject to equal ClassB, got ClassB"
What could be causing this strange behaviour? Any tips on debugging this?
Upvotes: 4
Views: 371
Reputation: 1174
I hope I'm not too late ;)
I had the same problem while testing a framework. It turns out that the class in question was also in the test's target. I think it then mismatch (but compile!) with the framework's class. I removed the class from the test's target and the test passes.
Upvotes: 1
Reputation: 80271
It seems class is really irrelevant for the archiving mechanism. Did you try just re-casting the class when you unarchive?
DesiredClass *object = (DesiredClass*) [NSKeyedUnarchiver
unarchiveObjectWithData:encodedObject];
Upvotes: 0