1
我使用這個代碼(從iphone Core Data Unresolved error while saving)以打印NSError對象的更詳細的描述:印刷USERINFO拋出EXC_BAD_ALLOC
- (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沒有告訴我任何有用的東西。
跑到完全相同的錯誤,感謝您張貼此 – Mortoc 2011-08-28 23:00:11