【问题标题】:Logout Button crash注销按钮崩溃
【发布时间】:2016-12-26 03:42:27
【问题描述】:

我刚刚在我的 HeaderView 扇区上实现了一个注销按钮。但不知何故,我不断从 Xcode 中得到这个崩溃。

我觉得这与我的func logoutBtnClicked(){***} 有某种关系。

这就是我的 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-08-18 21:18:54.801 helloworld[2439:115160] -[helloworld.HomeViewController Logout:]:无法识别的选择器发送到实例 0x78e38840 2016-08-18 21:18:54.829 helloworld[2439:115160] * 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[helloworld.HomeViewController 注销:]:无法识别的选择器发送到实例 0x78e38840” * 首先抛出调用栈: ( 0 CoreFoundation 0x018d1494 异常预处理 + 180 1 libobjc.A.dylib 0x035e5e02 objc_exception_throw + 50 2核心基础0x018db253-[NSObject(NSObject)不识别选择器:]+275 3 核心基础 0x0181089d ___forwarding_ + 1037 4 核心基础 0x0181046e _CF_forwarding_prep_0 + 14 5 libobjc.A.dylib 0x035fa0b5 -[NSObject performSelector:withObject:withObject:] + 84 6 UIKit 0x020c1e38-[UIApplication sendAction:to:from: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:from:forEvent:] + 118 10 UIKit 0x020c1db7-[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64 11 UIKit 0x02265f3b-[UIControl sendAction:to: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 发送事件:] + 1159 17 UIKit 0x020e4be8 -[UIApplication 发送事件:] + 266 18 UIKit 0x020b9769 _UIApplicationHandleEventQueue + 7795 19 核心基础 0x017e3e5f CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 15 20 核心基础 0x017d9aeb __CFRunLoopDoSources0 + 523 21 核心基础 0x017d8f08 __CFRunLoopRun + 1032 22 核心基础 0x017d8846 CFRunLoopRunSpecific + 470 23 核心基础 0x017d865b CFRunLoopRunInMode + 123 24 图形服务 0x05f27664 GSEventRunModal + 192 25 图形服务 0x05f274a1 GSEventRun + 104 26 UIKit 0x020bfeb9 UIApplicationMain + 160 27 helloworld 0x0007a4e1 主要 + 145 28 libdyld.dylib 0x043bba25 开始 + 1 ) libc++abi.dylib:以 NSException 类型的未捕获异常终止 (lldb)

【问题讨论】:

标签: swift xcode


【解决方案1】:

问题在于,在HomeViewControllerinterface builder 中,对于按钮操作,您设置了Logout,在HomeViewController 的类中,它被声明为logoutactionpropertycase sensitive,所以要么改变其中一个就可以解决你的崩溃问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-01-23
    • 2018-07-06
    • 2019-09-04
    • 2012-12-17
    • 2012-08-25
    • 2012-03-14
    • 2011-07-05
    相关资源
    最近更新 更多