我正在使用此代码(来自iphone Core Data Unresolved error while Saving)打印 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 没有告诉我任何有用的信息。