Core Data: Beyond the Basics

Jul 26 2022 · Swift 5.5, iOS 15, Xcode 13.3.1

Part 1: Fetching & Displaying Launches

02. Displaying Launches

Episode complete

Play next episode

Next
About this episode

Leave a rating/review

See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 01. Introduction Next episode: 03. Sorting Data Using Sort Descriptors

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

Now that you know how to save a Launch, the next step is to get those launches out of the persistent store and display them in a list so that you can see when they take place.

static func basicFetchRequest() {}
import SwiftUI
FetchRequest(entity: , sortDescriptors:) 
FetchRequest(entity: RocketLaunch.entity(), sortDescriptors:[])
let launchesFetchRequest = RocketLaunch.basicFetchRequest()
var launches: FetchedResults<RocketLaunch> {
  launchesFetchRequest.wrappedValue
}
@FetchRequest(entity: RocketLaunch.entity, sortDescriptors: []) var launches: FetchedResults<RocketLaunch>
HStack { 
  LaunchStatusView(isViewed: launch.isViewed)
  Text("\(launch.name ?? "")")
}
let context = PersistenceController.preview.container.viewContext
let newLaunch = RocketLaunch(context: context)
newLaunch.name = "A really cool launch!"
return LaunchesView()
ForEach(launches, id: \.self) { launch in 
Name: A night time launch!
Launchpad: Out on the coastline
Date: 5/1/22