iOS Essentials
(intermediate to senior)


Module 1

System design

See here about iOS system-design interviews.


Module 2

Swift, Data structures, and performance

Performance:

  • Understanding Swift Performance, WWDC 2016 talk:

    • Allocation (heap vs. stack; note that Strings longer than the size of pointer are allocated on the heap, not the stack, which means that for lengthy Dictionary keys it would be more performant to use something else, e.g. an enum.)

    • Reference-counting overhead

    • Method dispatch (dynamic vs. static)


Module 3

From Git to the App Store

Material drawn from here.


Module 4

Introduction to Connectivity and offline mode

  1. Google published an Android document called “Connectivity for billions”. What does it mean for iOS development?

  2. What matters in a network connection

  3. Assets already on disk

  4. Being smart about downloading images

  5. Deduplicating vs. retrying requests (e.g. idempotency, interceptors)

  6. Offline-first architecture

  7. Reachability and network interfaces


Module 5

Demystifying the backend

Drawn from Backend Essentials


Module 6

Networking: Talking to the backend

  1. Tooling: Proxyman/Charles, curl/grpcurl, throttling your connection using Link Conditioner (e.g. with 100% packet loss; and why that’s important).

  2. try Data(contentsOf: url) vs. URLSession vs. Alamofire. Using enums to organize your networking code.

  3. Feature vs. platform: request adapters, request retriers

  4. Partial updates: JSON Patch and Field Masks

  5. Streaming instead of request-response. Sample use case: live updates (e.g. for your order or your friends’ location or online status). For example, a “server push” with either a Websocket or gRPC (http/2), or Server-Sent Event (SSE) if you want to use an HTTP GET. Anything but polling.

  6. Push notifications: APNs and using pushes to wake up the app and/or avoid polling

  7. Some common patterns: e.g. pagination vs. streaming

  8. MTCP and the Multipath Entitlement. (For academic ideas inspired by MTCP, see https://web.eecs.umich.edu/~zmao/Papers/MPBond2020.pdf and https://web.eecs.umich.edu/~zmao/Papers/mobicom19.pdf)


Module 7

mobile cybersecurity

  • Concepts and mindset: blast radius, TTL, PII, encryption at rest vs. in transit

  • Checksums and dependency management

  • Helping the user login: password autofill, social logins, magin links, passkeys

  • Onboarding: e.g. permission priming

  • Certificate pinning

  • Keychain and Shared Keychain

  • Deeplinks

  • Authentication and Authorization

    • SHA, rainbow tables, and salt

    • http headers

    • Access tokens vs. refresh tokens, centralizing http-header logic, TTLs

    • Session tokens vs. OAuth2 (with JWTs)

A blog post: https://mas.owasp.org/MASTG/tests/ios/MASVS-STORAGE/MASTG-TEST-0058/


Module 8

mobile machine learning (ML)

  • Your workflow vs. user’s workflow:

  • Deploying an ML model: in the cloud vs. on device

  • Training an ML model: on a cluster (e.g. in the cloud) vs. on device?!

  • Reducing training time: e.g. transfer learning

  • ML is expensive if you have to train your model, etc. But not everything needs ML. There are other types of AI. You might, for example, have an analytic solution to a problem (e.g. for a convex optimization problem).

  • Removal of reflections from images as a convex optimization problem:

    • Yang et al. 2019 paper “Fast Single Image Reflection Suppression via Convex Optimization” [PDF]

    • A 2015 MIT press release about a new algorithm

    • A student project report from EE 368 at Stanford [PDF], which talks about the suitability of these kinds of computationally expensive algorithms for mobile devices and suggests a heuristic.

  • Using n-grams to predict text (e.g. for autofill) and capture context. (N-grams as a precursor to LLMs.)

  • A quick overview of different types of machine learning:

    • Supervised vs. unsupervised

    • Neural nets / deep learning vs. Bayesian vs. Support Vector Machines


caching

  1. The in-memory caches of UserDefaults and CoreData

  2. Key-value stores

  3. Collections: Dictionary vs. Set vs. Array; Sequence and Iterator

  4. Transient/transitory data and eviction policies

  5. NSCache vs. URLCache

  6. URLCache vs. Nuke/SDWebImage/Kingfisher

  7. The /Caches folder in the file system

  8. Opportunitistic caching

  9. /Caches (opportunitistic caching) -> /Application Support (important caching)

  10. Bounded caching: LRU cache

Module 9


Module 10

Persistence

  1. Key-value stores

  2. UserDefaults, UbiquitousKeyValueStore, CoreData, SQLite, Keychain

  3. File system: /Documents, /Application Support, /CloudKit, /tmp
    Apple’s video: https://developer.apple.com/videos/play/tech-talks/204

  4. NSURLIsExcludedFromBackupKey

  5. User-visible data. (The relevant distinction isn’t always “user data” vs. “app data”.)


Module 11

UI/ux, presentation patterns

  1. Frameworks: SwiftUI vs. UIKit

  2. Three different types of UIKit approaches found in legacy code:

    1. Nibs / xibs

    2. Storyboards. (One giant storyboard vs. multiple; motivation: eliminate merge conflicts.)

    3. programmatic subclassing of UIView and activating constraints

  3. What’s new in iOS 17—big changes

  4. UIKit: MVC -> Coordinators and Presenters. Storyboards, nibs, or a programmatic UIView

  5. A view model != MVVM and some simple patterns

  6. Redux, Unidirectional Flow (UDF), and Testable Composable Architecture (TCA)

  7. Scroll hitch rate and table views / lists

  8. Apple’s Human Interface Guidelines

  9. Redux, Unidirectional Flow (UDF), and Testable Composable Architecture (TCA)

  10. Bottom-up design vs. user-centered design vs. human in the loop


Module 12

UI/UX, Localization (“i18n & l10n”)

  1. Locale

    • Metric vs. imperial

  2. Languages

    • Specifying in your test scheme / test plan

    • LocalizableStrings

    • Pluralization: SwiftUI vs. UIKit

    • Why export localizations?

  3. Formatters:

    • dates (plus Date vs. TimeInterval type), currency, etc.


Module 13

Data-driven decision making

  1. “Improved performance by 50%”. Define “performance”.

  2. Monitoring: Crashlytics, Embrace, Firebase, Apple’s tooling.

  3. PII

  4. A/B testing


Module 14

Multithreading: concurrency and thread safety

  1. Watchdog terminations: Code 0x8badf00d

  2. GCD and deadlocks, async vs. sync

  3. How to make objects shared between threads threadsafe? (Also, remember value types?)

  4. Structured concurrency: why async-await is better than completion handlers

  5. Processes vs. threads (same as “coroutines”?)

  6. Concurrency vs. parallelism. For example, DispatchQueue.concurrentPerform function

  7. DispatchGroup (GCD) and TaskGroup (structured concurrency)

  8. Dispatch queues vs. threads. For example, is “main dispatch queue” synonymous with “main thread”?

  9. Priority inversion and the Thread Performance Checker.
    Apple docs: developer.apple.com/.../diagnosing-performance-issues-early

  10. You probably don’t need an OperationQueue or DispatchSemaphores; when a DispatchQueue is not enough and you either need a lock or an actor.

  11. CoreData crashes: thread containment


Module 15

Intra-App communication: When “return” isn’t enough

Communication inside an app. For example, between modules or threads, inter-thread or just decoupled.

  1. One to one vs. one to many (a broadcast / “pub-sub”)

  2. Combine (bye bye RxSwift)

  3. One to one:

    1. A callback vs. delegation

    2. A callback vs. completion handler

    3. A completion handler vs. async-await

    4. SwiftUI and a view model

  4. One to many (a broadcast / “pub-sub”):

    1. Callbacks and delegates. (Yes, it’s possible.)

    2. NSNotificationCenter


Module 16

App Launch

  • The app-launch spectrum: from warm launch to cold launch

  • iOS POV: foreground applications need RAM to run

  • Examples of cold launches: iOS evicts a memory-intensive game from RAM, from disk, from background

  • Tooling for measuring it: “Launch Time” pane in Xcode Organizer

  • Profiling it: “App Launch” template in Instruments

  • Improving it:

    • Third-party embedded frameworks / external dependencies and dylibs (dyld).

    • “Linked Frameworks & Libraries” in Xcode

    • Keep your initial view hierarchy simple

    • Avoid custom drawing—do not override draw (use standard views instead)

    • If you need custom drawing, do not render outsider the rectangle passed to draw func.

  • Tooling: “Static Initializer Calls” in Instruments

  • AppDelegate: initialize nonview functionality lazily rather than on app launch

Apple docs: developer.apple.com/documentation/.../reducing-your-app-s-launch-time


Module 17

Battery

  • Settings > Battery

  • Polling

  • Setting > General > Background App Refresh

  • Push notifications

  • Location services / GPS

  • Streaming?

  • Avoid cellular, download on wifi if possible


Module 18

modularization

  1. Dependency management: SPM vs. CocoaPods vs. Carthage

  2. Dependency graph (+ strongly coupled vs. loosely copuled)

  3. Engineering principles:

    1. IoC

    2. Extensibility

    3. SOLID principles of [OO]D. (For example: stackexchange.com/…/what-are-the-examples-of-breaking-liskov-substitution-principle)

  4. The call site: API design as user-centered design, where the user is another developer.

  5. Static vs. dynamic libs, faster build times vs. faster launch times

  6. Having modules reflect the division of labor among teams and delivery

  7. If a framework is a module, then what is a framework anyway?

    1. Apple’s definition

    2. Google’s definition