gpt4 book ai didi

swift - logInWithUsernameInBackground 的使用不明确

转载 作者:行者123 更新时间:2023-11-30 10:35:09 28 4
gpt4 key购买 nike

您好,尝试让 Back4App loginInWithUserNameSwiftUI 一起使用,但不断收到以下错误

Ambiguous use of logInWithUsernameInBackground

PFUser.logInWithUsernameInBackground($userName, 密码: $passWord)

struct ContentView: View {

@State var userName: String = ""
@State var passWord: String = ""
@State var authDidFail: Bool = false
@State var authDidWork: Bool = false
@State var editingMode: Bool = false

let storedUserName = "not your father"
let storedPassword = "this is not the password"



var body: some View {
ZStack{
VStack{
Text("WIK?")
.font(.largeTitle)
.fontWeight(.semibold)
.padding(.bottom, 20)
Image("WIK")
.clipShape(Circle())
UserNameTextField(userName: $userName, editingMode: $editingMode)
PasswordSecureField(passWord: $passWord)

if authDidFail {
Text("Information you entered was incorrect. Try again.")
.offset(y: -10)
.foregroundColor(.red)
}

Button(action: {

//need to check against back4app and set current user variable
PFUser.logInWithUsernameInBackground($userName, password: $passWord){
(user: PFUser?, error: NSError?) -> Void in
if user != nil{
//worked
}else {
//error
}

}


if self.userName == self.storedUserName && self.passWord == self.storedPassword {
self.authDidWork = true
} else {
self.authDidFail = true
}
}){
LoginButtonContent()
}
}
//vStack padding
.padding()
if authDidWork {
Text("Log in worked")
.font(.headline)
.frame(width: 250, height: 20)
.background(Color.green)
.cornerRadius(20.0)
.foregroundColor(.white)
.animation(Animation.default)
}
}
//ZStack
.offset(y: editingMode ? -150 :0)

}

}

尝试查看 $username$password 字符串作为 Object[""]: String

还尝试了字符串值self.userNameself.passWord

并尝试了字符串值userNamepassWord

最佳答案

您需要使用String值,而不是 Binding<String> :

PFUser.logInWithUsernameInBackground(userName, password: passWord)

关于swift - logInWithUsernameInBackground 的使用不明确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58198712/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com