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
Post a Comment