throwing an exception in objective-c/cocoa

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

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

13条回答
  •  清歌不尽
    2020-11-29 15:22

    @throw([NSException exceptionWith…])
    

    Xcode recognizes @throw statements as function exit points, like return statements. Using the @throw syntax avoids erroneous "Control may reach end of non-void function" warnings that you may get from [NSException raise:…].

    Also, @throw can be used to throw objects that are not of class NSException.

提交回复
热议问题