NSKeyedUnarchiver unarchiveObjectWithData crash - there is no way to catch an exception?

I have the following code:

@try { NSSet *set = [NSKeyedUnarchiver unarchiveObjectWithData:mData]; } @catch (NSException *exception) { // Use default data } 

At some point, it seems that I was not archived correctly, and mData corrupted. This gives me the following error:

 Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSKeyedUnarchiver initForReadingWithData:]: incomprehensible archive (0x14, 0xffffff9a, 0xffffffd0, 0x1d, 0x9, 0x3d, 0x43, 0x3)' *** Call stack at first throw: 

If the try / catch block does not work, how can I check the exception here? Shouldn't that work?

Thanks.

+6
source share
1 answer

I do not think the try-catch code did not work. The log says an โ€œuncaught exceptionโ€, so this error happens somewhere else in your code.

+1
source

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


All Articles