作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
您好,尝试让 Back4App loginInWithUserName
与 SwiftUI
一起使用,但不断收到以下错误
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.userName
和self.passWord
并尝试了字符串值userName
和passWord
最佳答案
您需要使用String
值,而不是 Binding<String>
:
PFUser.logInWithUsernameInBackground(userName, password: passWord)
关于swift - logInWithUsernameInBackground 的使用不明确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58198712/
您好,尝试让 Back4App loginInWithUserName 与 SwiftUI 一起使用,但不断收到以下错误 Ambiguous use of logInWithUsernameInBac
我正在为用 Swift 编写的 Parse 实现登录功能。我收到一个错误: Missing argument for parameter 'target' call 虽然我似乎没有遗漏任何参数 - 我
我是一名优秀的程序员,十分优秀!