🌍 iOS Development · subject
iOS Development Swift Programming Syllabus
The Swift Programming syllabus for iOS Development in full: 9 chapters, 21 topics and 64 sub-topics, every one listed below, plus 67 Swift Programming flashcards with answers.
Swift Programming syllabus: all 9 chapters
Expand any chapter to see its topics and sub-topics.
-
Introduction to Swift
2 topics- What is Swift?
- History of Swift
- Swift vs Objective-C
- Platforms Supported
- Setting Up the Environment
- Installing Xcode
- Xcode Interface Overview
- Playgrounds
- What is Swift?
-
Swift Basics
3 topics- Syntax and Structure
- Variables and Constants
- Data Types
- Operators
- Control Flow
- Functions
- Defining Functions
- Function Parameters and Return Values
- Closures
- Collections
- Arrays
- Dictionaries
- Sets
- Syntax and Structure
-
Advanced Swift
3 topics- Object-Oriented Programming
- Classes and Structures
- Inheritance
- Polymorphism
- Encapsulation
- Protocols and Extensions
- Defining Protocols
- Protocol Inheritance
- Extensions
- Generics
- Generic Functions
- Generic Types
- Associated Types
- Object-Oriented Programming
-
Memory Management
1 topic- Automatic Reference Counting (ARC)
- Strong and Weak References
- Unowned References
- Memory Leaks and Retain Cycles
- Automatic Reference Counting (ARC)
-
Concurrency
3 topics- Grand Central Dispatch (GCD)
- Dispatch Queues
- Dispatch Groups
- Dispatch Barriers
- Operation Queues
- Creating Operations
- Operation Dependencies
- Operation Priorities
- Async/Await
- Async Functions
- Awaiting Results
- Error Handling in Async Code
- Grand Central Dispatch (GCD)
-
Error Handling
2 topics- Error Types
- Defining Errors
- Throwing Errors
- Handling Errors
- Do-Try-Catch
- Try, Try?, Try!
- Defer
- Error Types
-
SwiftUI
3 topics- Introduction to SwiftUI
- SwiftUI vs UIKit
- Basic Views
- Modifiers
- State Management
- State and Binding
- ObservableObject and @Published
- EnvironmentObject
- Building Complex Interfaces
- Stacks and Grids
- Navigation
- Lists
- Introduction to SwiftUI
-
Networking
2 topics- URLSession
- Making Network Requests
- Handling Responses
- Downloading Data
- Decoding JSON
- Codable Protocol
- JSONDecoder
- Handling Decoding Errors
- URLSession
-
Testing
2 topics- Unit Testing
- XCTest Framework
- Writing Test Cases
- Mocking and Stubbing
- UI Testing
- UI Test Cases
- Recording UI Tests
- Assertions
- Unit Testing
iOS Development Swift Programming flashcards — 67 questions with answers
What is Swift and who developed it?
Swift is a general-purpose, compiled, type-safe programming language developed by Apple, first released in 2014. It is used to build apps for iOS, macOS, watchOS, tvOS, and beyond, and is designed to be safe, fast, and expressive as a modern successor to Objective-C.
Name three core design goals (safety features) that distinguish Swift.
Type safety (the compiler enforces types), memory safety (optionals prevent nil misuse, ARC manages memory), and elimination of common errors (variables are always initialized, arrays check bounds, integer overflow is trapped).
What is the difference between a compiled and an interpreted language, and which is Swift?
A compiled language is translated ahead of time into machine code by a compiler before running; an interpreted language is executed line-by-line at runtime. Swift is a compiled language, using the LLVM compiler to produce optimized native machine code.
What IDE and toolchain are used to develop Swift apps for Apple platforms?
Xcode is Apple's official IDE. It bundles the Swift compiler, Interface Builder, the iOS/macOS SDKs, Simulators, Instruments for profiling, and debugging tools. Swift Playgrounds can also be used for interactive learning.
What is a Swift Playground used for?
A Playground is an interactive environment where Swift code runs immediately and shows live results and value history in a sidebar, ideal for prototyping, learning the language, and experimenting without building a full app.
What is Swift Package Manager (SPM)?
Swift Package Manager is the official tool for managing the distribution of Swift code. It automates downloading, compiling, and linking dependencies, configured through a Package.swift manifest file.
What is the difference between declaring a variable with 'let' versus 'var' in Swift?
'let' declares a constant whose value cannot be changed after assignment; 'var' declares a variable that can be reassigned. Swift encourages using 'let' by default for immutability and safety.
What is type inference in Swift? Give an example.
Type inference lets the compiler deduce a variable's type from its initial value, so you can omit the annotation. Example: 'let count = 42' is inferred as Int, and 'let name = "Sam"' is inferred as String.
What is string interpolation in Swift and what is its syntax?
String interpolation builds a new string by embedding values inside a string literal using the syntax \(expression). Example: 'let msg = "Score: \(score)"'.
What is an Optional in Swift and how is it declared?
An Optional is a type that may hold a value or be nil (absence of a value). It is declared by appending '?' to a type, e.g. 'var name: String?'. Under the hood it is an enum with cases .some(value) and .none.
What is optional binding and how does 'if let' / 'guard let' work?
Optional binding safely unwraps an optional. 'if let x = optional { }' runs the block only if the optional has a value, binding it to x. 'guard let x = optional else { return }' unwraps and keeps x in scope for the rest of the function, exiting early if nil.
What does the nil-coalescing operator '??' do?
It provides a default value when an optional is nil. 'a ?? b' returns a's unwrapped value if a is non-nil, otherwise it returns b. Example: 'let n = maybeName ?? "Guest"'.
Compare Swift's basic control-flow loops: for-in, while, and repeat-while.
'for-in' iterates over a sequence or range. 'while' checks its condition before each iteration (may run zero times). 'repeat-while' checks its condition after each iteration, so its body always runs at least once.
How does a Swift 'switch' statement differ from C's, regarding fallthrough and exhaustiveness?
Swift's switch does not fall through implicitly (no break needed); each case ends automatically. It must be exhaustive, covering all possible values or including a 'default' case. Explicit 'fallthrough' is available if desired.
How do you define a function in Swift, and what is the general syntax?
Use the 'func' keyword: 'func name(parameter: Type) -> ReturnType { ... }'. Example: 'func square(_ x: Int) -> Int { return x * x }'.
What are argument labels versus parameter names in Swift functions?
An argument label is used at the call site; a parameter name is used inside the function body. In 'func greet(to name: String)', 'to' is the label and 'name' is the parameter. Using '_' as the label omits it at the call site.
What is a closure in Swift?
A closure is a self-contained block of functionality that can be passed around and used in code. Closures can capture and store references to variables and constants from their surrounding context. Functions are a special named form of closures.
What is trailing closure syntax and why is it used?
When a closure is the last argument to a function, it can be written outside and after the parentheses. Example: 'items.sorted { $0 < $1 }'. It improves readability, especially for functions taking a single closure.
What do 'inout' parameters do in a Swift function?
An 'inout' parameter allows a function to modify the caller's variable directly; changes persist after the call. You must pass the argument with an ampersand: 'func addOne(to x: inout Int)' called as 'addOne(to: &value)'.
Name the four primary collection types in Swift and their key characteristics.
Array (ordered collection of values, allows duplicates), Set (unordered collection of unique values), Dictionary (unordered collection of key-value pairs with unique keys), and Tuple (a fixed group of values that can be different types).
Show the other 47 Swift Programming flashcards
What is the average-case time complexity of looking up a value by key in a Swift Dictionary or checking membership in a Set?
Both are hash-based, giving an average-case lookup of $O(1)$ constant time. Array membership search by value, by contrast, is $O(n)$.
How do the higher-order functions map, filter, and reduce differ?
'map' transforms each element and returns a new collection of the same length. 'filter' returns a new collection containing only elements that satisfy a predicate. 'reduce' combines all elements into a single accumulated value, e.g. 'nums.reduce(0, +)' sums them.
What requirement must a type meet to be stored in a Swift Set or used as a Dictionary key?
It must conform to the Hashable protocol (which also requires Equatable), so the collection can compute hash values and test equality.
In object-oriented Swift, what is the key difference between a class and a struct?
Classes are reference types (instances are shared by reference and managed by ARC) and support inheritance, deinitializers, and identity checks (===). Structs are value types (copied on assignment), do not support inheritance, and get a memberwise initializer automatically.
What is the difference between a stored property and a computed property?
A stored property holds a value directly in the instance's memory. A computed property does not store a value; it provides a getter (and optionally a setter) that calculates a value each time it is accessed.
What are property observers 'willSet' and 'didSet' in Swift?
They observe and respond to changes in a stored property's value. 'willSet' runs just before the value is stored (with 'newValue'); 'didSet' runs just after (with 'oldValue'). They are not called during initialization.
What is the difference between a designated initializer and a convenience initializer in a Swift class?
A designated initializer fully initializes all properties and calls a superclass initializer; it is the primary initializer. A convenience initializer is a secondary initializer marked 'convenience' that must ultimately call a designated initializer in the same class.
How do you override a method in a subclass, and how do you prevent overriding?
Use the 'override' keyword before a method that redefines a superclass method. To prevent overriding, mark the method, property, or class as 'final'.
What is a protocol in Swift?
A protocol defines a blueprint of methods, properties, and other requirements that a conforming type must implement. It defines behavior without providing implementation, enabling polymorphism and abstraction (protocol-oriented programming).
What is a protocol extension and why is it powerful?
A protocol extension provides default method and property implementations to all conforming types. This lets you add shared behavior without inheritance, a cornerstone of Swift's protocol-oriented programming.
What can Swift extensions add to an existing type, and what can they NOT add?
Extensions can add computed properties, methods, initializers, subscripts, and protocol conformance to existing types. They cannot add stored properties or override existing functionality.
What are generics in Swift and what problem do they solve?
Generics let you write flexible, reusable functions and types that work with any type while preserving type safety, avoiding code duplication. Example: 'func swapTwo<T>(_ a: inout T, _ b: inout T)' works for any type T.
What is a type constraint in a generic, and what is its syntax?
A type constraint requires a generic type parameter to conform to a protocol or inherit from a class. Syntax: 'func f<T: Comparable>(a: T, b: T)' constrains T to types conforming to Comparable.
What is an associated type in a Swift protocol?
An associated type is a placeholder name for a type used within a protocol, declared with 'associatedtype'. The conforming type specifies the concrete type. Example: the Collection protocol uses an associated 'Element' type.
What is Automatic Reference Counting (ARC) and what does it manage?
ARC automatically tracks and manages the memory of class instances by counting the number of strong references to each instance. When an instance's strong reference count drops to zero, ARC frees its memory. It applies only to reference types (classes).
What is a strong reference cycle (retain cycle) and why is it a problem?
A strong reference cycle occurs when two class instances hold strong references to each other, so neither's reference count ever reaches zero. This causes a memory leak because ARC can never deallocate them.
How do 'weak' and 'unowned' references differ, and when is each used?
Both break strong reference cycles by not increasing the reference count. A 'weak' reference is optional and becomes nil when the referenced instance is deallocated (use when the other instance may become nil). An 'unowned' reference is non-optional and assumed always valid (use when the other instance has the same or longer lifetime).
What is a capture list in a closure and why does it matter for ARC?
A capture list, written as '[weak self]' or '[unowned self]' at the start of a closure, specifies how captured references are held. It prevents strong reference cycles between a closure and the instance that owns it.
What is Grand Central Dispatch (GCD)?
GCD is Apple's low-level C-based API for managing concurrent code execution. It uses dispatch queues to schedule work (blocks/closures) onto a pool of threads, abstracting away manual thread management.
What is the difference between a serial and a concurrent dispatch queue in GCD?
A serial queue executes one task at a time in FIFO order (each finishes before the next starts). A concurrent queue can execute multiple tasks simultaneously, starting them in order but not waiting for one to finish before starting the next.
What is the difference between 'sync' and 'async' dispatch in GCD?
'async' submits work to a queue and returns immediately without waiting for it to finish. 'sync' submits work and blocks the calling thread until that work completes. Calling 'sync' on the current serial queue causes a deadlock.
Which GCD queue must be used for all UI updates, and why?
The main queue (a serial queue running on the main thread), accessed via DispatchQueue.main. UIKit and SwiftUI are not thread-safe for UI, so all UI updates must occur on the main thread to avoid crashes and glitches.
What is an OperationQueue and how does it differ from a GCD dispatch queue?
OperationQueue is a higher-level, object-oriented API (built on GCD) that manages Operation objects. Unlike raw GCD, it supports adding dependencies between operations, cancelling operations, setting maxConcurrentOperationCount, and adjusting priorities and states (KVO-observable).
How do you make one Operation wait for another to finish using OperationQueue?
Use 'operationB.addDependency(operationA)', which makes operationB start only after operationA finishes. This lets you build ordered execution graphs across concurrent operations.
What do the 'async' and 'await' keywords mean in Swift concurrency?
'async' marks a function as asynchronous, meaning it can suspend. 'await' marks a suspension point where the function may pause to wait for an async call to return, freeing the thread to do other work without blocking it.
What is a Task in Swift's structured concurrency?
A Task represents a unit of asynchronous work that runs concurrently. Creating 'Task { await doWork() }' provides an async context from synchronous code. Tasks can be awaited, cancelled, and can inherit priority and actor context.
What is an 'actor' in Swift concurrency and what problem does it solve?
An actor is a reference type that protects its mutable state from data races by ensuring only one task accesses its isolated state at a time (serialized access). Accessing an actor's properties/methods from outside generally requires 'await'.
How does 'async let' enable parallel asynchronous work?
'async let' starts an asynchronous operation concurrently and binds a placeholder for its future result. Multiple 'async let' bindings run in parallel; you use 'await' when you actually need the values, e.g. 'async let a = fetchA(); async let b = fetchB(); let result = await (a, b)'.
In Swift, how do you define custom error types?
Define a type (commonly an enum) that conforms to the Error protocol. Example: 'enum NetworkError: Error { case timeout, badURL, serverError(code: Int) }'. Conforming enums can carry associated values for extra context.
What is the purpose of the 'throws' keyword in a function signature?
'throws' marks a function as able to throw (propagate) errors. Example: 'func loadData() throws -> Data'. Callers must handle the potential error using try within a do-catch, try?, or try!.
Explain the do-try-catch structure for error handling in Swift.
A 'do' block contains code that may throw; each throwing call is prefixed with 'try'. If an error is thrown, execution jumps to a matching 'catch' block, which receives the error (bound to 'error' by default) so it can be handled.
What is the difference between 'try', 'try?', and 'try!' in Swift?
'try' propagates a thrown error and must be used in a do-catch or throwing function. 'try?' converts the result to an optional, returning nil if an error is thrown. 'try!' asserts that no error will be thrown and crashes at runtime if one is.
What does the 'defer' statement do in Swift error handling and scope management?
A 'defer' block schedules code to run just before the current scope exits, regardless of how it exits (normal return, thrown error, or break). It is commonly used for cleanup like closing files or releasing resources.
What is SwiftUI and how does its programming paradigm differ from UIKit?
SwiftUI is Apple's declarative UI framework introduced in 2019. You describe what the UI should look like for a given state, and the framework renders and updates it automatically. UIKit is imperative, requiring you to manually create, configure, and mutate view objects.
What is the 'body' property of a SwiftUI View and what type does it return?
Every View conforms to the View protocol and must provide a computed 'body' property that returns 'some View' (an opaque type). The body describes the view's content and layout, and SwiftUI re-invokes it to recompute the UI when state changes.
What is the '@State' property wrapper in SwiftUI?
@State declares a source of truth for simple, local, mutable state owned by a single view. SwiftUI stores it outside the view struct and automatically re-renders the view's body whenever the @State value changes.
What is the difference between '@State' and '@Binding' in SwiftUI?
@State creates and owns a piece of local state within a view. @Binding creates a two-way reference (not ownership) to state owned elsewhere, letting a child view read and modify a parent's @State. You pass a binding with the '$' prefix, e.g. '$isOn'.
Compare '@StateObject' and '@ObservedObject' in SwiftUI.
Both work with reference-type models conforming to ObservableObject. @StateObject creates and owns the object, instantiating it once for the view's lifetime. @ObservedObject references an object created and owned elsewhere and does not manage its lifecycle.
What is '@EnvironmentObject' used for in SwiftUI?
@EnvironmentObject injects a shared ObservableObject into the environment so any descendant view can access it without passing it explicitly through each initializer. It is set with the '.environmentObject()' modifier on an ancestor view.
What do the SwiftUI stack views VStack, HStack, and ZStack do?
VStack arranges its child views vertically (top to bottom). HStack arranges them horizontally (leading to trailing). ZStack overlays them along the z-axis (back to front), aligning them on top of one another.
What is a view modifier in SwiftUI and how does chaining order affect the result?
A view modifier is a method that returns a new, modified copy of a view, e.g. '.padding()', '.foregroundColor(.red)'. Order matters because each modifier wraps the previous result; for example applying '.padding()' before vs after '.background()' produces different layouts.
How do you efficiently build a scrolling list of many rows in SwiftUI, and why use identifiable data?
Use 'List' or a ScrollView with 'ForEach'. ForEach needs each element to be uniquely identified (conforming to Identifiable or via a keyPath id) so SwiftUI can diff, reuse, and animate rows correctly as data changes.
What is URLSession used for in Swift?
URLSession is Foundation's API for performing HTTP/HTTPS network requests: downloading and uploading data, files, and streams. It manages a group of related network tasks and supports configuration for caching, timeouts, and background transfers.
Name the three main task types provided by URLSession.
URLSessionDataTask (fetches data into memory, e.g. JSON from an API), URLSessionUploadTask (uploads data or files to a server), and URLSessionDownloadTask (downloads a file to disk, supporting background download).
What is the modern async/await way to fetch data with URLSession, and what does it return?
Call 'let (data, response) = try await URLSession.shared.data(from: url)'. It returns a tuple of the downloaded Data and the URLResponse, throwing on error, eliminating the need for completion-handler callbacks.
After receiving data from URLSession, how do you decode JSON into a Swift type?
Make the target type conform to Decodable (or Codable), then use JSONDecoder: 'let model = try JSONDecoder().decode(MyType.self, from: data)'. The decoder maps JSON keys to the type's properties automatically.
When handling a URLSession completion handler, why must you dispatch UI updates to the main thread?
URLSession delivers its completion handlers on a background thread by default. Since UI updates must occur on the main thread, you wrap them in 'DispatchQueue.main.async { }' (or use @MainActor / await MainActor.run) to avoid crashes.
iOS Development Swift Programming FAQ
What is in the iOS Development Swift Programming syllabus?
iOS Development Swift Programming is split into 9 chapters: Introduction to Swift, Swift Basics, Advanced Swift, Memory Management, Concurrency, Error Handling, SwiftUI, Networking and Testing. Together they contain 21 topics and 64 sub-topics.
How many chapters are in iOS Development Swift Programming?
9 chapters, containing 21 topics and 64 sub-topics. The largest chapter is Swift Basics, with 3 topics.
Are there flashcards for iOS Development Swift Programming?
Yes — a 67-card Swift Programming deck, printed in full in the flashcards section of this page and available in the Examius app with spaced repetition. The free plan covers one exam of your choice, including its flashcards; Examius Pro, a one-time purchase, unlocks every other exam and deck.