Reputation:
I have a ForEach list in my app that pulls data from core data. Can I limit the number of objects that the ForEach list shows? for example, I want to only show the first 10 objects from my core data entity.
Upvotes: 0
Views: 696
Reputation: 8126
maybe in some cases the better solution would be to limit the fetchrequest, which is also quicker and less resource consuming
fetchrequest.fetchLimit = 10
Upvotes: 0
Reputation: 168
you can limit the fetch from core data. see How fetch 10 records each time from table using coredata
if youre looking to limit from ForEach instead of Core Data, you can iterator your collection using range:
ForEach(0 ..< 10) { index in
Text(Users[index].name)
}
Upvotes: 2