View attribute in CoreData

Asked 1 years ago, Updated 1 years ago, 352 views

With CoreData

I'd like to display adata in the list with Entity as AData and attribute as adata, but I can't find items.adata because the initial value is empty.

says

items.adata?

But it will come out.

What do you need?

struct ContentView:View {
@Environment (.managedObjectContext) private var viewContext

@FetchRequest(
    sortDescriptors: NSSortDescriptor (keyPath:\AData.adata, ascending:true),
    animation:.default)
private variables —FetchedResults<AData>

varbody:someView {
    NavigationView {
        List{
           
            Section {
                ForEach(0..<items.adata.count) {Text(items.adata[index])})
                }
            } header: {
                Text ("dust")
            }
        }
        }
        

coredata

2023-03-13 11:51

1 Answers

I don't have a confirmation environment at hand, so I imagine it.

ForEach(0..<items.count) {index in Text(items[index].adata)}

I think it will be


2023-03-13 15:05

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.