Error occurs using CoreData

Hi, I can't fix an error occurred in the TextField (Accessing State's value outside of being installed on a View. This will result in a constant Binding of the initial value and will not update.). Could you help me, please? Under I paste all the code of the swift view I made.

thank you



Code Block import SwiftUI
import CoreData
struct AddNew: View {
    
    @Environment(\.managedObjectContext) var moc
    @State static var name: String = ""
    @State static var carier: String = ""
    @State static var save: Bool = false
    
    var body: some View {
        
        NavigationView {
            
            Form {
                
                VStack {
                    
                    TextField("name...",text: AddNew.$name).padding()
                        .background(Color(red: 239.0/255.0, green: 243.0/255.0, blue: 244.0/255.0))
                    
                    TextField("carier...",text: AddNew.$carier).padding()
                         .background(Color(red: 239.0/255.0, green: 243.0/255.0, blue: 244.0/255.0))
                    
                    Button(action: {
                        let add = Big(context: moc)
                        add.name = AddNew.name
                        add.carier = AddNew.carier
                        add.save = AddNew.save
                        
                        try? moc.save()
                        
                        AddNew.name = ""
                        AddNew.carier = ""
                        
                    }) {
                        Text("Add New").padding()
                            .font(.system(size: 23))
                            .foregroundColor((AddNew.name.count > 0 && AddNew.carier.count > 0) ? Color.white : Color.gray)
                    }.background(Color .green)
                    .clipShape(RoundedRectangle(cornerRadius: 10))
                }
            }
        }
    }
}
struct AddNew_Previews: PreviewProvider {
    static var previews: some View {
        AddNew()
    }
}


hi,

i'm surprised this code compiles, and it's not really a Core Data-specific problem; but i would recommend simply removing all the "AddNew." qualifiers to variable names. then let us know what happens.

hope that helps,
DMG
Error occurs using CoreData
 
 
Q