Philip007
Philip007

Reputation: 3230

#define for AppDelegate

I read a post to use macro to reference AppDelegate. I wonder what I should use to replace (MyOwnAppDelegate*)

#define AppDelegate ((MyOwnAppDelegate*)[[UIApplication sharedApplication] delegate])

Upvotes: 0

Views: 688

Answers (2)

Rob Napier
Rob Napier

Reputation: 299305

If you're referencing the UIApplicationDelegate so often that you need a special macro for it, then you're referencing it too often. The application delegate is the delegate of the main UIApplication object. It is not a general place to store "stuff." See the following discussions:

Upvotes: 3

DrummerB
DrummerB

Reputation: 40211

If it's a more recently started project, your delegate is probably called AppDelegate. To find out, you have to find the class in your project that implements NSApplicationDelegate or UIApplicationDelegate (depending on your target platform).

enter image description here

Upvotes: 2

Related Questions