0

I am wondering how to solve my problem.

I have:

  • Entity A: Advertisers
  • Entity B: Offers

I have some Advertisers with many offers (1:n relation) and Advertisers without offers. Finally, each offer has a price.

I have a UITableView with two sections - Advertisers with offers - Advertisers without offers

The difficulty comes now, the user can add a filter on the price. When a user set a max price at x, then the Advertisers without offers with a price less than x should not appear in the first section anymore.

First, I was thinking to set the sort descriptor and section name to a parameter "HasOffers". So first section would be hasOffers=1 and second section hasOffers=0. However when dealing with the offer price filter my solution does not fit anymore.

Someone has an idea?

  • Are you having `hasOffers` attributes in `Advertisers` entity with value 1 and 2? – Nirav D Mar 21 '17 at 12:40
  • Use two nsfetchedresultscontrollers; one for each section – Paulw11 Mar 21 '17 at 12:45
  • @NiravD yep I do. When I create the entity instances, I set the attribute. It is then not transient as the core data concept allows only not transient attribute as sort descriptor. – Jean-Philippe Mar 21 '17 at 13:13
  • @Paulw11 I already tried that, it's just that it's not that simple to handle modification of context with this scheme. I mean, when the context notify that there is one more result in one of the two `nsfetechedresultcontroller`, how do you know if you need to add it in the first or second section of the tableview? – Jean-Philippe Mar 21 '17 at 13:14
  • 2
    The fetchedresultcontroller instance is passed to the delegate method, so simply check which results controller it is and update the appropriate table section. – Paulw11 Mar 21 '17 at 13:16

0 Answers0