Mobile Development

Ilya Loshkarev

Layers of iOS

Stack of Frameworks

For low-level access to high-level abstractions
Cocoa Touch
Core Services
Core OS
  • Darwin Kernel
    Concurrency, Networking, File-system
  • Accessory
    Bluetooth, Attached hardware communication
  • Accelerate
    Signal processing, Linear algebra
  • Security
    Encription, Certificates, Keychain
Cocoa Touch
Core Services
Core OS
  • Foundation
    Collections, Tasks, Socket communication
  • Core Data
    Internal database managment system
  • Core Media
    Low-level media data access
  • Core Location
    Positioning and compass
  • Core Motion
    Motion-data access
Cocoa Touch
Core Services
Core OS
  • Core Graphics
    Low-lewel drawing
  • Core Animation
    Low-lewel animation
  • Core Image
    Image manipulation
  • AV Foundation
    Record and playback of audio and video
  • Advanced graphics
    OpenGL, Metal, SceneKit, SpriteKit
Cocoa Touch
Core Services
Core OS
  • UIKit
    • Lifecycle mangement
    • UI managment
    • Notifications
  • App Extensions
    Calling an app from within another app
  • Notification Center
    Showing custom data in notifications
Cocoa Touch
Core Services
Core OS

App Life Cycle

App Bundle

  • Executable
  • UI files
  • Assets
  • Localization Resources
  • Temporary Files
  • Cache

Execution States

Foreground Not Running Controller Background Background Active Inactive Suspended
  • Inactive – app is executed but cannot recieve any events.
    Usually right after launch or coming from background
  • Active – app is up and running
  • Background – app is finishing it's tasks ready to get closed. Usually right after being switched out or turned off
  • Suspended – app is not running and can be terminated by the system without any warning

Allowed Background Tasks

  • Audio Player/Recorder
  • Location Updater
  • VoIP Listener
  • Accessory Listener
  • Background Downloader
  • Push Notification Listener

Background task must be declared in app preferences

App's Limitations

  • Sandbox FileSystem
  • 250Mb - 2Gb RAM
  • Workflow Guidelines
  • User Permissions

Model View Controller

UIWindow View Stack View View Controllers AppDelegate Controller Model Documents Data Objects UIAppliction
  • Core Data
  • Managed Object Classes
  • Documents & Files
Model Documents Data Objects Describes data and its relations
  • XIB Files
  • Storyboard Files
  • Code-generated Views
UIWindow View Stack View Provides interface for data and user actions
  • UIApplicationDelegate
  • Storyboard Segues
  • Layout Constraints
  • ViewControllers
View Controllers AppDelegate Controller Describes actions and reactions to events

App Delegate

UIWindow View Stack View View Controllers AppDelegate Controller Model Documents Data Objects UIAppliction



  • Responds to changes in execution state
  • Responds to system notifications
  • Allows for state preservation and restoration
  • Stores main window

Execution State Changes

							// Launch time
							application(_: willFinishLaunchingWithOptions:)
							application(_: didFinishLaunchingWithOptions:)
							// Transitioning to the foreground
							// Transitioning to the background
							// Transitioning to the inactive state
							applicationWillResignActive(_:) // from foreground
							applicationWillEnterForeground(_:) // from background
							// Termination
							applicationWillTerminate(_:) // when not suspended
AppDelegate Event Loop UIAppliction Restore UI state willFinishLaunching State Restoration didFinishLaunching ... Load main UI file User taps the app

App State Restoration

							// If App should save or restore state

Notification Response

							// System Events
							// Local Notifications
							// Remote Notifications



  • Sets Screen bounds for the App
  • Stores View Stack

Simple App

						class AppDelegate: UIResponder, UIApplicationDelegate {
							// Create new UIWindow
							var window: UIWindow? = UIWindow(frame: UIScreen.main.bounds)

							func application(application: UIApplication,
								didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
								// Create root ViewController
								window!.rootViewController = UIViewController()
								// Set window to handle input and show it
								return true