@throw NSException vs NSException raise
Asked Answered
S

1

7

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?

Scan answered 14/2, 2014 at 9:27 Comment(0)
L
7

From Apple docs,

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.

For further details you can refer the documentation.

Liberec answered 14/2, 2014 at 9:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.