Instance Method

initWithDomain:code:userInfo:

Returns an NSError object initialized for a given domain and code with a given userInfo dictionary.

Declaration

- (instancetype)initWithDomain:(NSErrorDomain)domain code:(NSInteger)code userInfo:(NSDictionary<NSErrorUserInfoKey, id> *)dict;

Parameters

domain

The error domain—this can be one of the predefined NSError domains, or an arbitrary string describing a custom domain. domain must not be nil. See Error Domains for a list of predefined domains.

code

The error code for the error.

dict

The userInfo dictionary for the error. userInfo may be nil.

Return Value

An NSError object initialized for domain with the specified error code and the dictionary of arbitrary data userInfo.

Discussion

This is the designated initializer for NSError.

See Also

Creating Error Objects

+ errorWithDomain:code:userInfo:

Creates and initializes an NSError object for a given domain and code with a given userInfo dictionary.