0
我會開始用Swift和Parse編寫註冊視圖控制器嗎? 標誌了有檢查,如果用戶名或電子郵件都採取了在解析客戶端在swift上處理PFErrorCode
let query = PFQuery(className:"_User")
query.whereKey("email", equalTo: email)
query.findObjectsInBackground { (succeeded, error) -> Void in
newUser.signUpInBackground{(success, error) -> Void in
// The find succeeded.
print("Successfully retrieved scores.")
if success {
// Do something with the found objects
let alertMessage = UIAlertController(title: "Register complated", message: "You've been registered.", preferredStyle: UIAlertControllerStyle.alert)
let okAction = UIAlertAction(title: "Ok", style: UIAlertActionStyle.default, handler: nil)
alertMessage.addAction(okAction)
self.present(alertMessage, animated: true, completion: nil)
}
// Log details of the failure
// username is exists
else {
if PFErrorCode.errorUsernameTaken.rawValue == 202 {
print ("Username is exists")
}
else if PFErrorCode.errorUserEmailTaken.rawValue == 203 {
print ("E-mail is exists")
}
}
當我試着寫了現有的電子郵件或密碼在控制檯輸出沒有顯示的print()相同我想要的。
嘿nts,我複製了擴展裏面的不活動按鈕,並在編譯器中彈出一些錯誤。 – user2508528
將擴展名粘貼到另一個文件中(例如:PFErrorCode + Equatable) – nathan
Hey nts,我嘗試了您寫的擴展名,並收到三條錯誤消息。你能更具體地把擴展名放在哪裏嗎? – user2508528