iOS ๐Ÿ”ฅ/Swift

Swift์—์„œ Abstract Class ๋งŒ๋“ค๊ธฐ

์šฐ์„  Swift๋Š” Abstract ํด๋ž˜์Šค๋ฅผ ๊ณต์‹์ ์œผ๋กœ ์ง€์›ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

https://github.com/apple/swift-evolution/blob/main/proposals/0026-abstract-classes-and-methods.md ์ดˆ๊ธฐ์— ์ผ๋ถ€๋Ÿฌ POP ์Šคํƒ€์ผ์„ ์œ ๋„ํ•˜๊ธฐ ์œ„ํ•ด์„œ ๊ฒฐ๊ตญ ๋ฆฌ์ ํ–ˆ๋˜ ๊ธฐ๋ก์ด ์žˆ์Šต๋‹ˆ๋‹ค.

 

GitHub - apple/swift-evolution: This maintains proposals for changes and user-visible enhancements to the Swift Programming Lang

This maintains proposals for changes and user-visible enhancements to the Swift Programming Language. - GitHub - apple/swift-evolution: This maintains proposals for changes and user-visible enhance...

github.com

ํ•˜์ง€๋งŒ POP๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ  ์ƒ์†์ด ํ•„์š”ํ•œ ๊ฒฝ์šฐ๊ฐ€ ์žˆ๋“ฏ์ด, Abstract class๊ฐ€ ํ•„์š”ํ•œ ๊ฒฝ์šฐ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. (override function์—์„œ fatalError๋ฅผ ๋‚ด๋Š” ์ฝ”๋“œ๊ฐ€ ์ข…์ข… ์žˆ๊ฑฐ๋“ ์š”.)

์œ„์™€ ๊ฐ™์€ ๊ฒฝ์šฐ, ๋‹ค์Œ ๊ฐ™์€ ์ฐจ์•…์ฑ…(๊ผผ์ˆ˜)์„ ์‚ฌ์šฉํ•ด ์šฐํšŒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

public typealias AbstractClass = _AbstractClass & AbstractClassRequirements

@available(*, deprecated, message: "์ง์ ‘ ์‚ฌ์šฉํ•˜์ง€ ๋ง๊ณ , typealias๋œ Abstract Class๋ฅผ ์‚ฌ์šฉํ•˜์„ธ์š”")
open class _AbstractClass { ... }

public protocol AbstractClassRequirements { ... }

์œ„์™€ ๊ฐ™์€ ๋ฐฉ์‹์„ ์‚ฌ์šฉํ•˜๋ฉด ์ ์–ด๋„ warning์„ ํ‘œ์‹œํ•˜๋ฉด์„œ ์‹ค์ˆ˜๋ฅผ ๋ฐฉ์ง€ํ•˜๋ฉฐ, Abstract ํด๋ž˜์Šค์™€ ๊ฐ™์€ ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.