I trying to call the login function for user to perform their login action, the way I calling the function is as follow:
struct LogInView: View {
@State private var emailAddress: String = ""
@State private var password: String = ""
@EnvironmentObject var userAuth: UserAuth
var body: some View {
...
Button(action: {
userAuth.login(self.emailAddress, self.password)
}) {
HStack {
Text("Sign In as Owner")
}
.padding()
.frame(width: geometry.size.width - 40, height: 40)
.foregroundColor(Color.white)
.background(Color.blue)
.cornerRadius(5)
}
...
}
And below is how I declare my login function
class UserAuth: ObservableObject {
@Published var isLoggedIn = false
var userID = nil {
didSet {
didChange.send(self)
}
}
var UserModel = PersistenceController()
let didChange = PassthroughSubject<UserAuth,Never>()
// required to conform to protocol 'ObservableObject'
let willChange = PassthroughSubject<UserAuth,Never>()
func login(email: String, password: String) {
self.userID = UserModel.loginUser(email: email, password: password).id
self.isLoggedin = true
}
}
I am really confused, the function is accepting two parameters, but the error keep showing "Argument passed to call that takes no arguments". Anyone knows how to solve it? Thanks in Advance.