[英]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.