FetchRequest and List/ForEach - no lazy loading?

Hi,


I made a small test program trying to figure out how @FetchRequest, List, ForEach work together with large data sets. At first glance it seems (judging from the memory consumption) that all the entities are loaded and not just those which are displayed (see code below). I am now wondering, if there is a way to setup FetchRequest (or the List, or...) in a way so it does the lazy loading for only visible items? Or is this just not (yet) possible?


Here is the SwiftUI coding I am using.


import SwiftUI

struct ContentView: View {
  @FetchRequest(entity: TrackCoordinate.entity(), sortDescriptors: [])
  var tracks: FetchedResults<TrackCoordinate>
  
    var body: some View {
      VStack {
        List {
          ForEach(tracks, id: \.self) { track in
            Text("\(track.x) \(track.y)")
          }
        }
      }
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}


Thanks, Michael

try an own view with initializalization initializer, an example can you find there


Kind Regads

DWD

FetchRequest and List/ForEach - no lazy loading?
 
 
Q