2013-04-06 44 views
-3

我在我的xcdatamodeld中有名爲Event的核心數據實體,具有2個屬性:titledate。我也有一個arrayController設置爲實體模式與Event實體(通過接口生成器完成)。我想使用代碼訪問arrayController中的對象的屬性。我怎樣才能做到這一點?在代碼中使用核心數據 - Objective-C/Cocoa

+0

您可以嘗試閱讀[核心數據的代碼片段](HTTP: //developer.apple.com/library/mac/#documentation/DataManagement/Conceptual/CoreDataSnippets/Introduction/Introduction.html#//apple_ref/doc/uid/TP40008285)文檔。 – 2013-04-06 21:04:23

回答

0
arrayController.arrangedObjects[index].title = newValue; 
1

我同意其他海報關於核心數據的一些文檔。 大書呆子牧場書籍是一個非常好的起點,如果你發現在線文檔勢不可擋(時間到了)。

xcdatamodel從菜單中選擇你的Event實體,然後執行: Editor > Create NSManaagedObject Subclass

然後,你可以這樣做: Event *event = [arrayController.arrangedObjects[index]]; event.title = newValue or [event setTitle];