@UIApplicationMain AppDelegate.swift

In AppDelegate.swift file, I see a line of code at the very top, just below an import keyword. It says "@UIApplicationMain". What does that line of code do? What does the"@" at the beginning mean?

Replies

In AppDelegate.swift file, I see a line of code at the very top, just below an import keyword. It says "@UIApplicationMain". What does that line of code do?

It indicates that this class should be treated as the app delegate for a UIKit based application. If you leave it out then you have to add a

main.swift
file that calls the
UIApplicationMain
function. This is unnecessary boilerplate, so Swift has a nice shortcut to avoid it.

What does the"@" at the beginning mean?

The

@
character introduces a Swift attribute, which modifies the following class declaration.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"