small medium large xlarge

Back to: All Forums  Core Data
Generic-user-small
17 Dec 2011, 05:30
Sandeep Chayapathi (1 post)

Hi all, Im planning on using CoreData to model a “News” iOS app. This’ll have many sections (read tab UITabBarItem) which will contain many articles (in a UITableView). The articles might appear in other sections too. Also the sort order of each article is another important factor.

In database lingo I’d have . “Article” table . “Sections” table and a . “Article_Sections” table to map an article to a section with additional sort order field.

I have tried and can’t model this in CoreData. Im stuck with a “Section” class having a many-to-many relationship with a “Article” class (with an inverse many-to-many relationship to the “Section” class). However with this I don’t know how to derive the sort order.

Any hint on how to do this is very much appreciated. Thanks in advance.

Sandeep

Photo_10_pragsmall
26 Dec 2011, 20:30
Eimantas Vaiciunas (11 posts)

You should set sort descriptor (NSSortDescriptor) for fetch request or fetched results controller. However sort order per section should be stored somewhere outside of core data, because I believe your articles don’t have the hardcoded position in each section.

You must be logged in to comment