iOS

[M1 Mac] XCODE(12.5.1) swift life cycle

natrue 2021. 8. 11. 23:17
728x90

1. init

 storyboard ์—์„œ View Controller๋“ค์„ ๋งŒ๋“ค ๊ฒฝ์šฐ View Controller์˜ ๊ฐ์ฒด๊ฐ€ ์ƒ์„ฑ๋  ๋•Œ ์ดˆ๊ธฐํ™” ์ž‘์—…์„ ํ•˜๋Š” ๋ฉ”์†Œ๋“œ.
 ์ฆ‰. ๋ทฐ๋ฅผ ๋งŒ๋“ค ๋•Œ ์‚ฌ์šฉํ•  ์ •๋ณด๋ฅผ ๋ทฐ ์ปจํŠธ๋กค๋Ÿฌ์— ์ €์žฅํ•˜๋Š” ๋‹จ๊ณ„

2. loadView

 ํ™”๋ฉด์— ๋‚˜ํƒ€๋‚ผ View๋ฅผ ๋งŒ๋“œ๋Š” ๋ฉ”์†Œ๋“œ

3. viewDidLoad

 View Controller ๋‹จ ํ•œ ๋ฒˆ๋งŒ ํ˜ธ์ถœ, ์ฃผ๊ธฐ์ ์œผ๋กœ ๋ฐ์ดํ„ฐ๊ฐ€ ๋ณ€๊ฒฝ๋˜๊ฑฐ๋‚˜ ํ•˜๋Š” ํ–‰์œ„๋Š” ๋‹ค๋ฅธ ๋ฉ”์†Œ๋“œ์—์„œ ์ •์˜
  override func viewDidLoad() {
  	super.viewDidLoad()
  }

4. viewWillAppear

  View Controller์˜ ํ™”๋ฉด์ด ์˜ฌ๋ผ์˜ค๊ณ  ๋‚œ ์ดํ›„์— ํ˜ธ์ถœ๋˜๋Š” ๋ฉ”์†Œ๋“œ
  override func viewWillAppear(_ animated: Bool) {
  }

5. viewDidAppear

  View Controller์˜ ๋ทฐ๊ฐ€ ๋ฐ์ดํ„ฐ์™€ ํ•จ๊ป˜ ์™„์ „ํžˆ ํ™”๋ฉด์— ๋‚˜ํƒ€๊ฐ€๊ณ  ํ˜ธ์ถœ๋˜๋Š” ๋ฉ”์†Œ๋“œ
  override func viewDidAppear(_ animated: Bool) { 
  	super.viewDidAppear(animated)
  }

6. viewWillDisappear

  ๋‹ค์Œ View Controller๋กœ ํ™”๋ฉด์ด ์ „ํ™˜๋˜๊ธฐ ์ „, Original View Controller๊ฐ€ ํ™”๋ฉด์—์„œ ์‚ฌ๋ผ์งˆ ๋•Œ ์ด ๋ฉ”์†Œ๋“œ๊ฐ€ ํ˜ธ์ถœ
  override func viewWillDisappear(_ animated: Bool) {
  }

7. viewDidDisappear

  View Controller๋“ค์ด ํ™”๋ฉด์—์„œ ์‚ฌ๋ผ์ง€๊ณ  ๋‚˜์„œ ์ด ๋ฉ”์†Œ๋“œ๊ฐ€ ํ˜ธ์ถœ
  override func viewDidDisappear(_ animated: Bool) {
  }

 

 

 

 

 

 

์ฐธ๊ณ  :  https://pxxxsxzy.tistory.com/34