I am using a @SectionedFetchRequest
with some success.
This sectioned fetch request feeds data to a List()
.
I want to include a footer to the list that provides a count of the managed objects returned from the sectioned fetch request.
Previously I have used .count
.
This still works but only returns the number of sections.
A sectioned fetch request provides this result...
SectionedFetchResults<String, CoreDataEntityClass>
So how do I iterate through this unusual collection to determine a count?
According to the doc, SectionedFetchResults
is a RandomAccessCollection
of Section
and Section
is a RandomAccessCollection
of Result
(Result
== CoreDataEntityClass
, in your case).
So, Please try something like this to get the total count:
items.reduce(0, {$0 + $1.count})