I am trying to achieve something like this in objective c.
@try{
//some code that will raise exception
}
@catch(CustomException e){//How to create this
//cat
In the simplest case, I can declare a class using...
@interface CustomException : NSException
@end
@implementation CustomException
@end
...and the code is very much like what you posted:
@try{
@throw [[CustomException alloc] initWithName:@"Custom" reason:@"Testing" userInfo:nil];
}
@catch(CustomException *ce){
NSLog(@"Caught custom exception");
}
@catch(NSException *e){
NSLog(@"Caught generic exception");
}