Browsing articles tagged with " delegate"

How to Retrieve Your App Delegate Singleton Instance

Dec 14, 2009   //   by Derek van Vliet   //   Development  //  3 Comments

You should be familiar with the application delegate class if you have ever developed any kind of iPhone app. It is the class that contains your app’s applicationDidFinishLaunching which most if not all apps use as an entry point for execution. You might use it to keep track of application-level state variables or objects, for example.

As such, from time to time you will have a need to retrieve your app’s application delegate instance. You can retrieve it from anywhere within your app by running the following single line of code:

MyAppDelegateClass *app = (MyAppDelegateClass *)[[UIApplication sharedApplication] delegate];

Just be sure to replace “MyAppDelegateClass” with your own iPhone app’s application delegate class name.

Our Games

Latest Tweets