ios - NSNotificationCenter crash after changing UIViewController -
i'm implementing application, whith ios sdk 6.0, , i've got problem.
when i'm opening first time uiviewcontroller implemented nsnotificationcenter detect when user clicking on home button, looks working when try click on home button , go app'. problem is, when i'm on uiviewcontroller, , go another, uiviewcontroller , try click on home button, app' looks crashing.
this code :
in viewdidload function : [[nsnotificationcenter defaultcenter] addobserver: self selector: @selector(applicationenteringbackground) name: uiapplicationdidenterbackgroundnotification object: nil]; [[nsnotificationcenter defaultcenter] addobserver: self selector: @selector(applicationenteringforeground) name: uiapplicationwillenterforegroundnotification object: nil];
and implemented methods :
-(void)applicationenteringbackground { ... } -(void)applicationenteringforeground { ... }
the problem looks :
thanks =)
make sure removing observer when first view controller destroyed [[nsnotificationcenter defaultcenter] removeobserver:self];
Comments
Post a Comment