Posted By

cdarken on 10/17/11


Tagged

Objective-c iphone


Versions (?)

notify view controller when application becomes active


 / Published in: Objective C
 

  1. //add this when initializing controller
  2. [[NSNotificationCenter defaultCenter] addObserver:self
  3. selector:@selector(becomeActive:)
  4. name:UIApplicationDidBecomeActiveNotification
  5. object:nil];
  6.  
  7. //add the actual method in the controller
  8.  
  9. - (void)becomeActive:(NSNotification *)notification {
  10. NSLog(@"becoming active");
  11. }
  12.  
  13. //be sure to clean up the notification
  14.  
  15. - (void)dealloc {
  16. [[NSNotificationCenter defaultCenter] removeObserver:self];
  17. [super dealloc];
  18. }

Report this snippet  

You need to login to post a comment.