开发者

Data model for folders in Core Data

I'm trying to implement a folders and items data model in Core Data. It will be displayed in a table view. I'm using a "listItem" entity for the table view with these properties:

listItem
--------
isFolder (BOOL)
item (relationship to an Item)
folder (relationship to a Folder, if isFolder is true, otherwise nil)

My Folder and Item entities both have a name property and a dateCreated property. My Folder entity also has an "listItems" relationship containing more listItems. All listItems are contained in a parent Fold开发者_如何学Pythoner.

How can I ask a fetched results controller to use the name or dateCreated property to order the tableview, even though they are in different relationships? Do I have to make a copy of the name and dateCreated in listItem? Is there a better way to do this in Core Data? Thanks.


Just add an new property to your entry CreationDate and use an SortDescriptor to order them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜