Programming in Swift: Fundamentals

Oct 19 2021 · Swift 5.5, iOS 15, Xcode 13

Part 4: More Collections

29. Accessing & Working with Dictionaries

Episode complete

Play next episode

About this episode

Leave a rating/review

See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 28. Creating & Populating Dictionaries Next episode: 30. Challenge: Dictionaries

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Notes: 29. Accessing & Working with Dictionaries

Apple’s Swift Dictionary documentation:

Update Notes: The student materials have been reviewed and are updated as of October 2021.

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

Hey - welcome back! In the previous video, you learned about how to create dictionaries, how key-value storage works, and how to add and update elements in your dictionary. But there’s a whole lot more to dictionaries than just that!

namesAndPets["Captain Ahab"]
let captainAhabPet = namesAndPets["Captain Ahab"] ?? "No white whale for Captain Ahab"
namesAndPets.removeValue(forKey: "Goku")
namesAndPets["Hiccup"] = nil
for (character, pet) in namesAndPets {

for (character, pet) in namesAndPets {
  print("\(character) has a \(pet)")
for (name, _) in namesAndPets {
for pet in namesAndPets.keys {
for pet in namesAndPets.values {