IOS NSError with a global handler

I am starting to program an iOS application. After reading Apple's guidelines on how to deal with bugs, I got the following most important points:

  • Exceptions for programmers
  • Use NSErrorfor user

Now NSErrorusually passed as an external argument, which can then be used internally and must be verified by the caller. However, I ask myself if it is useful to use a global error handler, say, singleton, which wraps around NSErrorand can be used to trigger errors and handle errors from the called function.

Is there anything against this method or will it be bad practice?

+4
source share
4 answers

MacOS X has the concept of an error responder chain , which is an unofficial protocol that propagates errors in the responder chain until they are processed. For some reason, this is not implemented in Cocoa on iOS, but there are several third-party implementations:

Errorkit

ios-presentError

There are a few more.

This approach is very flexible, well-documented, is the best practice in MacOS X, and it is generally preferable to use a singleton for this purpose.

+1
source

, "NSError " . NSErrors , . , , , .

0

, , - NSError. .

0

iOS "" ( iOS).

, . error:, (log/dump NSError) .

( , error: parm , , , . , , error: parm /.)

, NSError - .

0

All Articles