gpt4 book ai didi

ios - @throw NSException 与 NSException 引发

转载 作者:可可西里 更新时间:2023-11-01 03:30:39 27 4
gpt4 key购买 nike

@throw NSExceptionNSException raise 有什么区别?我想知道我应该使用哪一个(有一个合适的用例来使用一个),为什么?

最佳答案

来自 Apple 文档,

An important difference between @throw and raise is that the latter can be sent only to an NSException object whereas @throw can take other types of objects as its argument (such as string objects). Cocoa applications should @throw only NSException objects.

Typically you throw or raise an exception inside an exception-handling domain, which is a block of code marked off by the @try compiler directive.

See “Handling Exceptions” for details.

Within exception handling domains you can re-propagate exceptions caught by local exception handlers to higher-level handlers either by sending the NSException object another raise message or by using it with another @throw directive.

更多详情可以引用documentation .

关于ios - @throw NSException 与 NSException 引发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21775432/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com