SwiftUI: Extracting data from CoreData to label

Viewed 15

I save the user's number in Core Data and want to place it in the label for NavigationLink Text("\(self.number ?? 0)"), but no matter how I try, Xcode gives various errors. What are the ways to do this?

Request to the database:

@FetchRequest(entity: ProfileUser.entity(), sortDescriptors: [NSSortDescriptor(keyPath: \ProfileUser.number, ascending: true)]) var profileUser: FetchedResults<ProfileUser>

NavigationLink with label, where I want to place the data from the database:

NavigationLink(
    destination: ProfileView(),
    label: {
        Text("\(self.number ?? 0)")
            .frame(width: 40, height: 40)
            .font(.system(size: 18,
                          weight: .semibold))
    })
0 Answers
Related