-
[iOS] instantiateViewController(withIdentifier:)iOS 2022. 2. 19. 01:41
Instance Method
instantiateViewController(withIdentifier:)
์ง์ ๋ identifier๋ก ๋ทฐ์ปจํธ๋กค๋ฌ๋ฅผ ๋ง๋ค๊ณ ์คํ ๋ฆฌ๋ณด๋์ ๋ฐ์ดํฐ๋ก ์ด๊ธฐํํ๋ค.
Declaration
func instantiateViewController(withIdentifier identifier: String) -> UIViewControllerParameters
identifier์คํ ๋ฆฌ๋ณด๋ ํ์ผ์์ ๋ทฐ์ปจํธ๋กค๋ฌ๋ฅผ ๊ณ ์ ํ๊ฒ ์๋ณํ๋ identifier ๋ฌธ์์ด. ๋์์ธ ํ์์์ ์ธํฐํ์ด์ค ๋น๋์์ ๋ทฐ์ปจํธ๋กค๋ฌ์ Storyboard ID ์์ฑ์ ๋์ผํ ๋ฌธ์์ด์ ๋ฃ๋๋ค. ์ด identifier๋ ๋ทฐ์ปจํธ๋กค๋ฌ ๊ฐ์ฒด ์์ฒด์ ์์ฑ์ด ์๋๋ค. ์คํ ๋ฆฌ๋ณด๋๋ ์ด identifier๋ฅผ ์ฌ์ฉํ์ฌ ๋ทฐ์ปจํธ๋กค๋ฌ์ ์ ํฉํ ๋ฐ์ดํฐ๋ฅผ ์ฐพ๋๋ค.
์ง์ ๋ ์๋ณ์๊ฐ ์คํ ๋ฆฌ๋ณด๋ ํ์ผ์ ์๋ ๊ฒฝ์ฐ, ์ด ๋ฉ์๋๋ ์์ธ๋ฅผ ๋ฐ์์ํจ๋ค.
Return Value
์ง์ ๋ identifier ๋ฌธ์์ด์ ๋์ํ๋ ๋ทฐ์ปจํธ๋กค๋ฌ. ๋ง์ฝ ์ง์ ๋ identifier๋ฅผ ๊ฐ์ง ๋ทฐ์ปจํธ๋กค๋ฌ๊ฐ ์๋ค๋ฉด ๋ฉ์๋๋ ์์ธ๋ฅผ ๋ฐ์์ํจ๋ค.
Discussion
์ด ๋ฉ์๋๋ฅผ ์ฌ์ฉํ์ฌ ์ฝ๋๋ก ํ์ํ ๋ทฐ์ปจํธ๋กค๋ฌ ๊ฐ์ฒด๋ฅผ ์์ฑํ๋ค. ์ด ๋ฉ์๋๋ฅผ ํธ์ถํ ๋๋ง๋ค ๋ทฐ์ปจํธ๋กค๋ฌ๋
init(coder:)๋ฉ์๋๋ฅผ ์ฌ์ฉํ์ฌ ๋ทฐ์ปจํธ๋กค๋ฌ์ ์๋ก์ด ์ธ์คํด์ค๋ฅผ ์์ฑํ๋ค.
ใ ค
ใ ค'iOS' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[iOS] MVC (Model-View-Controller) (0) 2022.03.17 [iOS] TabBarItem ์ด๋ฏธ์ง ๋ณ๊ฒฝํ ๋ ์ฃผ์ํ ์ (0) 2022.02.23 [iOS] ๋ทฐ์ ์ํ๋ณํ ๊ฐ์ง ๋ฉ์๋ (0) 2022.02.18 [iOS] addTarget(_:action:for:) (0) 2022.02.16 [iOS] Cocoapods pod install ์ค์น ์๋ฌ ์ ํด๊ฒฐ ๋ฐฉ๋ฒ (0) 2022.02.13