Post

Replies

Boosts

Views

Activity

Comment on [SwiftData] How to get the first 7 elements by using @Query?
Thank you for your answer. If I want declare a fetch descriptor as a static variable. Do I also need to set value of fetchLimit in the init()? Like this: static var fetchDescriptor = FetchDescriptor<Record>(sortBy: [SortDescriptor(\Record.date, order: .reverse)]) @Query(fetchDescriptor) private var records:[Record] init() { view.fetchDescriptor.fetchLimit = 7 }
Nov ’24