私はこのコード(保存中のiphone Core Data Unresolvedエラーから)を使用して、NSErrorオブジェクトのより詳細な説明を出力しています:
- (NSString*)debugDescription
{
NSMutableArray* errorLines = [NSMutableArray array];
[errorLines addObject:[NSString stringWithFormat:@"Failed to save to data store: %@", [self localizedDescription]]];
NSArray* detailedErrors = [[self userInfo] objectForKey:NSDetailedErrorsKey];
if (detailedErrors != nil && [detailedErrors count] > 0)
{
for (NSError* detailedError in detailedErrors)
{
// The following line crashes the app
[errorLines addObject:[NSString stringWithFormat:@" DetailedError: %@", [detailedError userInfo]]];
}
}
else
{
[errorLines addObject:[NSString stringWithFormat:@" %@", [self userInfo]]];
}
return [errorLines description];
}
問題は、ネストされたNSErrorのuserInfoオブジェクトにアクセスしようとすると、アプリがEXC_BAD_ALLOCでクラッシュすることです。
問題のエラーは、新しいNSManagedObjectを作成し、それにデータを入力すると生成されます。オブジェクトに割り当てているすべてのプロパティは、割り当てられているものをすべて保持していますが、何かが正しく保持されていないようです。
どうすればこれを追跡できますか?NSZombieEnabledは私に有用なことを何も教えてくれませんでした。