How to use async / await keywords in Swift | Swift Concurrency #3

  Рет қаралды 24,269

Swiftful Thinking

Swiftful Thinking

2 жыл бұрын

Async and Await are the two most common keywords used in Swift Concurrency. We will use them in every video going forward - and likely multiple times per video! In this video, we will take an in-depth look into what these keywords are really doing behind the scenes. Understanding this will save you hours of debugging!
Next video: • How to use Task and .t...
Previous video: • Download images with A...
🤙 WELCOME BACK 🤙
WEBSITE: www.swiftful-thinking.com
DISCORD: / discord
GITHUB: github.com/SwiftfulThinking/
SAY THANKS: www.buymeacoffee.com/nicksarno

Пікірлер: 47
@KimbrellBrad
@KimbrellBrad 2 жыл бұрын
I have looked at Async quite a bit from many different sources. This explanation "hit me in the head" or was perfect for my understanding. Thanks for this new series - it is very timely for most of us!
@markaurelius61
@markaurelius61 2 жыл бұрын
That cleared up a lot of my confusion about async await. Thanks for the extra level of detail by showing the current thread numbers.
@kdtechniquesofficial6153
@kdtechniquesofficial6153 Жыл бұрын
Did @Escaping then Combine videos came. After several months Nick explains about Async & Await. And I'm like here we go again. hehe.. Awesome work as always Nick.
@penguinwolf0125
@penguinwolf0125 Жыл бұрын
Simply fantastic simulation, awesome.
@suryakantsharma6761
@suryakantsharma6761 Жыл бұрын
Great work!! Mind-blowing. Keep it up
@bruhmoment3731
@bruhmoment3731 2 жыл бұрын
Very well explained!
@BABEENGINEER
@BABEENGINEER Жыл бұрын
Love this explanation! More videos like this!
@SwiftfulThinking
@SwiftfulThinking Жыл бұрын
Thanks!
@mrtayyabmughal7209
@mrtayyabmughal7209 2 жыл бұрын
Awesome Async!
@alexbui0609
@alexbui0609 Жыл бұрын
Great explanation!
@vladislavwhatislove7156
@vladislavwhatislove7156 Жыл бұрын
the best explanation! Thank you =)
@jonothen2212
@jonothen2212 Жыл бұрын
thanks bro, this is great helped me got rid of that purple warning
@Manish_Sahu
@Manish_Sahu 3 ай бұрын
super easily explained the topic
@GloverCom
@GloverCom Жыл бұрын
Brilliant. Huge Help!
@GilbertLei-ih5lc
@GilbertLei-ih5lc 2 ай бұрын
well explained. thank you!
@andresraigoza2082
@andresraigoza2082 2 жыл бұрын
Awesome!!! Thank you so much.
@lizakryshkovskaya7412
@lizakryshkovskaya7412 Жыл бұрын
Great job! 🙏
@harshyadav9220
@harshyadav9220 2 жыл бұрын
Mybe Simplest Video but also quite Important one.
@Nick-gj9gz
@Nick-gj9gz 2 жыл бұрын
Best one I've seen
@emdutt4012
@emdutt4012 Жыл бұрын
brother Nick, I am using Xcode 14 every time it goes background thread. for example, author1 or something 2 is in the background thread .
@kdtechniquesofficial6153
@kdtechniquesofficial6153 Жыл бұрын
"If it doesn't work, I probably need a new job, but It did work" LOL... 😂😂😂😂😒😒😒
@valentine1925
@valentine1925 Жыл бұрын
good quality tutorials!
@SwiftfulThinking
@SwiftfulThinking Жыл бұрын
Glad you like them!
@AntonR8
@AntonR8 16 күн бұрын
Class property 'current' is unavailable from asynchronous contexts; Thread.current cannot be used from async contexts.; this is an error in Swift 6
@paulancajima
@paulancajima 2 жыл бұрын
Is there a chance await hangs forever? Is there a timeout config?
@josemanuelortizsanchez4983
@josemanuelortizsanchez4983 Жыл бұрын
Thanks!
@kr1s0404
@kr1s0404 Жыл бұрын
at 3:26, I laughed so hard on this hahahahaha ... great work Nick!
@user-mp2wv8db5o
@user-mp2wv8db5o Жыл бұрын
Hi, Thanks a lot for your work! I have a question here. I called function addAuthor1() several times and I never get main thread as you have. What can be the problem here? Or is it some changes in swift concurrency?
@panosjapan7
@panosjapan7 10 ай бұрын
Me too. author1() always runs on the Main thread. Not sure why.
@lolrie
@lolrie 7 ай бұрын
Same - seems like addAuthor1() runs on background thread by default
@3ilz
@3ilz Жыл бұрын
Sorry still confused as to why author2 and something2 are in the background threads even though they are being ran in a MainActor?
@tutecodes3631
@tutecodes3631 Жыл бұрын
In my case when i call addAuther1() from onAppear it shows null in thread name following warning receives Class property 'current' is unavailable from asynchronous contexts; Thread.current cannot be used from async contexts.; this is an error in Swift 6
@brandonhopkins3438
@brandonhopkins3438 Жыл бұрын
same. Thread.current not available in async appaz
@eamdude
@eamdude Жыл бұрын
Why will it not work on macOS? Even running on Catalyst does not show any images, it seems like the URLSession calls doesn't work. If I compile for iPad it is o.k. all three different ways.
@911lalala
@911lalala Жыл бұрын
I have an error in 08:09, and it is called "Class property 'current' is unavailable from asynchronous contexts; Thread.current cannot be used from async contexts.; this is an error in Swift 6" What is it means?
@emdutt4012
@emdutt4012 Жыл бұрын
use only Thread() instead of Thread. current.
@911lalala
@911lalala Жыл бұрын
@@emdutt4012 Thanks bro
@woozoobro
@woozoobro Жыл бұрын
Your Joke is always funny lol
@1slyboy
@1slyboy 8 ай бұрын
NOTE: Class property 'current' is unavailable from asynchronous contexts; Thread.current cannot be used from async contexts.; this is an error in Swift 6 For the purpose of this tutorial the warning can be ignore, but you should avoid trying to get access to Thread.current in production. You can however still use thread.isMainThread
@guillaumeramey
@guillaumeramey 2 жыл бұрын
Hi Nick, thank you for another great video ! I saw that you can add @MainActor to your class so you don't need to specify it inside the functions, is it a good practice or not ?
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
Yea it is good practice, but depending on the situation. I have a whole video on GlobalActors and the @MainActor later in this series!
@wjcnwjcn
@wjcnwjcn 2 ай бұрын
Task.sleep(for:tolerance:clock:) in iOS 16 is nicer than Task.sleep(nanoseconds:) in iOS 13.
@mamazur
@mamazur 10 ай бұрын
.onAppear{ Task{ await viewModel.addAuthor1 No 'async' operations occur within 'await' expression What is going on? Please help
@hashcat5721
@hashcat5721 Жыл бұрын
The author has an error, we do not get into the main stream. line 37 - to be moved to await MainActor.body { } await MainActor.run(body: { let author2 = "Author2 : \(Thread.current)" self.dataArrat.append(author2) let author3 = "Author3 : \(Thread.current)" self.dataArrat.append(author3) })
How to use Task and .task in Swift | Swift Concurrency #4
34:24
Swiftful Thinking
Рет қаралды 23 М.
How to use Do, Try, Catch, and Throws in Swift | Swift Concurrency #1
26:34
Aprenda Construct 3 | Primeiros Passos #01
4:47
Angelo GameDev
Рет қаралды 31
Илья Чикмарев - async/await в Swift
29:19
CocoaHeads
Рет қаралды 10 М.
AsyncIO, await, and async - Concurrency in Python
9:12
Socratica
Рет қаралды 79 М.
Swift API Calls for Beginners (Networking) - Async Await & JSON
25:35
How use async and await
17:38
SwiftSimple
Рет қаралды 1,3 М.
ЗАБУДЬ про DATASOURCE
44:57
Сергей Горбачёв / cmd+B, cmd+R
Рет қаралды 2,4 М.
Swift 5.5. Async/Await
11:46
SwiftBook
Рет қаралды 10 М.