ListMonitor does not respect fetchLimit after inserts. #172

Closed
opened 2025-12-29 18:24:03 +01:00 by adam · 1 comment
Owner

Originally created by @zalogatomek on GitHub (Sep 27, 2017).

So, I have some ListMonitor, Where, ListObserver (self)

self.where = Where("name != nil")
self.monitor = CoreStore.monitorList(From<Person>(), self.where, OrderBy(.ascending("name")))
self.monitor.addObserver(self)

Then, I'm performing refetch() with Tweak:

self.tweak = Tweak({ (fetchRequest) in
                fetchRequest.fetchLimit = 10
            })
self.monitor.refetch([self.where, self.tweak])

Everything works as expected (in this scenario: 10 Person's entities with lowest name) but when in some other part of App I'm making inserts into Person, fetchLimit is not respected:

  • listMonitor(_:didInsertObject:toIndexPath:) is called for every inserted entity, while listMonitor(_:didDeleteObject:fromIndexPath:) is not called at all.
  • self.monitor.numberOfObjectsInSection(0) returns more than 10
Originally created by @zalogatomek on GitHub (Sep 27, 2017). So, I have some `ListMonitor`, `Where`, `ListObserver` (`self`) ```swift self.where = Where("name != nil") self.monitor = CoreStore.monitorList(From<Person>(), self.where, OrderBy(.ascending("name"))) self.monitor.addObserver(self) ``` Then, I'm performing `refetch()` with `Tweak`: ```swift self.tweak = Tweak({ (fetchRequest) in fetchRequest.fetchLimit = 10 }) self.monitor.refetch([self.where, self.tweak]) ``` Everything works as expected (in this scenario: 10 `Person`'s entities with _lowest_ name) but when in some other part of App I'm making inserts into `Person`, fetchLimit is not respected: - `listMonitor(_:didInsertObject:toIndexPath:)` is called for every inserted entity, while `listMonitor(_:didDeleteObject:fromIndexPath:)` is not called at all. - `self.monitor.numberOfObjectsInSection(0)` returns more than 10
adam added the ios/compiler bug label 2025-12-29 18:24:03 +01:00
adam closed this issue 2025-12-29 18:24:03 +01:00
Author
Owner

@JohnEstropia commented on GitHub (Oct 10, 2017):

Unfortunately this is a bug in NSFetchedResultsController since 2011 and there's not much we can do here aside from reporting it to Apple.

@JohnEstropia commented on GitHub (Oct 10, 2017): Unfortunately this is a [bug in NSFetchedResultsController since 2011](https://stackoverflow.com/questions/4858228/nsfetchedresultscontroller-ignores-fetchlimit) and there's not much we can do here aside from reporting it to Apple.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/CoreStore-JohnEstropia#172