Mobile development

Stage 1 · Lesson 7 of 10

Arrays, dictionaries and sets

Swift fundamentals

has three main collections. An holds items in order. A Dictionary looks up a value by its key.

A Set holds unique items and checks "is it in there?" quickly. All are , so a copy is independent of the original. Learn the operations you will use to prepare data for screens: map, filter, reduce, compactMap (which drops nil values), first(where:), contains, sorted(by:) and Dictionary(grouping:by:).

A dictionary lookup such as scores["ana"] returns an optional, because the key might be missing.

Common trapindexing an array directly with items[0] on an empty array, which crashes; use items.first, which returns an optional.

A question to check yourself, an AI practice session and 2 cheat sheet entries come with the full roadmap. Unlock

Resources for this stage

Start with

  • CourseFree
    100 Days of SwiftUI

    Paul Hudson (Hacking with Swift) · Beginner

    Days 1 to 15 teach Swift, with a checkpoint exercise every other day

Practise

  • Dart, TypeScript, Kotlin and Swift tracks with small exercises and free mentor feedback

Keep handy

Also worth your time

Mark this stage as not done?