ios - PostNotificationName Exception from inside shouldSelectViewController -


tab bar has log-out button displays login screen when tapped.

i want put confirm logout alert before leaving current tab view , added following code beginning of shouldselectviewcontroller block:

if(viewcontroller == mlogoutcont) {     // post notification initiate showing logout confirmation alert.     [[nsnotificationcenter defaultcenter] postnotificationname:@"confirmlogout" object:self  userinfo:nil];     return false; } 

the app crashes inside postnotificationname call following nsexception error:

2015-04-29 09:40:59.333 testapplication[5420:210308] -[nsconcretenotification presentviewcontroller:animated:completion:]: unrecognized selector sent instance 0x7fe17217cc60 2015-04-29 09:40:59.341 testapplication[5420:210308] *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[nsconcretenotification presentviewcontroller:animated:completion:]: unrecognized selector sent instance 0x7fe17217cc60' 

if comment out postnotificationname line, app not crash when "logout" tab button tapped – nothing visually changes on screen – expected behavior because of return false;.

there's not enough code shown here. thing can tell

  • it's bad app design have log out button in tabs of tab bar controller
  • [nsconcretenotification presentviewcontroller:animated:completion:] indicates you're calling presentviewcontroller on notification object being passed (where ever you're handling response notification).

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -