01 logo

iOS Native Development - AppDelegate

What is AppDelegate?

By ConficlePublished 5 years ago 3 min read

Hello everyone, we are back with our next article. In case you directly jumped on this article you can read our previous articles here before moving further.

In this article we will understand what is AppDelegate class, what is its purpose and various use cases around it.

So when you create a new Xcode project as explained in this article Xcode creates a file called AppDelegate.swift with a class named AppDelegate. This class is a short form of application delegate and implements UIApplicationDelegate interface.

What is Delegate?

Before understanding the class itself. Let us first understand what a delegate is.

By meaning delegate is a person or entity representing another person or entity, with a limited authority and information.

For example, Indian government sends political delegates to another country for any discussions. So these delegates represent India or the government of India with limited authority or information.

So here AppDelegate class is a delegate of our application. It represents our iOS application with a limited authority or information by the means of method it implements.

In a very simple language it is our application class.

The Purpose or Use cases

Application level information

Being an application class, the main purpose of this class is to give information about application to the other classes in our code. For example when an application starts, ends, goes to background, comes to foreground, receives remote notification, receives events from other applications etc.

It does so by implementing application level event methods defined in UIApplicationDelegate protocol. These methods are called application life cycle methods and are discussed in detail in this article.

Sharing application level data.

Again being an application class, it is a singleton class. Which means only a single instance of this class is created during the entire application.

When our application is launched the instance of AppDelegate class is created by the application itself in main method. This is explained in more detail in our previous article here.

Though this use case makes it easy to access some application level data. However as a developer one should take care while creating customer variables, methods and properties in AppDelegate as they become globally accessible and will remain throughout the application, unless destroyed manually.

One should take care as a developer that AppDelegate should not become the dumping ground of all information.

At any point of time one can get the instance of AppDelegate class using below code.

let appDelegate = UIApplication.shared.delegate as! AppDelegate

let aVariable = appDelegate.someVariable

Custom application delegate

Instead of using Xcode to create an AppDelegate class, you can make or create your own application delegate class. To do that you need to confirm your custom class to UIApplicationDelegate protocol and you need to pass the class name as 4th argument by implementing custom UIApplicationMain() function as described in our previous article

Every iOS application has only one application delegate class. Though you can create multiple classes confirming UIApplicationDelegate however the name of the class passed in UIApplicationMain() function will only be used as an actual delegate class.

Summary

AppDelegate class is created by Xcode by default and is a singleton class. As this class represents our application, it is used to get the application level information and events. One should take care that this should not become dumping ground of unwanted variables, methods and properties.

That’s it for this article. We hope now you have a far better understanding of AppDelegate class, its purpose and use cases.

Thanks for reading this article. If you have any queries related to this topic or iOS, Objective C and Swift. Please write us at [email protected] or direct message us on instagram at conficle(instagram username).

Also keep watching this space for upcoming articles on iOS development, software development and technology concepts.

mobile

About the Creator

Conficle

A passionate iOS developer with more than decade of experience in creating enterprise applications for Apple devices. With a solid foundation in Swift, Objective-C, I thrive on transforming complex ideas into elegant, functional apps.

Reader insights

Be the first to share your insights about this piece.

How does it work?

Add your insights

Comments

There are no comments for this story

Be the first to respond and start the conversation.

Sign in to comment

    Find us on social media

    Miscellaneous links

    • Explore
    • Contact
    • Privacy Policy
    • Terms of Use
    • Support

    © 2026 Creatd, Inc. All Rights Reserved.