📱

iOS App Core Classes

Jul 10, 2025

Overview

This lecture introduces the core Swift classes that form the foundation of every iOS app, focusing on AppDelegate and ViewController, and explains their roles in app structure and user interaction.

AppDelegate Class

  • The AppDelegate class is a central part of every iOS app, automatically generated by Xcode.
  • It contains Swift code essential to app startup and lifecycle management.
  • The @main annotation marks AppDelegate as the entry point for the app, auto-generating a main function.
  • The main function is where the app begins execution.

Swift Classes in iOS Apps

  • A class in Swift defines variables and functions shared by all objects of its type.
  • Every iOS app contains at least one Swift class, regardless of size.

ViewController Class

  • The ViewController class handles user interaction and represents one screen or activity within an app.
  • Most apps consist of multiple ViewControllers, each linked to a specific user interface (UI) element called a storyboard.
  • The ViewController serves as the gateway for user actions, managing events and responses.

Main Class and Entry Point

  • One class in every app is designated as the main class, serving as the starting point when the app launches.
  • AppDelegate, with its @main annotation, fulfills this role by providing the entry point to the app.

Xcode Project Structure

  • When creating a new iOS project, files like AppDelegate.swift and ViewController.swift are generated automatically.
  • These files can be accessed and edited via the project navigator in Xcode's interface.

Key Terms & Definitions

  • Class — A code blueprint defining variables and functions for objects of a given type.
  • AppDelegate — The Swift class managing app launch, termination, and critical lifecycle events.
  • @main Annotation — Signals the compiler to use the annotated class as the app's entry point.
  • ViewController — Manages a single screen's user interaction and UI logic in an iOS app.
  • Storyboard — A visual representation of a UI and its flow between screens in iOS apps.

Action Items / Next Steps

  • Review the generated AppDelegate.swift and ViewController.swift files in your Xcode project.
  • Prepare to learn how to use ViewController to build interactive app components in upcoming lessons.