亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

objective-c - NSException與NSError區(qū)別?
怪我咯
怪我咯 2017-04-21 11:15:57
0
1
492

NSException與NSError在使用中有哪些區(qū)別?

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[])
{
    
    @autoreleasepool {
        NSException* ex = [[NSException alloc]initWithName:@"MyException"  
                                                    reason:@"b==0"   
                                                  userInfo:nil];  
        
        @try   
        {  
            int b = 0;   
            switch (b)    
            {  
                case 0:  
                    @throw(ex);//b=0,則拋出異常;  
                    break;  
                default:  
                    break;  
            }  
        }  
        @catch (NSException *exception)//捕獲拋出的異常   
        {  
            NSLog(@"exception.name= %@" ,exception.name);
            NSLog(@"exception.reason= %@" ,exception.reason);
            NSLog(@"b==0 Exception!");  
        }  
        @finally   
        {  
            NSLog(@"finally!");  
        }  
        [ex release];  
        
    }
    return 0;
}

https://developer.apple.com/library/m...

https://developer.apple.com/library/m...

怪我咯
怪我咯

走同樣的路,發(fā)現(xiàn)不同的人生

reply all(1)
小葫蘆

Exceptions and errors are two completely different things. If an exception is thrown but you don't catch it, it will crash. But if an error is returned, you can do whatever you want to the outside world. It just tells you that there is an error in this call.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template