记录NSError的最佳方式是什么
- (void)checkThing:(Thing *)thing withError:(NSError *)error {
NSLog(@"Error: %@", error);
}给我一条null消息
发布于 2009-10-13 11:29:18
查看NSError文档后,我发现您需要执行以下操作:
NSLog(@"%@",[error localizedDescription]);这将为您提供人类可读的输出
发布于 2009-10-13 10:20:17
NSLog(@“错误:%@",error);
给我一条空消息
则error是nil,而不是NSError实例。
发布于 2009-10-13 17:01:54
这是我在开发时用来记录错误的粗略方法;(不适用于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负责显示错误。
https://stackoverflow.com/questions/1559169
复制相似问题