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

Поділитися
Вставка
  • Опубліковано 29 гру 2024

КОМЕНТАРІ • 49

  • @KimbrellBrad
    @KimbrellBrad 2 роки тому +11

    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 роки тому +5

    That cleared up a lot of my confusion about async await. Thanks for the extra level of detail by showing the current thread numbers.

  • @stu7032
    @stu7032 3 дні тому

    Really easy to understand and useful.

  • @Manish_Sahu
    @Manish_Sahu 9 місяців тому +1

    super easily explained the topic

  • @kavinda_dilshan_paramsoodi
    @kavinda_dilshan_paramsoodi Рік тому

    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.

  • @jonothen2212
    @jonothen2212 2 роки тому +1

    thanks bro, this is great
    helped me got rid of that purple warning

  • @emdutt4012
    @emdutt4012 Рік тому +1

    brother Nick, I am using Xcode 14 every time it goes background thread. for example, author1 or something 2 is in the background thread .

  • @penguinwolf0125
    @penguinwolf0125 2 роки тому +1

    Simply fantastic simulation, awesome.

  • @tutecodes3631
    @tutecodes3631 Рік тому +2

    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

  • @suryakantsharma6761
    @suryakantsharma6761 Рік тому

    Great work!! Mind-blowing. Keep it up

  • @911gogogo
    @911gogogo 2 роки тому +1

    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 2 роки тому +5

      use only Thread() instead of Thread. current.

    • @911gogogo
      @911gogogo 2 роки тому

      @@emdutt4012 Thanks bro

  • @mrtayyabmughal7209
    @mrtayyabmughal7209 2 роки тому +2

    Awesome Async!

  • @vidorahi
    @vidorahi 4 місяці тому

    If it possible you can update this for swift 6 and Observation Framework

  • @harshyadav9220
    @harshyadav9220 2 роки тому

    Mybe Simplest Video but also quite Important one.

  • @АлексейШестаков-ь8н

    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?

    • @gibber1sh-c6w
      @gibber1sh-c6w Рік тому +1

      Me too. author1() always runs on the Main thread. Not sure why.

    • @lolrie
      @lolrie Рік тому

      Same - seems like addAuthor1() runs on background thread by default

  • @kavinda_dilshan_paramsoodi
    @kavinda_dilshan_paramsoodi Рік тому +1

    "If it doesn't work, I probably need a new job, but It did work" LOL... 😂😂😂😂😒😒😒

  • @bruhmoment3731
    @bruhmoment3731 2 роки тому +1

    Very well explained!

  • @alexbui0609
    @alexbui0609 Рік тому

    Great explanation!

  • @paulancajima
    @paulancajima 2 роки тому +1

    Is there a chance await hangs forever? Is there a timeout config?

  • @GilbertLei-ih5lc
    @GilbertLei-ih5lc 8 місяців тому

    well explained. thank you!

  • @vladislavwhatislove7156
    @vladislavwhatislove7156 2 роки тому

    the best explanation! Thank you =)

  • @3ilz
    @3ilz 2 роки тому

    Sorry still confused as to why author2 and something2 are in the background threads even though they are being ran in a MainActor?

  • @GloverCom
    @GloverCom Рік тому

    Brilliant. Huge Help!

  • @BABEENGINEER
    @BABEENGINEER 2 роки тому

    Love this explanation! More videos like this!

  • @kr1s0404
    @kr1s0404 2 роки тому

    at 3:26, I laughed so hard on this hahahahaha ... great work Nick!

  • @Nick-gj9gz
    @Nick-gj9gz 2 роки тому

    Best one I've seen

  • @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.

  • @valentine1925
    @valentine1925 Рік тому

    good quality tutorials!

  • @lizakryshkovskaya7412
    @lizakryshkovskaya7412 2 роки тому

    Great job! 🙏

  • @AntonR8
    @AntonR8 6 місяців тому +6

    Class property 'current' is unavailable from asynchronous contexts; Thread.current cannot be used from async contexts.; this is an error in Swift 6

  • @andresraigoza2082
    @andresraigoza2082 2 роки тому

    Awesome!!! Thank you so much.

  • @josemanuelortizsanchez4983
    @josemanuelortizsanchez4983 2 роки тому

    Thanks!

  • @woozoobro
    @woozoobro Рік тому

    Your Joke is always funny lol

  • @1slyboy
    @1slyboy Рік тому

    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 роки тому +1

    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 роки тому +4

      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 8 місяців тому

    Task.sleep(for:tolerance:clock:) in iOS 16 is nicer than Task.sleep(nanoseconds:) in iOS 13.

  • @mamazur
    @mamazur Рік тому

    .onAppear{ Task{ await viewModel.addAuthor1 No 'async' operations occur within 'await' expression What is going on? Please help

  • @hashcat5721
    @hashcat5721 2 роки тому +1

    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)
    })