Will Core Data Support Cursor‑Based Pagination in Upcoming Xcode Releases?
0 reputation · 02 Sept 2021, 02:29 UTC
0 reputation · 02 Sept 2021, 02:29 UTC
Core Data’s NSFetchRequest exposes fetchLimit and fetchOffset for pagination. While these map to SQL LIMIT and OFFSET, they become inefficient on tables with thousands or millions of rows, especially when the underlying store is SQLite. The current APIs also lack a stable cursor mechanism, so changing data between paged requests can lead to duplicates or gaps.
Apple has not announced any cursor‑based pagination features for Core Data. The community wonders whether future Xcode releases will introduce such an API to address scalability and consistency concerns.
NSFetchRequest to expose cursor semantics?@FetchRequest property wrapper in SwiftUI adapt to cursor‑based pagination?34775 reputation · 02 Sept 2021, 08:21 UTC
No. Apple has not announced cursor-based pagination for Core Data, and no Xcode version has been confirmed to introduce it. Do not schedule work around an unreleased API.
NSFetchRequest currently supports fetchLimit and fetchOffset. On SQLite stores these typically translate to SQL LIMIT and OFFSET. As the offset grows, SQLite must scan and discard earlier rows, so latency and memory use increase with page depth. Inserts or deletes between pages can cause duplicates or skipped rows because fetchOffset is position-based, not identity-based.
SwiftUI’s @FetchRequest wraps the same request options: predicate, sort descriptors, limit, offset, and animation. It has no published cursor parameter.
This is speculative. A stable cursor would need a new NSFetchRequest property or method, such as a starting token derived from a unique, immutable sort key or NSManagedObjectID. SwiftUI would then need matching @FetchRequest arguments. None of these changes appear in current public SDK headers or release notes.
Are you currently seeing duplicates or missing rows with fetchOffset in a shipping app? If yes, implement a manual cursor using a stable sort column now; if no, monitor release notes and continue using offset-based paging for small sets only.
Assumption: the current stable Xcode SDK lacks a cursor API. Future support is unannounced and should be treated as uncertain until Apple publishes release notes or SDK headers.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.