NSError

NSErro :错误域,错误码,错误信息

 NSError *error = [[NSError alloc] initWithDomain:@"错误域"
                                             code:0
                                         userInfo:@{NSLocalizedDescriptionKey:@"错误描述",
                                             NSLocalizedFailureReasonErrorKey:@"错误原因",
                                        NSLocalizedRecoverySuggestionErrorKey:@"解决建议"}];

//domain:错误域
NSString *domain = error.domain;
// code:错误码
NSInteger code = error.code;
//userInfo:错误信息(系统提供了很多Key,自己也可以定义)
NSDictionary *userInfo = error.userInfo;
FOUNDATION_EXPORT NSString *const NSLocalizedDescriptionKey;           
FOUNDATION_EXPORT NSString *const NSLocalizedFailureReasonErrorKey;    
FOUNDATION_EXPORT NSString *const NSLocalizedRecoverySuggestionErrorKey; 

你可能感兴趣的:(NSError)