notify view controller when application becomes active


/ Published in: Objective C
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.