Information about an error condition including a domain, a domain-specific error code, and application-specific information.
- iOS 2.0+
- macOS 10.2+
- tvOS 9.0+
- watchOS 2.0+
Objective-C methods can signal an error condition by returning an
NSError object by reference, which provides additional information about the kind of error and any underlying cause, if one can be determined. An
NSError object may also provide localized error descriptions suitable for display to the user in its user info dictionary. See Error Handling Programming Guide for more information.
Methods in Foundation and other Cocoa frameworks most often produce errors in the Cocoa error domain (
NSCocoa); error codes for the Cocoa Error Domain are documented in the Foundation Constants. There are also predefined domains corresponding to Mach (
NSMach), POSIX (
NSPOSIXError), and Carbon (
Applications may choose to create subclasses of
NSError, for example, to provide better localized error strings by overriding