Author Topic: How can I get a reference to my AppDelegate  (Read 2048 times)

kjmcneish

  • Administrator
  • *****
  • Posts: 719
    • View Profile
How can I get a reference to my AppDelegate
« on: October 15, 2014, 03:39:00 PM »
You can get a reference to your AppDelegate object from anywhere within your app using the following code.

Swift:
Code: [Select]
var appDelegate = UIApplication.sharedApplication().delegate as AppDelegate
Objective-C:
Code: [Select]
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
All the best!
Kevin McNeish
Author of "Learn to Code in Swift": https://itunes.apple.com/us/book/learn-to-code-in-swift/id942956811?mt=11
« Last Edit: August 15, 2015, 11:29:30 PM by kjmcneish »