How to decide between a Set and an Array in Swift?

  Рет қаралды 306

donny wals

donny wals

Ай бұрын

Learn how you can decide between a Set and an Array in Swift. We go over their semantics as well as their core performance characteristics.
Level up your Swift Concurrency skills with my video course: donnyplus.com/p/practical-swi...
This video is a companion for my blog post about the same topic: www.donnywals.com/how-to-deci...

Пікірлер: 5
@chezchezchezchez
@chezchezchezchez Ай бұрын
I have drums in my computer room! HAHA
@tsbob7847
@tsbob7847 Ай бұрын
Thanks for the video. I’m new to iOS programming. ForEach wants an ordered collection so the set has to be sorted. A number of other SwiftUI things seem to be oriented around arrays. Is this the case in general for SwiftUI? Set Vs Array is insignificant in my small app but curious about SwiftUI Vs data efficiency. Does @Observable mean no longer sorting for every screen update, only if the set changes? Is there a good article on this? Thanks again.
@DonnyWalsdev
@DonnyWalsdev Ай бұрын
I’d say most UI related collection work should be done with array since you don’t want things jumping around in your UI due to Set being unsorted. I don’t know of an article covering the specifics here but @Observable would mean that your UI is stable until the next screen redraw and the Set is accessed again. I would recommend converting to an Array so you have guaranteed stable ordering.
@tsbob7847
@tsbob7847 Ай бұрын
@@DonnyWalsdev Thanks for the response. Obvious from the UI perspective - head slap. Arrays planned for “normal usage” views of item subsets but no fundamental order to the underlying items themselves so I’m starting with a set and a “management/debug” view. Lots to learn. Very different perspective from real time microcontroller systems but I’m enjoying it. I appreciate the info people like yourself, Paul Hudson, Stewart Lynch and others make freely available. They are great learning tools and benefit so many.
Using Closures as Dependencies
15:18
donny wals
Рет қаралды 1,1 М.
I've been using Redis wrong this whole time...
20:53
Dreams of Code
Рет қаралды 344 М.
Secret Experiment Toothpaste Pt.4 😱 #shorts
00:35
Mr DegrEE
Рет қаралды 27 МЛН
路飞太过分了,自己游泳。#海贼王#路飞
00:28
路飞与唐舞桐
Рет қаралды 28 МЛН
50 YouTubers Fight For $1,000,000
41:27
MrBeast
Рет қаралды 205 МЛН
Best KFC Homemade For My Son #cooking #shorts
00:58
BANKII
Рет қаралды 65 МЛН
The moment we stopped understanding AI [AlexNet]
17:38
Welch Labs
Рет қаралды 808 М.
lvalues and rvalues in C++
14:13
The Cherno
Рет қаралды 307 М.
Actor Reentrancy in Swift explained
20:18
donny wals
Рет қаралды 1,4 М.
Nature's Incredible ROTATING MOTOR (It’s Electric!) - Smarter Every Day 300
29:37
Pkl: Apple's New JSON/YAML Killer (I actually want to use this...)
14:30
Generative AI in a Nutshell - how to survive and thrive in the age of AI
17:57
Groundbreaking New Solar Energy System - Too Good to be True?
7:07
Sabine Hossenfelder
Рет қаралды 402 М.
@preconcurrency usage in swift explained
7:52
donny wals
Рет қаралды 488
Python Hash Sets Explained & Demonstrated - Computerphile
18:39
Computerphile
Рет қаралды 112 М.
Nika loves to eat chicken #cat #cats
0:17
Princess Nika cat
Рет қаралды 66 МЛН
Головоломка от дедушки🔥
0:31
FERMACHI
Рет қаралды 18 МЛН
No empty
0:35
Mamasoboliha
Рет қаралды 6 МЛН
САМОЕ СЛОЖНОЕ СОРЕВНОВАНИЕ
0:41
MakkClips
Рет қаралды 1,6 МЛН
How to drink orange juice legally @kahoko6607
0:29
OHIOBOSS SATOYU
Рет қаралды 22 МЛН