Hello
So essentially I want to create an instance of a class using the TextField input
class Movie: ObservableObject{
@Published var name:String = ""
@Published var director:String = ""
@Published var stars:Double = 0.0
@Published var review:String = ""
func setName(theName:String){
self.name = theName
}
func setDirector(theDirector:String){
self.director = theDirector
}
func setStars(theStars:Double){
self.stars = theStars
}
func setReview(theReview:String){
self.review = theReview
}
}
so this is the class that I want to initialise and I want to get a value from the struct below and store it in variables in this class
struct BottomSheetView:View{
@StateObject var newMovie = Movie()
var body: some View{
VStack(alignment: .leading){
Text("Add Movie")
.fontWeight(.bold)
.font(.system(size:30))
.padding()
TextField("Movie name", text: ????
}
}
}
I want to get a String from the textfield above and store to var name:String in the Movie class
How do I do this?