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.
@@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?
@@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.
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
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 ?
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?
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 ?
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.
Really nice job, Nick!
This makes it really clear. Thank you so much!
Nice to see you back Nick !
why i can't just always put [weak self] instead of cancelling tasks manually and managing them?
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.
@@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?
@@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.
Great job Nick, it was a great video as usual!
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
Hi Nicholas! Are you planning to make some tutorials on SwiftData ?
Thanks. We are building on VisionOS. It is magic 🙂
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 ?
How can you pump out that much quality content?!?
My man is here
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?
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 ?
Maybe you could have added the deinit on VM and Service to show it runs after you cancel tasks.
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.
Can we date? 😊