Objective-c – throwing an exception in objective-c/cocoa

cocoaexception handlingobjective c

What's the best way to throw an exception in objective-c/cocoa?

Best Answer

I use [NSException raise:format:] as follows:

[NSException raise:@"Invalid foo value" format:@"foo of %d is invalid", foo];