无法识别的选择器通过FIRAuth发送到实例

时间:2017-02-07 22:57:03

标签: ios swift firebase firebase-authentication

我收到以下错误

2017-02-07 23:50:44.987 Eat and Write[43621:3732723] -[UIViewController logOutAction:]: unrecognized selector sent to instance 0x7fa7a4c379c0
2017-02-07 23:50:44.991 Eat and Write[43621:3732723] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController logOutAction:]: unrecognized selector sent to instance 0x7fa7a4c379c0'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000103beed4b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x000000010322f21e objc_exception_throw + 48
    2   CoreFoundation                      0x0000000103c5ef04 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
    3   CoreFoundation                      0x0000000103b74005 ___forwarding___ + 1013
    4   CoreFoundation                      0x0000000103b73b88 _CF_forwarding_prep_0 + 120
    5   UIKit                               0x0000000104ad28bc -[UIApplication sendAction:to:from:forEvent:] + 83
    6   UIKit                               0x0000000104c58c38 -[UIControl sendAction:to:forEvent:] + 67
    7   UIKit                               0x0000000104c58f51 -[UIControl _sendActionsForEvents:withEvent:] + 444
    8   UIKit                               0x0000000104c57e4d -[UIControl touchesEnded:withEvent:] + 668
    9   UIKit                               0x0000000104b40545 -[UIWindow _sendTouchesForEvent:] + 2747
    10  UIKit                               0x0000000104b41c33 -[UIWindow sendEvent:] + 4011
    11  UIKit                               0x0000000104aee9ab -[UIApplication sendEvent:] + 371
    12  UIKit                               0x00000001052db72d __dispatchPreprocessedEventFromEventQueue + 3248
    13  UIKit                               0x00000001052d4463 __handleEventQueue + 4879
    14  CoreFoundation                      0x0000000103b93761 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    15  CoreFoundation                      0x0000000103b7898c __CFRunLoopDoSources0 + 556
    16  CoreFoundation                      0x0000000103b77e76 __CFRunLoopRun + 918
    17  CoreFoundation                      0x0000000103b77884 CFRunLoopRunSpecific + 420
    18  GraphicsServices                    0x0000000107f8ba6f GSEventRunModal + 161
    19  UIKit                               0x0000000104ad0c68 UIApplicationMain + 159
    20  Eat and Write                       0x00000001021e750f main + 111
    21  libdyld.dylib                       0x0000000106d7568d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

此代码似乎是问题

@IBAction func logOutAction(_ sender: Any) {

    try! FIRAuth.auth()!.signOut()

    if FIRAuth.auth()!.currentUser != nil { // <-- scheint zu buggen
        do {
            try! FIRAuth.auth()!.signOut()
            let vc = UIStoryboard(name: "AuthScreen", bundle: nil).instantiateViewController(withIdentifier: "SignUp")
            self.present(vc, animated: true, completion: nil)


        } catch let error as NSError {
            print(error.localizedDescription)
        }
    }
}

从FIRAuth.auth()登录和其他内容工作正常。我也可以轻松地在故事板之间“跳”。我不知道问题出在哪里。

编辑: 我感觉错误位于

之内

try! FIRAuth.auth()!.signOut()

编辑2: 创建一个新的ViewController修复它我使用的那个被窃听,找不到导致错误的原因

1 个答案:

答案 0 :(得分:1)

(代表OP发布)

解决:Class是WriteUITest的一部分,而不是App本身。