I have a class that serializes and deserializes using NSCoder / NSKeyedArchiver and NSKeyedUnarchiver . I have unit tests that are designed to test my handling of various errors inside my serialization format (which is not a simple archive, but contains archives).
However, since I upgraded to Swift 2 / iOS 9, tests show unusual behavior. Previously, the invalid archive test failed because deserializing the invalid archive raised an Objective-C exception as the state of the documents that crashed the program because Swift could not catch them. This is great, I decided to fix the test at some point in the future.
Now the test passes. When I fed my random or deterministic garbage, instead of unarchiveObjectWithData return nil back from unarchiveObjectWithData . I checked the docs for this method and there were no behavior changes.
Honestly, I believe that such a change in behavior is extremely suspicious, since there is no mention of how and why this change occurred. My previously failed unit tests are only now passing for no apparent reason.
So, is this the new expected behavior (which returns nil )? If not, how can I get the actual expected behavior (Obj-C exception) and not nil for an invalid archive?
source share