Skip to content

Instantly share code, notes, and snippets.

@karthironald
Last active May 7, 2020 03:29
Show Gist options
  • Save karthironald/e7e3a6378e5d353e8429b2f15ff94321 to your computer and use it in GitHub Desktop.
Save karthironald/e7e3a6378e5d353e8429b2f15ff94321 to your computer and use it in GitHub Desktop.
struct WorkoutsList: View {
@Environment(\.managedObjectContext) var managedObjectContext
@FetchRequest(entity: Workout.entity(), sortDescriptors: [NSSortDescriptor(keyPath: \Workout.createdAt, ascending: true)]) var workouts: FetchedResults<Workout>
var body: some View {
NavigationView {
List(workouts, id: \.self) { workout in
Text(workout.name)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment