JohnEstropia / CoreStore

Unleashing the real power of Core Data with the elegance and safety of Swift
MIT License
4k stars 254 forks source link

Displaying nested sections #307

Closed eraydiler closed 5 years ago

eraydiler commented 5 years ago

Hello, I need to display some data in nested sections like;

Section -SubSection --Item --Item Section -SubSection --Item -SubSection --Item --Item --Item ...

Also need to track any changes and reflect them in the UI with listmonitor.

I found this question with a coredata related solution; https://stackoverflow.com/questions/37203272/nested-sections-in-uitableview-and-core-data

When I tried to apply it with CoreStore, I couldn't give multiple arguments to list monitor's sectionBy(...). which matches with groupBy in coredata as far as I can understand. Is there a way to apply coredata solution mentioned in the link with CoreStore? Or do I need something else to represent items in nested sections like the sketch above?

JohnEstropia commented 5 years ago

You'll need to process the indexPaths for the second-level sections yourself. NSFetchedResultsController, which ListMonitor runs on top of, was designed for UITableViews and UICollectionViews, which support only one level of sectioning.

The stackoverflow thread you linked gave an answer that throws out NSFetchedResultsController altogether and simply queries the store for an array of Dictionarys. What it doesn't say is it would still return just the first-level sections and not the inner section. You will still need to process the second-level sections by hand.

eraydiler commented 5 years ago

Got it, thanks for the answer.