code_junkie

Referencing AppDelegate instance variables

Nov 11th, 2011
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. YourAppDelegate *appDelegate = (YourAppDelegate *)[[UIApplication sharedApplication] delegate];
  2. //and then access the variable by appDelegate.variable
  3.  
  4. UIApplication* myApplication = [UIApplication sharedApplication];
  5. UIWindow* mainWindow = [myApplication keyWindow];
  6. UIViewController* rootViewController = [mainWindow rootViewController];
  7.  
  8. UIApplication* myApplication = [UIApplication sharedApplication];
  9. UIWindow* mainWindow = [myApplication keyWindow];
  10. UIViewController* rootViewController = [mainWindow rootViewController];
Add Comment
Please, Sign In to add comment