How to manage strong & weak references with Async Await | Swift Concurrency #13

Поділитися
Вставка
  • Опубліковано 15 січ 2025

КОМЕНТАРІ • 19

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

    Really nice job, Nick!

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

    This makes it really clear. Thank you so much!

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

    Nice to see you back Nick !

  • @justmytraining4190
    @justmytraining4190 27 днів тому +1

    why i can't just always put [weak self] instead of cancelling tasks manually and managing them?

    • @SwiftfulThinking
      @SwiftfulThinking  27 днів тому +2

      That would solve memory leaks part but it would not cancel the task itself. The task has its own lifecycle and may be doing more than only holding strong references.

    • @indomitabletr1834
      @indomitabletr1834 13 днів тому

      @@SwiftfulThinking I am really curious, what if you never care to put weak self into Task. Let's say you dont mind when your tasks will finish after deiniting your view, but eventually tasks will finish even after view dismissing. So I believe, in the end I won't have memory leak, beacuse, all strong references task already finished. Am I correct?

    • @SwiftfulThinking
      @SwiftfulThinking  13 днів тому +1

      @@indomitabletr1834Yes, that is the default behavior and will work for most cases. However, there are some Tasks (like an AsyncStream) that run forever and you will want to cancel.

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

    Great job Nick, it was a great video as usual!

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

    I wish there was a clone of you that could also teach UIKit and even Android with XML or Jetpack Compose. Your tutorials are simply unrivaled and you’ve completely dominated the SwiftUI tutorial video topics

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

    Hi Nicholas! Are you planning to make some tutorials on SwiftData ?

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

    Thanks. We are building on VisionOS. It is magic 🙂

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

    Thank you so much Nicholas! You have the best iOS development channel on UA-cam, and your tutorials are the best I have found. Why don't you launch your courses on Udemy ?

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

    How can you pump out that much quality content?!?

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

    My man is here

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

    what happens when you're running a task (for example a timer to remove a view on the screen) but while the task is running the user minimizes the app? does the task go on? or will it stop and resume one the app is maximized again?

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

    Nick When cancel things come to topic, using async wait is not looking easy to use, manging someting by ourselve takes us old alloc dealloc objective-c days. What do you think about it, have you ever felt like I have ?

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

    Maybe you could have added the deinit on VM and Service to show it runs after you cancel tasks.

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

    You don't need to add a weak ref inside Task. in order to create a retain cycle we need TWO object that point one on each other with strong ref. when you use Task this is not the case, so you don't need to add weak ref inside of it.

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

    Can we date? 😊