Uploaded image for project: 'Realm Cocoa SDK'
  1. Realm Cocoa SDK
  2. RCOCOA-2295

Sectioned Results with Empty Sections

      Problem

      Sometimes you need to have a sectioned UITableView that shows a section even if there are no cells in that section. The current behavior of SectionedResults is that it only has a section if there is an object in that section. If you try to use multiple Results with observers, you'll end up with NSInternalInconsistencyException}}s. It triggers the table to update for one section before the other, but it still compares the before and after counts of all sections in the update for the one. Also, if you try to force an "empty" section with {{SectionedResults, the observation updates will be inconsistent and impossible to manage.

      Solution

      It would be great to be able to supply either an array of sections, or use another query to define the sections.

      Alternatives

      I have three different workarounds, which none of them are great.

      1. One UITableView with SectionedResults and hard-coded sections.

      Hard-code the number of sections, observe changes, and hard-reload UITableView. The problem is that you can't use batch updates, because the section insert/deletion updates don't match the hard-coded sections. It's also not enough to ignore the section insertion/deletion updates, because row updates are also not always consistent and it causes UITableView to raise NSInternalInconsistencyException.

      1. One UITableView with two Results.

      Use one Results per section. This doesn't work, and if I understand correctly is the reason that SectionedResults exists. Responding to changes in one section causes the counts to be checked in other sections, before those changes are processed, and UITableView raises NSInternalInconsistencyException.

      1. Two UITableView with two Results.

      Position multiple UITableViews into a single UIScrollView, each with their own Results. This is the only one that doesn't crash because it follows the intended use case of Results. However, now you have to deal with correctly sizing multiple UITableViews in a view, which is also a pain. At least it doesn't crash though!

      How important is this improvement for you?

      I would like to have it but have a workaround

      Feature would mainly be used with

      Local Database only

            Assignee:
            nikola.irinchev@mongodb.com Nikola Irinchev
            Reporter:
            unitosyncbot Unito Sync Bot
            AD SDK Team 2
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: