[英]How can I view an NSError?
记录NSError
的最佳方法是什么?
- (void)checkThing:(Thing *)thing withError:(NSError *)error {
NSLog(@"Error: %@", error);
}
给我一个null
信息
NSLog(@"Error: %@", error);
给我一个空信息
然后error
是nil
,而不是NSError实例。
这是我用来在开发过程中记录错误的粗略方法; (不适用于Cocoa-touch)
// Execute the fetch request put the results into array
NSError *error = nil;
NSArray *resultArray = [moc executeFetchRequest:request error:&error];
if (resultArray == nil)
{
// Diagnostic error handling
NSAlert *anAlert = [NSAlert alertWithError:error];
[anAlert runModal];
}
NSAlert负责显示错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.