.storyboard
, .xib
포맷의 파일을 수정할 수 있는 에디터
-> 이 두 파일을 컴파일하면 nib
형태의 파일이 된다
특징
기술적 접근
.storyboardc
파일로 앱 번들에 포함된다init(coder:)
메서드를 호출💡 nib
The contents of .xib
and .storyboard
files are stored in XML format. At build time, the .xib
and .storyboard
files are compiled into binary files called nibs
. At runtime, nibs are loaded and the objects they contain are instantiated.
직접 코드를 통해 스토리보드를 불러온다
- 앱 번들에 저장된 nib 파일(.storyboardc)을 메모리로 로드한다
- 스토리보드 인스턴스에 저장되어 있는 VC 정보를 사용하여 VC 를 초기화한다
- instantiateInitialViewController()
- instantiateViewController(withIdentifier:)
- 조건: Storyboard ID 설정
프로젝트 생성 후 info.plist 를 따로 수정하지 않는 상태에서 사용
- Info.plist 는 타겟의 Info 탭에서도 확인 가능
- 프로젝트 생성 시 Info.plist 기본 설정
- Main.storyboard 가 기본 값임을 확인 가능
이 부분을 다른 스토리보드 파일명으로 바꿔줄 수 도 있다.- 앱이 시작되고 Info.plist 설정대로
- Main.storyboard 가 UIStoryboard 인스턴스로 생성되고,
- 그 중 initialViewController 에 해당하는 VC 인스턴스가 앱의 첫 화면으로 보이게 됨.
(UIKit 프레임워크 내부 코드이므로 직접 코드 확인은 불가능)let storyboard = UIStoryboard(name:"Main", bundle: nil) storyboard.instantiateInitialViewController()