Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSKeyedUnarchiver unarchiveObjectWithData crashes - No way to catch the 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 wasn't archiving properly and mData is 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 a try/catch block does not work, how am I supposed to check for an exception here? Shouldn't it be working?

Thank you.

like image 596
dimitrios Avatar asked Mar 21 '12 11:03

dimitrios


1 Answers

I don't think the try-catch code wasn't working. The log says "uncaught exception" so this error happens somewhere else in your code.

like image 112
George Avatar answered Oct 17 '22 15:10

George