dimitrios
dimitrios

Reputation: 509

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.

Upvotes: 6

Views: 1572

Answers (1)

George
George

Reputation: 4029

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.

Upvotes: 1

Related Questions