throwing an exception in objective-c/cocoa

后端 未结 13 1647
耶瑟儿~
耶瑟儿~ 2020-11-29 15:01

What\'s the best way to throw an exception in objective-c/cocoa?

13条回答
  •  臣服心动
    2020-11-29 15:18

    I think to be consistant it's nicer to use @throw with your own class that extends NSException. Then you use the same notations for try catch finally:

    @try {
    .....
    }
    @catch{
    ...
    }
    @finally{
    ...
    }
    

    Apple explains here how to throw and handle exceptions: Catching Exceptions Throwing Exceptions

提交回复
热议问题