How can I keep the fetchLimit constant even when new data is inserted?
To replicate this, you can create a new Project in Xcode and check "Use Core Data". I use this code to apply fetchLimit:
struct MyView: View {
@FetchRequest private var items: FetchedResults<Item>
init() {
let request: NSFetchRequest<Item> = Item.fetchRequest()
request.fetchLimit = 3
_items = FetchRequest(fetchRequest: request)
}
This code works. For example I have 10 Items and when I open the app - only 3 are displayed! But when I add a new Item on the fly - @FetchRequest just adds it to the View and now it displays 4 Items!?
How can I make @FetchRequest keep updating the View reactively, but respect the fetchLimit to always show the latest 3 Items only?