How to use Dictionaries in Swift | Swift Basics #14

  Рет қаралды 6,696

Swiftful Thinking

Swiftful Thinking

Күн бұрын

Master the usage of dictionaries in Swift with this comprehensive tutorial! Learn how to store and retrieve key-value pairs efficiently using dictionaries. Discover the power of dictionary operations, such as adding, updating, and removing elements. Understand how to iterate over dictionaries and access their values. Start your journey to becoming a skilled Swift developer today and leverage the flexibility and convenience of dictionaries in your projects!
🤙 WELCOME BACK 🤙
WEBSITE: www.swiftful-thinking.com
DISCORD: / discord
GITHUB: github.com/SwiftfulThinking/
SAY THANKS: www.buymeacoffee.com/nicksarno
00:00 Dictionaries
00:00 Intro
01:58 Welcome back!
02:35 Background
03:23 Dictionaries
05:43 Accessing values by key
06:43 Dictionary access is safe
08:15 Dictionaries do not have indexes
10:11 Dictionary keys must be unique
11:09 Adding and removing items
12:39 Dictionaries are not ordered
12:51 Array vs Dictionary
14:15 Dictionary with a Custom Type
17:21 Wrapping up

Пікірлер: 11
@warrenscorner
@warrenscorner Жыл бұрын
Fantastic explanation! I installed an app on my iPad called Unwrap. It’s made by Paul Hudson. Anyone that’s searching KZfaq for SwiftUI has heard of him. Anyway, the app is a great tool for testing your knowledge but not so great at teaching. I bombed the sets and dictionary part! I just didn’t get it. After watching this video it became perfectly clear to me how these things operate. Great lessons Nick!
@AdamTabiev
@AdamTabiev Жыл бұрын
Thank you Nick! Now I understand dictionaries a little more 🕺
@sxmiotb2834
@sxmiotb2834 Жыл бұрын
Thanks 😊
@norsegaud
@norsegaud Жыл бұрын
Hey man, almost through all of these videos. One thing I noticed is that the likes are dropping each video I go further into the playlist. While that's likely because people are giving up, I found myself forgetting to like a video before moving on. Maybe inject in the middle of the video a reminder to like the video and I believe you'll get more.
@lolrie
@lolrie Жыл бұрын
Hey Nick! In your postArray vs. postDict example, how come the dictionary item is an optional that needs to be unwrapped but not the array item? Can't they both potentially be empty?
@SwiftfulThinking
@SwiftfulThinking Жыл бұрын
That’s what I was trying to explain here… accessing keys in a dictionary will return nil if there is no value.. but accessing indexes in an array will crash if there is no item!
@lolrie
@lolrie Жыл бұрын
@@SwiftfulThinking Ahhh right, didn't make the connection there. Thank you!
@yt-1161
@yt-1161 4 ай бұрын
What is the difference between var wordCounts: [String: Int] = [:] and var wordCounts: Set = [:] ?
@nileshjdarji
@nileshjdarji 12 күн бұрын
Can we have a dictionary with Key and value both as Integers. I am working on an app that can keep a log of show seasons and different episodes. I am trying to persist number of episodes for a particular season using dictionary. so I am doing something like seasonInfo = [1:4, 2:3, 3:2] where for season 1 there are 4 episodes, season 2 there are 3 episodes and so on. If this is a bad approach what option do you recommend?
@SwiftfulThinking
@SwiftfulThinking 12 күн бұрын
You can, but more likely your seasons have an ID from your data model or database. So then you’d want to do [seasonId : count] of [String:Int]. This is the most common approach
@911lalala
@911lalala Жыл бұрын
fantatic. Goat lectures in swift history
How to use For Each Loops in Swift | Swift Basics #15
16:11
Swiftful Thinking
Рет қаралды 6 М.
Swift Closures Explained
14:23
Sean Allen
Рет қаралды 62 М.
ПРОВЕРИЛ АРБУЗЫ #shorts
00:34
Паша Осадчий
Рет қаралды 7 МЛН
Spot The Fake Animal For $10,000
00:40
MrBeast
Рет қаралды 195 МЛН
Ouch.. 🤕
00:30
Celine & Michiel
Рет қаралды 26 МЛН
Amazing weight loss transformation !! 😱😱
00:24
Tibo InShape
Рет қаралды 67 МЛН
The Story of Next.js
12:13
uidotdev
Рет қаралды 560 М.
JPEG is Dying - And that's a bad thing
8:09
2kliksphilip
Рет қаралды 78 М.
Why You Shouldn't Nest Your Code
8:30
CodeAesthetic
Рет қаралды 2,6 МЛН
How to use Generics in Swift | Advanced Learning #8
19:24
Swiftful Thinking
Рет қаралды 14 М.
The moment we stopped understanding AI [AlexNet]
17:38
Welch Labs
Рет қаралды 858 М.
This Is Why Python Data Classes Are Awesome
22:19
ArjanCodes
Рет қаралды 799 М.
Swift API Calls for Beginners (Networking) - Async Await & JSON
25:35
Learn JSON in 10 Minutes
12:00
Web Dev Simplified
Рет қаралды 3,1 МЛН
ПРОВЕРИЛ АРБУЗЫ #shorts
00:34
Паша Осадчий
Рет қаралды 7 МЛН