object-c 的异常构造,并抛出

    @try {
        NSException *exception = [NSException exceptionWithName: @"HotTeaException"
                                                         reason: @"The tea is too hot"
                                                       userInfo: nil];
        @throw exception;
    }
    @catch (NSException *exception) {
        NSLog(@"main: Caught %@: %@", [exception name], [exception reason]);
    }
    @finally {
        NSLog(@"finally");
    }
 

你可能感兴趣的:(object)