As reference types, closures face the same challenges that classes do when it comes to memory management. Use weak and unowned with closure captures to prevent leaks.
Hi Ray, thanks for your awesome tut. quick question, if we wanna run print(galileo.name) then we should @escaping for the closure(time: on video, 12:55)? thanks
Not sure I understand your question but let me take a guess. (Apologies if I missed in advance. )
@escaping only applies to closures so you do not need it in the case of print(galileo.name) However if you wanted to wrap the Dispatch in a function and pass a closure into that, it would need to escape. Example:
Hey Ray, i am confused about the reason as to why after we assign weak reference semantics to galieleo, we make it a strong reference using guard in the next line.
Thanks for the very informative video series. I have just a small correction to the slides for this video. The vertical text on the right side of slides 5 and 7 declares the increment function to be of the type (Int) -> Int, but the code in the box on the left declares it to be of type as (Int) -> Void, which is how the function is actually defined.