Closed pearlyred closed 4 years ago
Hi, Pager
expects an Array
of Equatable
elements and a keyPath
to an identifier. FetchedResults
is a RandomAccessCollection
@lsaunders80 , just use Array(orders)
and make sure that either Order
conforms to Identifiable
or you pass a keyPath
to an identifier:
struct Order {
id: String
// more variables
}
@State var page = 0
let pager = Pager(page: $page, data: Array(orders), id: \.id) {
// your view
}
As part of #135 , version 1.13.0-beta.1 supports an initializer that takes any RandomAccessCollection
so you can pass your orders
collection directly now:
struct Order {
id: String
// more variables
}
@State var page = 0
let pager = Pager(page: $page, data: orders, id: \.id) {
// your view
}
Hi, couldn't see anywhere else to ask this.. just wondering if it's possible to use a fetch request result as the data for the pager?
I currently have:
I tried setting the Pager.data parameter to orders, but that didn't work.