0
votes

I have two entities as follows

Item <----->> Categories

Each item may have multiple categories.

For e.g. There are 5 items each have a sort category as release_Date. I want to sort all these 5 items based on the release_Date with the table view header as the release_Date value of each item.

I want to sort these items based on the category value selected by the user from the popover. Also I want to display the sorted objects in a sectioned table view with the table header being the category values selected.

I am using nsfetchedresultscontroller for this. I am able to sort the items based on the name of the items. But I am finding no luck in sorting them using the relationship attribute.

Any kind of help is appreciable.

1

1 Answers

0
votes

if i understand your model correctly you can do this with multiple sort descriptors pretty easily.

NSSortDescriptor *sortDescriptor1 = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:NO];
NSSortDescriptor *sortDescriptor2 = [[NSSortDescriptor alloc] initWithKey:@"Categories.release_Date" ascending:NO];
NSArray *sortDescriptors = @[sortDescriptor1, sortDescriptor2];

[fetch setSortDescriptors:sortDescriptors];