Reputation: 149
I just implemented a logout button on my HeaderView sector. But somehow I keep getting this crash from Xcode.
I feel like this is somehow related to my func logoutBtnClicked(){***}
.
so here is what my logoutBtnClicked() looks like:
//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:]: unrecognized selector sent to instance 0x78e38840 2016-08-18 21:18:54.829 helloworld[2439:115160] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[helloworld.HomeViewController Logout:]: unrecognized selector sent to instance 0x78e38840' * First throw call stack: ( 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: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 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: terminating with uncaught exception of type NSException (lldb)
Upvotes: 1
Views: 119
Reputation: 72460
The problem is that in the interface builder
for HomeViewController
, for button action you have set Logout
and inside the class of HomeViewController
it is declare as logout
, action
and property
are case sensitive
, so either change one of them will solve your crash.
Upvotes: 1