NSInvalidArgumentException not an exception type. This is the string that will be returned in the name property for an exception. Thus, you must catch your exception, and the name property does not match, you can return @throw exceptions that you are not going to handle, for example:
@try { // code that generates exception } @catch (NSException *exception) { if ([exception.name isEqualToString:NSInvalidArgumentException]) { // handle it } else { @throw; } }
For more information, see Exception Programming Topics .
I must admit that I share the concern of CodaFi that this is the misuse of exceptions. It's much better to program protection, check your parameters before you call Cocoa methods, and just make sure you don't throw exceptions in the first place. If you refer to the Working with Errors section of the Program using the Objective-C manual, the exceptions are for "programmer errors," and they say:
You should not use the try-catch block instead of the standard programming checks for Objective-C methods.
source share