When do we REALLY need to use [weak self]? 🤔

  Рет қаралды 8,137

Vincent Pradeilles

Vincent Pradeilles

Күн бұрын

Пікірлер: 21
@v_pradeilles
@v_pradeilles 2 жыл бұрын
Did you find this explanation useful? Do you think of a situation that doesn't fit in my three examples? Let me know in the comments 🚀
@jeremymagnier
@jeremymagnier 2 жыл бұрын
Hi, good video, what do you think of the use of "unowned", in the 3rd example it can be relevant sometimes to use it, it avoids an unnecessary guard let when you know that if the closure is called self still exists
@v_pradeilles
@v_pradeilles 2 жыл бұрын
@@jeremymagnier good question! There’ll actually be a video on this exact topic later this month 🤫
@jeremymagnier
@jeremymagnier 2 жыл бұрын
@@v_pradeilles I activate the bell so haha
@ShubhamGupta-qo2pt
@ShubhamGupta-qo2pt 2 жыл бұрын
Good example. It will be good if we can have part 2 representing the retain cycle in memory graph
@michaelA-d3m
@michaelA-d3m 9 ай бұрын
Could you also consider an example with multiple nested closures and explain where we need to specify weak self to avoid retain cycles.
@v_pradeilles
@v_pradeilles 9 ай бұрын
Great question! I've actually already covered this topic in a separate video: kzbin.info/www/bejne/aIDXaWmelL2oZ68
@ronnyfenrich
@ronnyfenrich 2 жыл бұрын
This still makes my head hurt :). I wish the compiler could just figure it out for all cases and create a warning/error.
@poluxsaurus1454
@poluxsaurus1454 2 жыл бұрын
I’d say it’s only required in the 3rd example
@rasheshbosamiya1482
@rasheshbosamiya1482 2 жыл бұрын
good example, thank you for sharing
@KEVINKIM2586
@KEVINKIM2586 2 жыл бұрын
really useful content. your videos have been extremely useful for my iOS interview questions thx!
@Noah-qm4ki
@Noah-qm4ki 2 жыл бұрын
Oh!! It's really useful! I am a student studying iOS in South Korea. So I wanted to translate it to Korean and post it on my blog to make more people see it (I am not using it to make any profit! & I'll put a link to the original video in my post.) is it OK?
@captaintech8337
@captaintech8337 2 жыл бұрын
Thanks for the explanation. It's very useful.
@salmansiddiqui9522
@salmansiddiqui9522 2 жыл бұрын
For second example I am trying to crash app without weak self by poping back view controller or making reference nil but its always capturing self and not crashing is it because apple created it ? for our clousres we need to add [weak self ] which escapes ?
@anhhanry7167
@anhhanry7167 Жыл бұрын
thank you for your clip, I've learned something new today, it's helpful, much appreciated, and also I want to ask a simple question: do we need to use [weak self] in case of present AlertController or any animation (any code to use in animation: { } ) ?
@MrWvid
@MrWvid 2 жыл бұрын
Great topic! Another good topic would be when to use unowned. For example in your 3rd example I think unowned would be perfect because when self is deinited handler will also be removed.
@v_pradeilles
@v_pradeilles 2 жыл бұрын
The video on that exact topic is coming later this month 😉
@developerios6096
@developerios6096 2 жыл бұрын
Very informative video vincent, so with closure at line 27 there would not be a memory leak is it correct? There is no reference to the closure, and so, there is no retain to self. But diving a bit deeper: 1)There would be a kind of retain to self anyway, as that closure executes after 2 seconds, even if the ViewModel gets deallocated. Correct? 2) The ViewModel can't get deallocated, until the DispatchQueue.after is executed. Correct?
@Herton17
@Herton17 9 ай бұрын
AÏE LIKE YOURE FRENCH ACCENTE. GOUD VIDEO ALRIGHT
When is it RISKY to use [unowned self] inside a closure? 🤨
7:31
Vincent Pradeilles
Рет қаралды 1,9 М.
No more [weak self] 🤯 (special video for the 1,000 subscribers)
13:35
Vincent Pradeilles
Рет қаралды 7 М.
REAL or FAKE? #beatbox #tiktok
01:03
BeatboxJCOP
Рет қаралды 18 МЛН
Сестра обхитрила!
00:17
Victoria Portfolio
Рет қаралды 958 М.
Difference between weak and unowned in Swift
16:20
Code Cat
Рет қаралды 16 М.
You hate DispatchQueue.main.async { } ? Good news, @MainActor killed it ☠️
11:51
If you're ambitious but lazy, please watch this video...
12:57
Mark Tilbury
Рет қаралды 387 М.
Weak and Unowned Self Closure Memory Leak Fixes
12:21
Lets Build That App
Рет қаралды 57 М.
Strong vs. Weak Swift 5: What is Weak Self (Xcode 11, 2020)
16:41
Here's the ULTIMATE tip to find memory leaks in Xcode!
5:41
Vincent Pradeilles
Рет қаралды 15 М.
Swift 5.9 Released | Prime Reacts
14:36
ThePrimeTime
Рет қаралды 74 М.
How to use Lazy in Swift
9:56
Sean Allen
Рет қаралды 39 М.