mingsai

IOS 5 Responding to Application Events

Sep 9th, 2012
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //ios 5
  2. //responding to application level events
  3.  
  4. - (void)viewDidLoad
  5. {
  6.     [super viewDidLoad];
  7.     [[NSNotificationCenter defaultCenter]
  8.      addObserver:self
  9.      selector:@selector(willEnterForegroundNotification:)
  10.      name:UIApplicationWillEnterForegroundNotification
  11.      object:nil];
  12.    
  13.     [[NSNotificationCenter defaultCenter]
  14.      addObserver:self
  15.      selector:@selector(willResignActiveNotification:)
  16.      name:UIApplicationWillResignActiveNotification
  17.      object:nil];
  18.    
  19.     // Do any additional setup after loading the view.
  20. }
  21. - (void)willEnterForegroundNotification:(NSNotification *)notification
  22. {
  23.     //app is returning to foreground from background
  24. }
  25.  
  26. - (void)willResignActiveNotification:(NSNotification *)notification
  27. {
  28.     //home button is pressed
  29. }
Advertisement
Add Comment
Please, Sign In to add comment