我有一個問題。何時真的可以訪問NSManagedObject?
我有一個名爲「mapController」的NSObjectController,我想在創建對象時放置一些默認值。我按照文檔中的建議,在我的文檔的windowControllerDidLoadNib方法中執行此操作。但是......
if (![mapController content]){ // No map defined yet.
[mapController add: self]; // This should create the instance.
NSLog(@"%@",[mapController content]); // Gives NULL.
我想:
BOOL ok = [mapController fetchWithRequest:nil merge:NO error:nil];
NSLog(@"%@",[mapController content]); // Gives NULL.
mapController的內容是在覈心數據「便箋」,但我不能訪問它。我必須這樣設置其屬性之一:
[[mapController content] setValue:[matrix colorReference] forKey:@"mapData"];
這給沒有錯誤,因爲更改的文件被標記,但我測試值:
NSLog(@"%@",[mapController content]); // Gives NULL.
當赫克它的控制器內容真的在這裏?屏幕上出現一些內容,但實際上是什麼?讀取文檔並不能幫助我......