Pregunta

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?

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top