开发者

Data model for folders in Core Data

开发者 https://www.devze.com 2023-03-02 01:33 出处:网络
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:

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

精彩评论

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