12์ 14์ผ (ํ)
- enum์ static
- Factory Pattern
- topViewController์ visibleViewController ย
[Enum์ static ๋ฉ์๋, ํน์ static ๋ณ์]
- static ๊ฐ์ ๊ฒฝ์ฐ์๋ ๋ฉ๋ชจ๋ฆฌ์ data ์์ญ์ ์กด์ฌํ๋ค.
- data์์ญ์ ํ๋ก๊ทธ๋จ์ด ์คํํ๊ณ ๋๋ ๋ ๊น์ง ๋ฐ์ดํฐ๊ฐ ์ฃฝ์ง์๊ณ ์ด์๋จ์์๋ค.
- ๋ฐ๋ผ์ ์ฌ์ฉ์ฌ๋ถ์ ์๊ด ์์ด ํญ์ ๋ฉ๋ชจ๋ฆฌ๊ฐ ์ด์์๋ค.
- ๋ง๊ตญ๋ฐ๋ํ ํ๋ก์ ํธ ์ค์ enum์ ํ์ฉํ์ฌ static ๋ฉ์๋์ static ๋ณ์๋ฅผ ๋ฌถ์ด๋ ํ์ ๋ค์ด ์กด์ฌํ๋๋ฐ, ์ด๋ฅผ ์ด๋ป๊ฒ ํด๊ฒฐํ๋ฉด ์ข์์ง ๊ณ ๋ฏผํด๋ณด์
[Factory Pattern]
- Factory Pattern์ด๋?
- ๊ฐ์ฒด๋ฅผ ๋ง๋ค๊ธฐ ์ํ ํ๋กํ ์ฝ์ ์ ์ํ์ง๋ง, ์ด๋ค ํด๋์ค์ ์ธ์คํด์ค๋ฅผ ์์ฑํ ์ง์ ๋ํ ๊ฒฐ์ ์ ํ์ ํด๋์ค๊ฐ ์ ํ๋๋ก ํ๋ ๋ฐฉ๋ฒ
- ๊ฐ์ฒด ์์ฑ์ ์๋ธ ํด๋์ค๊ฐ ํ๋๋ก ์ฒ๋ฆฌํ๋ ํจํด
- ์ฆ, ๊ฐ์ฒด ์์ฑ์ ์บก์ํํ ์ ์์ผ๋ฉฐ, ์ด๋ก ์ธํด ๋ถ๋ชจ ํด๋์ค๋ ์์ ํด๋์ค๊ฐ ์ด๋ค ๊ฐ์ฒด๋ฅผ ์์ฑํ๋์ง ๋ชฐ๋ผ๋ ๋๋ค.
- ๊ตฌ์กฐ
- Product
- Creator์ ํ์ ํด๋์ค๊ฐ ์์ฑํ ์ ์๋ ๋ชจ๋ ๊ฐ์ฒด์ ๋์ผํ ํ๋กํ ์ฝ๋ฅผ ์ ์ธํ๋ค
- Concreate Product
- Product๊ฐ ์ ์ธํ ํ๋กํ ์ฝ๋ก ๋ง๋ ์ค์ ๊ฐ์ฒด๋ค.
- Creator
- ์๋ก์ด ๊ฐ์ฒด๋ฅผ ๋ฐํํ๋ ํฉํ ๋ฆฌ ๋ฉ์๋๋ฅผ ์ ์ธํ๋ค.
- ์ฌ๊ธฐ์ ๋ฐํํ๋ ๊ฐ์ฒด๋ Product ํ๋กํ ์ฝ์ ์ค์ํ๊ณ ์์ด์ผ ํ๋ค.
- Concreate Creator
- ๊ธฐ๋ณธ ํฉํ ๋ฆฌ ๋ฉ์๋๋ฅผ override ํ์ฌ ์๋ก ๋ค๋ฅธ Product ๊ฐ์ฒด๋ฅผ ๋ง๋ ๋ค.
- Product
- ์ธ์ ์ฌ์ฉํ ๊น??
- ๋ง๋ค ๊ฐ์ฒด์ ํด๋์ค ์ข ๋ฅ๋ฅผ ์์ธกํ ์ ์์ ๋
- ๋ง๋ค์ด์ผ ํ ๊ฐ์ฒด์ ํ์ ํด๋์ค๋ฅผ ๋ช ์ํ๊ณ ์ถ์ ๋
- ์ข
๋ฅ
- Factory Method Pattern
- Abstract Factory Pattern
[topViewController์ visibleViewController๋ ๊ฐ์ VC์ ๊ฐ๋ฅดํค๋ ๊ฑธ๊น?]
- ์ ๊ทธ๋ฆผ์ ๋ณด๋ฉด topViewController์ visibleViewController๊ฐ ๋งจ ์์ ๊ฐ์ VC์ ๊ฐ๋ฅดํค๊ณ ์๋ค.
- ํ์ง๋ง topViewController์ visibleViewController๋ ๋ฐ๋์ ๊ฐ์ ๊ฒ์ ์๋๋ค.
- ์๋ฅผ ๋ค์ด, ํ๋์ VC๋ฅผ ๋ชจ๋ฌ์ฐฝ์ผ๋ก ๋ํ๋ธ๋ค๋ฉด visibleViewController๋ ๋ชจ๋ฌ VC์ ๊ฐ๋ฅดํฌ ๊ฒ์ด๊ณ , topViewController๋ ๋ณํ์ง ์๋๋ค.
- ์ฐธ๊ณ ๋งํฌ
- https://theswiftdev.com/comparing-factory-design-patterns/
- https://daheenallwhite.github.io/design%20pattern/2019/05/07/Factory-Pattern/
- https://velog.io/@ryan-son/%EB%94%94%EC%9E%90%EC%9D%B8-%ED%8C%A8%ED%84%B4-Factory-pattern-in-Swift
- https://kingso.netlify.app/posts/boostcourse-view-controller/
- https://stackoverflow.com/questions/33395463/in-uinavigationcontroller-what-is-the-difference-between-topviewcontroller-visi