๐ ๊ฐ๋ฐ29 [iOS] storyboard์์ custom init์ ํ ๊ฒฝ์ฐ required init์ด ํ์ํ ์ด์ view controller์์ init์ ์์ฑํด์ฃผ๋ ค๋ฉด ์ required init์ด ํ์ํ ๊น? required init์ ํ์ ์์ฑ์๋ก ๋ถ๋ชจ ํด๋์ค์ ์์ฑ๋์ด ์๋ค๋ฉด ์์ ํด๋์ค์์๋ ํ์๋ก ์์ฑํด์ฃผ์ด์ผ ํ๋ค. ๋จ, ์ง์ ์์ฑ์๋ฅผ ๋ฐ๋ก ์์ฑํ๋ ๊ฒฝ์ฐ์๋ง. ๋ถ๋ชจ ํด๋์ค์ ์์ฑ์๋ค์ ๊ทธ๋๋ก ๋ฐ์ ๊ฒฝ์ฐ์๋ ๋ฐ๋ก ์์ฑํด ์ค ํ์๊ฐ ์๋ค. view controller๋ UIViewController๋ฅผ ์์๋ฐ๋๋ค. class firstViewController: UIViewController ๊ทธ๋ฆฌ๊ณ UIViewController๋ NSCoding์ด๋ผ๋ ํ๋กํ ์ฝ์ ์ฑํํ๊ณ ์๋ค. class UIViewController: NSCoding ์ด NSCoding ํ๋กํ ์ฝ์๋ required init์ผ๋ก NSCoder๋ฅผ .. 2023. 11. 9. [Swift]super.init()์ด ๋ฐ๋์ ํ์ํ๋ ๊ฒฝ์ฐ ์๋ ํ์ญ๋๊น, ๋ฏผํธ์ ๋๋ค. ๐ super.init()์ ๋ํด์ ์ด๊ฒ์ ๊ฒ ์ฐพ์๋ณด๋ค ์ ๊ธฐํ ๊ฒฝ์ฐ๋ฅผ ์ฐพ์์ต๋๋ค.class A { init(some: String) { print("a") }} A์ ๊ฐ์ด ๋งค๊ฐ๋ณ์๊ฐ ์๋ init์ ๊ฒฝ์ฐ์๋, ์์์ ํด์ ๋ด๋ถ์ ๋ณํ๋ฅผ ์ค ๋class B: A { override init(some: String) { super.init(some: some) print("b") }}๋ฐ๋์ super.init์ ๋ถ๋ฌ์ผ ํ๋ค๋ ์๋ฌ ๋ฉ์ธ์ง๊ฐ ๋ด์ต๋๋ค. 2๋จ๊ณ ์ด๊ธฐํ์์ ๋ณด๋ฉด, customize๋ ์ด๊ธฐํ๋ 1. superClass์ subclass๊ฐ ์์ ๋ subClass ์ด๊ธฐํ 2. superClass ์ด๊ธฐํ ์์ผ๋ก ์ฌ๋ผ๊ฐ.. 2023. 11. 8. ์ด์ 1 2 3 4 ๋ค์