oc 异常处理

#import <UIKit/UIKit.h>
#import "AppDelegate.h"

int main(int argc, char * argv[]) {
    
    @try {//可能要抛出的异常
        //手动写入异常
        @throw [NSException exceptionWithName:@"My Error" reason:nil userInfo:nil];
    }
    @catch (NSException *exception) {//捕抓到的异常
        NSLog(@"%@",exception);
    }
    @finally {//最终执行的块
        NSLog(@"run");
    }
}

 

posted @ 2015-08-19 14:27  netcorner  阅读(446)  评论(0编辑  收藏  举报