@try {
//Do something which might raise an exception
}
@catch (NSException *exception) {
//Handle the exception. E.g.: Show alert
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:[exception name]
message:[exception reason] delegate:self
cancelButtonTitle:@”Ok” otherButtonTitles: nil];
[alert dismissWithClickedButtonIndex:0 animated:TRUE];
[alert show];
[alert release];
//return;
}
Raise the exception by :
[NSException raise:name format:@"%@", reason]; Also has:@finally