会員の登録を行うところの記述をxcode行った際に、
user.signUpInBackground{(error: NSError!) in
下記のようなエラーがでてきて困っております。
cannot convert value of type '(NSError!) ->()' to expected argument type "NCMBErrorResultBlock!'
ご教授お願いします。。
以下、signupviewcontroller.swiftの中身です。
swift
1 2 3 4import UIKit 5import NCMB 6 7class SignUpViewController: UIViewController { 8 // User Name 9 @IBOutlet weak var userNameTextField: UITextField! 10 // Password 11 @IBOutlet weak var passwordTextField: UITextField! 12 @IBOutlet weak var passwordTextField_second: UITextField! 13 14 // errorLabel 15 @IBOutlet weak var errorLabel: UILabel! 16 17 18 // 画面表示時に実行される 19 override func viewDidLoad() { 20 super.viewDidLoad() 21 // Passwordをセキュリティ入力に設定 22 self.passwordTextField.isSecureTextEntry = true 23 self.passwordTextField_second.isSecureTextEntry = true 24 25 } 26 27 // SignUpボタン押下時の距離 28 @IBAction func signUpBtn(_ sender: UIButton) { 29 // キーボードを閉じる 30 closeKeyboad() 31 32 // 入力確認 33 if self.userNameTextField.text!.isEmpty || self.passwordTextField.text!.isEmpty || self.passwordTextField_second.text!.isEmpty { 34 self.errorLabel.text = "未入力の項目があります" 35 // TextFieldを空に 36 self.cleanTextField() 37 38 return 39 40 } else if passwordTextField.text! != passwordTextField_second.text! { 41 self.errorLabel.text = "Passwordが一致しません" 42 // TextFieldを空に 43 self.cleanTextField() 44 45 return 46 47 } 48 49 //NCMBUserのインスタンスを作成 50 let user = NCMBUser() 51 //ユーザー名を設定 52 user.userName = self.userNameTextField.text 53 //パスワードを設定 54 user.password = self.passwordTextField.text 55 56 //会員の登録を行う 57 user.signUpInBackground{(error: NSError!) in 58 // TextFieldを空に 59 self.cleanTextField() 60 61 if error != nil { 62 // 新規登録失敗時の処理 63 self.errorLabel.text = "ログインに失敗しました:\(error.code)" 64 print("ログインに失敗しました:\(error.code)") 65 66 } else { 67 // 新規登録成功時の処理 68 self.performSegue(withIdentifier: "signUp", sender: self) 69 print("ログインに成功しました:\(user.objectId)") 70 71 } 72 73 } as! NCMBErrorResultBlock as! NCMBErrorResultBlock as! NCMBErrorResultBlock as! NCMBErrorResultBlock as! NCMBErrorResultBlock as! NCMBErrorResultBlock as! NCMBErrorResultBlock as! NCMBErrorResultBlock as! NCMBErrorResultBlock 74 } 75 76 // 背景タップするとキーボードを隠す 77 @IBAction func tapScreen(_ sender: UITapGestureRecognizer) { 78 self.view.endEditing(true) 79 80 } 81 82 // TextFieldを空にする 83 func cleanTextField(){ 84 userNameTextField.text = "" 85 passwordTextField.text = "" 86 passwordTextField_second.text = "" 87 88 } 89 90 // errorLabelを空にする 91 func cleanErrorLabel(){ 92 errorLabel.text = "" 93 94 } 95 96 // キーボードを閉じる 97 func closeKeyboad(){ 98 userNameTextField.resignFirstResponder() 99 passwordTextField.resignFirstResponder() 100 passwordTextField_second.resignFirstResponder() 101 102 } 103 104} 105
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。