1

I would like to subclass NSException and use it in my app for the application specific errors or exceptions.

Is it right way to do so? If YES, how to do it in a better way. If NO, why it is not the right way and whats the alternate for it?.

Please guide me !

Thanks.

4

1 回答 1

3

Do not use exceptions for recoverable errors.

So, yes, there is a better way. Exceptions should only be used for fatal errors. Other kinds of error handling is done via the NSError** pattern.

CodaFi's answer (Is it a good practice to subclass from NSException for app-specific exceptions?) has more details.

于 2013-05-20T15:43:18.947 回答