iphone: try end try

后端 未结 3 1184
-上瘾入骨i
-上瘾入骨i 2020-12-04 03:53

Is there in objective-C any way to see if it is possible to do a certain task without risking crash the application?

Other languages like javascript have

         


        
3条回答
  •  悲哀的现实
    2020-12-04 04:57

    Have a look at Exception Handling :

    Cup *cup = [[Cup alloc] init];
    
    @try {
        [cup fill];
    }
    @catch (NSException *exception) {
        NSLog(@"main: Caught %@: %@", [exception name], [exception reason]);
    }
    @finally {
        [cup release];
    }
    

    Also worth to have a look: Error Handling Programming Guide

提交回复
热议问题