swift4
xcode9.2
FirebaseAuthで、メールアドレスベースでログイン認証を実装したいです。
サインアップには成功しました。
(画像の"会員登録"ビューで登録buttonをタップし、"ログインしたよ"まで遷移できています。)
ですが、"ログイン"ビューのログインbuttonをタップすると、
エラーでクラッシュします。
この場合の、
ログインするのに相応しいMailLogInViewControllerrのコードを教えて頂きたいです。
よろしくお願いします。
(MailSignUpViewControllerサインアップです) import UIKit import Firebase import FirebaseAuth class MailSignUpViewController: UIViewController { @IBOutlet weak var emailTF: UITextField! @IBOutlet weak var passwordTF: UITextField! @IBOutlet weak var usernameTF: UITextField! override func viewDidLoad() { super.viewDidLoad() } //サインアップボタン! @IBAction func mailSignUpButton(_ sender: Any) { guard let email = emailTF.text else { return } guard let pass = passwordTF.text else { return } guard let username = usernameTF.text else { return } Auth.auth().createUser(withEmail: email, password: pass) { user, error in if error == nil && user != nil { print("ユーザー登録したよ") let changeRequest = Auth.auth().currentUser?.createProfileChangeRequest() changeRequest?.displayName = username changeRequest?.commitChanges { error in if error == nil { print("User display name changed!") self.dismiss(animated: false, completion: nil) } } } else { print("ユーザー登録失敗!: (error!.localizedDescription)") } } } }
(MailLogInViewControllerrログインです) import UIKit import Firebase import FirebaseAuth class MailLogInViewController: UIViewController { @IBOutlet weak var emailTF: UITextField! @IBOutlet weak var passwordTF: UITextField! override func viewDidLoad() { super.viewDidLoad() } @IBAction func mailLogInButton(_ sender: Any) { func login() { Auth.auth().signIn(withEmail: emailTF.text!, password: passwordTF.text!, completion: { user,error in if error != nil { print("ユーザーログイン失敗!: (error!.localizedDescription)") } else { print("ログイン!") } } )} } }
(エラーコンソールです) 2017-12-31 14:37:33.475932+0900 make01[5540:498135] [Firebase/Analytics][I-ACS023007] Firebase Analytics v.40005000 started 2017-12-31 14:37:33.476093+0900 make01[5540:498135] [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r) アプリを開いたよ 2017-12-31 14:37:33.898667+0900 make01[5540:498022] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /Users/tanakaatsushi/Library/Developer/CoreSimulator/Devices//data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles 2017-12-31 14:37:33.901754+0900 make01[5540:498022] [MC] Reading from private effective user settings. 2017-12-31 14:37:33.913445+0900 make01[5540:498022] Could not successfully update network info during initialization. 2017-12-31 14:37:34.032210+0900 make01[5540:498145] TIC Read Status [1:0x0]: 1:57 2017-12-31 14:37:34.032329+0900 make01[5540:498145] TIC Read Status [1:0x0]: 1:57 2017-12-31 14:37:34.230953+0900 make01[5540:498143] TIC Read Status [2:0x0]: 1:57 2017-12-31 14:37:34.231077+0900 make01[5540:498143] TIC Read Status [2:0x0]: 1:57 2017-12-31 14:37:35.029164+0900 make01[5540:498022] Unknown class MailLogInViewController in Interface Builder file. 2017-12-31 14:37:35.060771+0900 make01[5540:498022] [MC] Lazy loading NSBundle MobileCoreServices.framework 2017-12-31 14:37:35.062220+0900 make01[5540:498022] [MC] Loaded MobileCoreServices.framework 2017-12-31 14:37:37.085986+0900 make01[5540:498022] -[UIViewController mailLogInButton:]: unrecognized selector sent to instance 0x7fa07680fc10 2017-12-31 14:37:37.090251+0900 make01[5540:498022] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController mailLogInButton:]: unrecognized selector sent to instance 0x7fa07680fc10' *** First throw call stack: ( 0 CoreFoundation 0x000000010e53d12b __exceptionPreprocess + 171 1 libobjc.A.dylib 0x000000010dbd1f41 objc_exception_throw + 48 2 CoreFoundation 0x000000010e5be024 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132 3 UIKit 0x000000010f301f51 -[UIResponder doesNotRecognizeSelector:] + 295 4 CoreFoundation 0x000000010e4bff78 ___forwarding___ + 1432 5 CoreFoundation 0x000000010e4bf958 _CF_forwarding_prep_0 + 120 6 UIKit 0x000000010f0cf972 -[UIApplication sendAction:to:from:forEvent:] + 83 7 UIKit 0x000000010f24ec3c -[UIControl sendAction:to:forEvent:] + 67 8 UIKit 0x000000010f24ef59 -[UIControl _sendActionsForEvents:withEvent:] + 450 9 UIKit 0x000000010f24de86 -[UIControl touchesEnded:withEvent:] + 618 10 UIKit 0x000000010f145807 -[UIWindow _sendTouchesForEvent:] + 2807 11 UIKit 0x000000010f146f2a -[UIWindow sendEvent:] + 4124 12 UIKit 0x000000010f0ea365 -[UIApplication sendEvent:] + 352 13 UIKit 0x000000010fa36a1d __dispatchPreprocessedEventFromEventQueue + 2809 14 UIKit 0x000000010fa39672 __handleEventQueueInternal + 5957 15 CoreFoundation 0x000000010e4e0101 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 16 CoreFoundation 0x000000010e57ff71 __CFRunLoopDoSource0 + 81 17 CoreFoundation 0x000000010e4c4a19 __CFRunLoopDoSources0 + 185 18 CoreFoundation 0x000000010e4c3fff __CFRunLoopRun + 1279 19 CoreFoundation 0x000000010e4c3889 CFRunLoopRunSpecific + 409 20 GraphicsServices 0x000000011497d9c6 GSEventRunModal + 62 21 UIKit 0x000000010f0ce5d6 UIApplicationMain + 159 22 make01 0x000000010b727f97 main + 55 23 libdyld.dylib 0x0000000111f09d81 start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)
//エラーを追記しました
回答1件
あなたの回答
tips
プレビュー