๊ธ€ ์ž‘์„ฑ์ž: ๊ฐœ๋ฐœํ•˜๋Š” ํ›ˆ์ด

2021.12.20 ์˜ค๋Š˜์˜ ๋ฐฐ์›€

์˜ค๋Š˜ ํ•œ ์ผ.

 

You don’t (always) need [weak self]

We will talk about weak self inside of Swift closures to avoid retain cycles & explore cases where it may not be necessary to capture self weakly.

medium.com

  • ์•Œ๊ณ ๋ฆฌ์ฆ˜ ํ’€๊ธฐ
  • ์นด์—” ์ฝ”ํ…Œ ์‘์‹œ

์˜ค๋Š˜ ์ƒˆ๋กœ ๋ฐœ๊ฒฌํ•œ ๊ฒƒ.

  • nonescaping ํด๋กœ์ €์—์„œ๋Š” self๊ฐ€ retain๋˜์ง€ ์•Š๋Š”๋‹ค. ์–ด์ฐจํ”ผ ํ•จ์ˆ˜๊ฐ€ ๋๋‚˜๊ธฐ ์ „์— ํด๋กœ์ €๋„ ๋๋‚˜๊ธฐ ๋•Œ๋ฌธ์—.

์˜ค๋Š˜ ๋Š๋‚€ ๊ฒƒ.

  • ํ•˜ ์ง„์งœ ๋ณ„ ๊ฒƒ๋„ ์•„๋‹Œ๊ฑธ๋กœ ์˜ค์ง€๊ฒŒ ์‚ฝ์งˆํ–ˆ๋‹ค.. ํ•œ๋ฒˆ ๋ฉ˜ํƒˆ์ด ๋ง๋ฆฌ๋‹ˆ๊นŒ ์ƒ๊ฐ๋„ ์•ˆํ•˜๊ณ  ๋ฌด์ž‘์ • ์ˆ˜์ •ํ•˜๊ณ  ๋Œ๋ ค๋ณด๋‹ค๊ฐ€ ๋˜ ๋ฉ˜ํƒˆ ๋‚˜๊ฐ€๊ณ .. ๋‚œ ์™œ ๋ฐœํ‘œ ๊ฐ™์€๊ฑด ๋ฉ˜ํƒˆ ๊ด€๋ฆฌ ์ž˜ํ•˜๋ฉด์„œ ์ฝ”ํ…Œ๋งŒ ๋ณด๋ฉด ์ด๋Ÿด๊นŒ..? ์ŠคํŠธ๋ ˆ์Šค ๋ฐ›๋Š”๋‹ค.. ์นด์—” ์ž˜๊ฐ€...

๋‚ด์ผ์˜ ๊ณ„ํš.

  • ๋ผ์ธ ๋Œ€๋น„ํ•ด์„œ ์Šค์œ„ํ”„ํŠธ๋กœ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋งŽ์ด ํ’€๊ธฐ 
  • Method Dispatch ๊ณ„์† ๋ฏธ๋ฃจ๊ณ ์žˆ๋Š”๋ฐ ์•„๋ฌด๋ž˜๋„ ์ฃผ๋ง์— ํ•ด์•ผ๋  ๊ฒƒ ๊ฐ™๋‹ค.

์˜ค๋Š˜์˜ ๊ฐ์‚ฌ.

  • ๊ฐ์‚ฌํ•  ๋ฉ˜ํƒˆ์€ ์•„๋‹ˆ์ง€๋งŒ ๊ทธ๋ž˜๋„ ๋๊นŒ์ง€ ์ž˜ ํ’€๊ฒŒ ํ•ด์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ด์š”..