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 :

the problem

thanks =)

make sure removing observer when first view controller destroyed [[nsnotificationcenter defaultcenter] removeobserver:self];


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -