2016-08-19 9 views
1

私はHeaderViewセクタにログアウトボタンを実装しました。しかし、どういうわけか私はこのクラッシュをXcodeから得ています。ログアウトボタンのクラッシュ

これはなんとなく私のfunc logoutBtnClicked(){***}に関連しているように感じます。 : -

//clicked logout 
    @IBAction func logout(sender: AnyObject) { 

     PFUser.logOutInBackgroundWithBlock { (error: NSError?) -> Void in 
      if error == nil { 
       NSUserDefaults.standardUserDefaults().removeObjectForKey("username") 
       NSUserDefaults.standardUserDefaults().synchronize() 

       let signin = self.storyboard?.instantiateViewControllerWithIdentifier("signinViewController") as! SigninViewController 
       let appDelegate: AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate 
       appDelegate.window?.rootViewController = signin 
      } 
     } 
    } 

2016年8月18日21:18:54.801のHelloWorld [2439 115160] [helloworld.HomeViewControllerログアウトので、ここで

はどのように見えるか、私のlogoutBtnClicked()であります]:インスタンスに送信された認識できないセレクタ0x78e38840 2016-08-18 21:18:54.829 helloworld [2439:115160] *未知の例外 'NSInvalidArgumentException'のためアプリを終了しています、理由: '[helloworld.HomeViewController Logout:]:認識できませんインスタンスに送信されたセレクタ0x78e38840 ' *まずスローコールスタック: ( 0 CoreFoundationの0x018d1494 exceptionPreprocess + 180 1 libobjc.A.dylib 0x035e5e02 objc_exception_throw + 50 2 CoreFoundationの0x018db253 - [NSObjectの(NSObjectの)doesNotRecognizeSelector:] + 275 3 CoreFoundationの0x0181089d ___forwarding_ + 1037 4 CoreFoundationの0x0181046e _CF_forwarding_prep_0 + 14 5 libobjc.A.dylib 0x035fa0b5 - [NSObjectのperformSelector:withObject:withObject:] + 84 6のUIKit 0x020c1e38 - [のUIApplication sendAction:に:から:forEvent:] + 118 7のUIKit 0x025519da - [UIBarButtonItem(UIInternal)_sendAction:withEvent:] + 179 8 libobjc.A.dylib 0x035fa0b5 - [NSObject performSelector:withObject:withObject:] + 84 9 UIKit 0x020c1e38 - [UIApplication sendAction:to:forEvent:] + 118 10 UIKit 0x020c1db7 - [UIApplication sendAction:toTarget:fromSender :forEvent:] + 64 11のUIKit 0x02265f3b - [するuicontrol sendAction:全forEvent:] + 79 12のUIKit 0x022662d4 - [するuicontrol _sendActionsForEvents:withEvent:] + 433 13のUIKit 0x02266483 - [するuicontrol _sendActionsForEvents:withEvent:] + 864 14のUIKit 0x022652c1 - [するuicontrol touchesEnded:withEvent:] + 714 15のUIKit 0x0214252e - [UIWindow _sendTouchesForEvent:] + 1095 16のUIKit 0x021435cc - [UIWindowのSendEvent:] + 1159 17のUIKit 0x020e4be8 - [のUIApplicationのSendEvent:] + 266 18のUIKit 0x020b9769 _UIApplicationHandleEventQueue + 7795 19 CoreFoundationの0x017e3e5f CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 15 20 CoreFoundationの0x017d9aeb __CFRunLoopDoSources0 + 523 21 CoreFoundationの0x017d8f08 __CFRunLoopRun + 1032 22 CoreFoundationの0x017d8846 CFRunLoopRunSpecific + 470 23 CoreFoundation 0x017d865b CFRunLoopRunInMode + 123 24 GraphicsServices 0x05f27664 GSEventRunModal + 192 25 GraphicsServices 0x05f274a1 GSEventRun + 104 26 UIKit 0x020bfeb9 UIApplicationMain + 160 27 helloworld 0x0007a4e1 main + 145 28 libdyld.dylib 0x043bba25 start + 1 ) libC++ abi。dylib:問題はHomeViewControllerためinterface builderで、ボタンアクションのためにあなたがLogoutを設定しているとHomeViewControllerのクラスの中にはlogoutとして宣言されていることであるタイプNSException (lldb)

+0

エラーレポートインスタンスに送信された認識できないセレクタ - 正しいビューコントローラに接続されていません – DogCoffee

+0

この回答を確認してくださいhttp://stackoverflow.com/questions/24588690/unrecognized-selector-sent-to-instance-error-when- a-button-is-click –

答えて

1

のキャッチされない例外で終了し、actionpropertycase sensitiveですので、どちらかを変更するとクラッシュが解決されます。

+0

うん、うんざりしている。しかし、それを見るには年を取った。 – Giraffe

関連する問題