I want to do sectioning when displaying table views based on NSSet.

Asked 2 years ago, Updated 2 years ago, 105 views

This is my first time to ask a question.
It may be difficult to read, but please forgive me.

CoreData is trying to create a two-tier table view.

The data models are as follows:

·Main class
 Attribute Name, Category 1
 [Relationship] Details (Many)

·Detailed class
 Attribute Name, Category 2
 [Relationship] Main (1)

Table view in Tier 1 is the
automatically generated code.
in sectionNameKeyPath: on the NSFetchedResultsController I was able to divide it into sections by Category 1 of the main class.

Similarly, in Tier 2, I would like to section the detail class by Category 2.
I don't know how to handle the detail class obtained by NSSet from the main class.

I know how to sort it into NSArray, so
I can think of a simple way to loop and set it up, but

like NSFetchedResultsController in Tier 1 Please let me know if there is a way to make it into a two-dimensional array that is simply sectioned.

ios objective-c uitableview coredata

2022-09-30 14:48

1 Answers

The primary class is query for CoreData, so you can add sortDescriptor, compliance conditions, etc.

However, the detail class here is a set attached to the end of the main class query, so we have no choice but to use the NSSet method.

  • (NSArray*) sortedArrayUsingDescriptors:(NSArray*) sortDescriptors

It seems that sorting can be done by using .


2022-09-30 14:48

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.