Tableview with sections controlled by the result controller

I am very new to CoreData and need help on one issue. I have a table that simply lists the cities stored in SQLite db. The city is defined by the attributes "cityId" and "name".

Data is retrieved using NSFetchedResultsController, and everything works fine, except that I cannot figure out how to make FetchedResultsController to group cities by the first letter of city names.

When I put the "name" for the sectionNameKeyPath argument for the initWithFetchRequest: managedObjectContext: sectionNameKeyPath: cacheName: method, it creates a section for each city, which obviously I don’t want something. I cannot figure out how to create an expression that will allow it to work the way I need.

Thanks for any advice and / or advice on this.

Mattes

+3
source share

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


All Articles