【发布时间】:2023-03-10 08:47:01
【问题描述】:
出于某种原因,我需要显示错误本地化失败原因。我收到 NSError
Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (Unexpected end of file while parsing object.) UserInfo=0x178a72b80 {NSDebugDescription=Unexpected end of file while parsing object.}
当我尝试登录时
[error localizedFailureReason]
为此我得到了空值。我可以知道是什么原因造成的吗?我只是得到
The operation couldn’t be completed. (Cocoa error 3840.)
为
[error localizedDescription] only
下面是我完整的方法代码:
+(NSDictionary *)insertErrorIntoFormat:(NSError*)error{
NSLog(@"1.%@",[error localizedDescription]);
NSLog(@"2.%@",[error description]);
NSLog(@"3.%@",[self getCurrentDateTimeString]);
NSDictionary *threat = [NSDictionary dictionaryWithObjectsAndKeys:
[self getCurrentDateTimeString], kTimestamp,
[error localizedDescription], @"logs",
[error localizedFailureReason], @"reason",
nil];
return threat;
}
【问题讨论】: