@SectionedFetchRequest total number of records?

Hi all, Looking into the new @SectionedFetchRequest in SwiftUI 3 and it's really awesome. Thx! But how can I keep track of the total number of records fetched now that they are separated into sections? Can't find anything useful in the docs. Want to update the counter inte the Quakes sample app now that I'm using @SectionedFetchRequest instead of @FetchRequest. Thx in advance / Jörgen, Bitfield

Replies

I was looking at some other questions for #wwdc21-10017 and found that

quakes.reduce(0, { $0 + $1.count })

solves my problem. Great!

Now onwards to figure out how to handle the selection in a @SectionedFetchRequest List building on the Quakes sample.

Any ideas are welcome. Thx!

  • Late here, but if anyone has anything to add I'd also love to hear it. Apple's documentation is lacking, especially for something so obviously necessary!

  • @Sanook, the reduce method described in the answer here is a good solution and works in my Core Data apps that use @SectionedFetchRequest.

Add a Comment