Tuesday, 6 August 2013

Try-Catch Error Objective C

Try-Catch Error Objective C

I am trying to get Captions from a given instagram picture, however if
there is no caption the app throws an exception and crashes. How would I
implement @try and @catch to do this. Here is what i have so far:
@try {
RNBlurModalView *modal = [[RNBlurModalView alloc]
initWithViewController:self title:[NSString
stringWithFormat:@"%@",entry[@"user"][@"full_name"]] message:[NSString
stringWithFormat:@"%@",text[@"caption"][@"text"]]];
[modal show];
}
@catch (NSException *exception) {
NSLog(@"Exception:%@",exception);
}
@finally {
RNBlurModalView *modal = [[RNBlurModalView alloc]
initWithViewController:self title:[NSString
stringWithFormat:@"%@",entry[@"user"][@"full_name"]] message:[NSString
stringWithFormat:@"%@",text[@"caption"][@"text"]]];
[modal show];
}

No comments:

Post a Comment