Extension๊ณผ Protocol์€ Swift์—์„œ ์ž์ฃผ ์‚ฌ์šฉ๋˜๋Š” ๊ธฐ๋Šฅ์ด๋‹ค. ๊ฐ’์— ์ ‘๊ทผ์ด ๋ถˆ๊ฐ€ํ•จ์—๋„ Extension์œผ๋กœ ์ถ”๊ฐ€ ๊ธฐ๋Šฅ์„ ๊ตฌํ˜„ํ•  ์ˆ˜ ์žˆ๋‹ค.

Extension

  • class, struct, enum ํ™•์žฅ ๊ฐ€๋Šฅ
  • ์›๋ณธ ์†Œ์Šค์— ์ ‘๊ทผํ•  ์ˆ˜ ์—†์–ด๋„ ์‚ฌ์šฉ๊ฐ€๋Šฅ
  • Objective-C์˜ category์™€ ์œ ์‚ฌํ•œ ๊ธฐ๋Šฅ
  • ์ ‘๊ทผ์ œ์–ด ๊ฐ€๋Šฅ
  • ๊ฐ€๋Šฅํ•œ ๊ฒƒ๋“ค
    • computed property ์ถ”๊ฐ€
    • method ์ถ”๊ฐ€
    • initializer ์ถ”๊ฐ€
      • designated intializer, deinitializer ์ถ”๊ฐ€ ๋ถˆ๊ฐ€
      • ์ƒˆ๋กœ์šด initializer, convenience initializer ์ถ”๊ฐ€ ๊ฐ€๋Šฅ
      • ์ถ”๊ฐ€๋œ initializer์—์„œ default initializer, memberwise initializer ํ˜ธ์ถœ ๊ฐ€๋Šฅ
    • subscript ์ถ”๊ฐ€
    • nested type ์ถ”๊ฐ€
    • ํŠน์ • protocol์˜ confirm
    • protocol ํ™•์žฅ