我有一個NSManagedObject的一些屬性在程序的開始初始化。當我稍後提到這個對象時,它看起來是錯誤的,並且這些屬性是不可訪問的。我不知道我需要做什麼。NSManagedObject Faulted
這與添加到程序中的新功能有關,該程序一直以其他方式使用核心數據平穩運行。
這裏是一個代碼片段,它被初始化爲單例的屬性值。 (這個單是我的代碼很多地方訪問):
favoritesCollection = [[SearchTerms alloc] initWithEntity:[NSEntityDescription entityForName:@"SearchTerms" inManagedObjectContext:moc] insertIntoManagedObjectContext:moc];
favoritesCollection.keywords = @"Favorites List";
favoritesCollection.isFavoritesCollection = [NSNumber numberWithBool:YES];
favoritesCollection.dateOfSearch = [NSDate NSCExtendedDateWithNaturalLanguageString:@"4000"];
favoritesCollection.pinColorIndex = 0;
[moc save:&error];
NSLog(@"(favoritesCollection) = %@", favoritesCollection);
}
return favoritesCollection;
當我看着favoritesCollection與NSLog的,我看到這個(我加了一些新行,以方便閱讀):
(favoritesCollection) =
<SearchTerms: 0x5c28820>
(entity: SearchTerms; id: 0x5a6df90
<x-coredata://3936E19F-C0D0-4587-95B6-AA420F75BF78/SearchTerms/p33> ;
data: {
dateOfSearch = "4000-09-25 12:00:00 -0800";...*more things after this*
返回後,另一個NSLog顯示內容完好無損。
當我提到這個例子後,我可以在調試器中看到這一點:
<SearchTerms: 0x5c28820>
(entity: SearchTerms; id: 0x5a6df90
<x-coredata://3936E19F-C0D0-4587-95B6-AA420F75BF78/SearchTerms/p33> ;
data: <fault>)
,這一切。
所以我相信該對象是保留的(我明確保留它返回的地方)。我有殭屍,它看起來不像殭屍。
我在程序中只有一個managedObjectContext,在單例中維護。
那麼發生了什麼事情,以及如何獲得已保存的屬性?