What is the difference between @throw NSException
and NSException raise
? I wonder which one I should rather use (there is a proper use case to use one) and why?
From Apple docs,
An important difference between
@throw
andraise
is that the latter can be sent only to anNSException object
whereas@throw
can take other types of objects as its argument (such as string objects). Cocoa applications should @throw onlyNSException 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.
For further details you can refer the documentation.
© 2022 - 2024 — McMap. All rights reserved.