Sort by object name in NSFetchRequest

I have a resulting result controller that should display all the elements of a specific object that has multiple subtitles.

The sections in the resulting result controller should be based on the name of the entity, i.e. which subtitle belongs to the element. Setting sectionNameKeyPath to @"entity.name" works.

However, it seems impossible to get the correct sort descriptor for the select query. Things like [NSSortDescriptor sortDescriptorWithKey:@"entity.name" ascending:YES] lead to errors like keypath entity.name not found in entity Something .

+6
source share
1 answer

Try using [NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES]; You do not need the previous element, since the property is already defined by the select query. See Also Description of the descriptor description class .

+3
source

Source: https://habr.com/ru/post/891051/


All Articles