
IBOutlet, IBAction์ StoryBoard์์ ์ฐ๊ฒฐ๊ณ ๋ฆฌ
@IBOutlet : ๋ฐ์ดํฐ ๊ฐ์ ธ์ค๊ธฐ
@IBAction : Event ๋ฐ์ ์ (์ ๋ ฅ์ด ๋ค์ด์์ ๋) ์ด๋ค ํ๋์ ํ ์ง
ViewController๊ฐ ํ๋ฉด์ ๋์์ง๋ ๋ฉ์๋๋ค์ด ํธ์ถ๋๋ ์ฃผ๊ธฐ๊ฐ ์๋ค๋ ๊ฒ

-init( ) : ์คํ ๋ฆฌ๋ณด๋๋ nib(xib)ํ์ผ์ ํตํด ๋ทฐ์ปจํธ๋กค๋ฌ๋ฅผ ์ด๊ธฐํ. ๋ทฐ๋ฅผ ๋ง๋ค ๋ ์ฌ์ฉํ ์ ๋ณด๋ฅผ ๋ทฐ ์ปจํธ๋กค๋ฌ์ ์ ์ฅ
-loadView( ) : ๋ทฐ๋ฅผ ์ค์ ๋ก ์์ฑํด์ ๋ฉ๋ชจ๋ฆฌ์ ๋ก๋
๋ทฐ ๊ณ์ธต์ ๋ฉ๋ชจ๋ฆฌ์ ๋ก๋ํ ์งํ์ ํธ์ถ๋จ
๋ทฐ๊ฐ ๊ณ์ธต์ ์ถ๊ฐ๋๊ณ , ํ๋ฉด์ ํ์๋๊ธฐ ์ง์ ์ ํธ์ถ๋จ
ํ๋ฉด์ด ์๋ก ์ฌ๋ผ์ฌ ๋๋ง๋ค ์ํํ๊ธฐ ๋๋ฌธ์ ๊ทธ๋๋ง๋ค ์ํํด์ผ ํ ์์
์ ๋ด๋นํ๊ธฐ์ ์ ์ฉ
๋ทฐ๊ฐ ํ๋ฉด์ ํ์๋ ์ดํ์ ํธ์ถ๋จ
๋ทฐ๋ฅผ ๋ณด์ฌ์ค ๋ ํ์ํ ์ถ๊ฐ์ ์ธ ์์
๋ด๋น
๋ทฐ๊ฐ ๊ณ์ธต์์ ์ฌ๋ผ์ง๊ธฐ ์ง์ ์ ํธ์ถ๋จ
๋ทฐ๋ฅผ ์์ฑํ๊ณ ๋์ ํ๋ ํ๋๋ค์ ๋๋๋ฆฌ๋ ์์
์ ํ๊ฑฐ๋ ์์ฑ ๋๋ ์ ํ๋ ์ ๋ณด๋ค์ ์ญ์ ๋๊ธฐ ์ ์ ์ ์ฅํด๋๋ ์์
์ ์ํ
๋ทฐ๊ฐ ๊ณ์ธต์์ ์ฌ๋ผ์ง ๋ค ํธ์ถ๋จ
๋ทฐ๋ฅผ ์จ๊ธฐ๋ ์์
์ ์ํ
์ฐธ๊ณ ์๋ฃ)
https://etst.tistory.com/90
https://jcsoohwancho.github.io/2019-09-21-iOS-%EB%B7%B0%EC%BB%A8%ED%8A%B8%EB%A1%A4%EB%9F%AC%EC%9D%98-%EC%83%9D%EB%AA%85%EC%A3%BC%EA%B8%B0/

๋๋


+) ์๋ฌ ์์ ! ์ด๋ Identity Storyboard ID๋ ์ค์ ํด์ค์ผํจ
// secondViewController ํธ์ถ
let secondViewController = self.storyboard?.instantiateViewController(withIdentifier: "SecondViewController") as! SecondViewController
self.present(secondViewController, animated: true, completion: nil)
@IBOutlet weak var uiTextField: UITextField!
@IBAction func didTapAction(_ sender: Any) {
// uiTextField์ ์ ํ ํ
์คํธ๋ฅผ ์์ data์ ๋ฃ๊ณ ์ถ๋ ฅ
// ์ด๋ป๊ฒ ๋๋ nil๊ฐ์ ๋ฐ์ง ์์ ๊ฒ ๊ฐ์ผ๋ฉด !๋ก ๋ฐ๋ก ์ต์
๋ ํ์ด์ฃผ๊ธฐ
let data : String = uiTextField.text!
// secondViewController ํธ์ถ
let secondViewController = self.storyboard?.instantiateViewController(withIdentifier: "SecondViewController") as! SecondViewController
secondViewController.result = data
self.present(secondViewController, animated: true, completion: nil)
}
@IBOutlet weak var uiResult: UILabel!
var result : String? = "DEFAULT"
์ฑ ์ ๋ฐ์ ์ผ๋ก ์ ์ค์ฒ๋ฅผ ์ธ์ํ ์ ์๋ ๊ฒฝ์ฐ๋ฅผ ๋ค๋ฃธ
- ex) home ๋ฒํผ์ ๋๋ฌ์ ์ฑ ์์ฒด๊ฐ background๋ก ๊ฐ์ ๋, ๋ค์ foreground๋ก ๊ฐ์ ๋
Scene์ ์ฑ UI์ ํ๋์ ๋ณต์ฌ๋ณธ ๋๋ ์ฑ UI์ ํ๋์ ์ธ์คํด์ค

์ ์ฌ์ง์์๋ ์ฑ ํ๋์ ๋ํด scene์ด 2๊ฐ๊ฐ ์์
- AppDelegate : App ์๋ช ์ฃผ๊ธฐ ๊ทธ ์์ฒด(์ฑ์ด ์ค๋น๋๋ค, ์ฑ์ด ์ข ๋ฃ๋๋ค)๋ฅผ ๋ค๋ฃธ
- App ์๋ช ์ฃผ๊ธฐ ๋ด๋ถ์์ Scene์ ์๋ช ์ฃผ๊ธฐ๊ฐ ๋ ๋ฆฝ์ ์ผ๋ก ๋๋ฉฐ ์ด ๋ด์ฉ์ SceneDelegate์์ ํ์ธ๊ฐ๋ฅ
- ์ด ๋์ ์ฐ๊ฒฐ๊ณ ๋ฆฌ๊ฐ SceneSession์ ํตํด ์งํ๋จ
์๋ ๊ทธ๋ฆผ์์
๋นจ๊ฐ : AppDelegate
๊ฒ์ : SceneDelegate


์ฑ์ด ์คํ๋์ง ์์๊ฑฐ๋, ์์ ํ ์ข ๋ฃ๋์ด ๋์ํ์ง ์๋ ์ํ
์ฑ์ด ์ ๋ฉด์์ ์คํ๋๊ณ ์๋ ์ํ
Inactive
- ์ฑ์ด ์คํ๋๋ฉด์ foreground์์ ์คํ์ค์ด์ง๋ง ๋ฏธ๋ฆฌ์๋ฆผ ๋๋ ์ผ์ ์ผ๋ฟ์ด ํ๋ฉด์ ๋ฎ์ฌ์ ์ฑ์ด ์ค์ง์ ์ผ๋ก๋ ์ด๋ฒคํธ๋ฅผ ๋ฐ์ง ๋ชปํ๋ ์ํ
- ์ฑ์ ์ํ ์ ํ ๊ณผ์ ์์ ์ ๊น ๋จธ๋ฌด๋ ๋จ๊ณ
active
- ์ฑ์ด foreground์์ ์คํ์ค์ด๋ฉฐ ์ด๋ฒคํธ๋ฅผ ๋ฐ์ ์ ์๋ ์ํ
- ์ดํ๋ฆฌ์ผ์ด์
์ด ์ค์ง์ ์ผ๋ก ํ๋ํ๊ณ ์๋ ์ํ
์ฑ์ด background์ ์์ผ๋ฉฐ ์คํ๋๋ ์ฝ๋๊ฐ ์๋ ์ํ์ด๋ฉฐ, ๋ค๋ฅธ ์ฑ์ผ๋ก ์ ํ๋์๊ฑฐ๋ ํ ๋ฒํผ์ ๋๋ฌ ๋ฐ์ผ๋ก ๋๊ฐ์ ๋์ ์ํ
Suspended ์ํ๊ฐ ๋๊ธฐ ์ ์ ๊น ๋จธ๋ฌด๋ ์ํ(์ถ๊ฐ ์ฝ๋ ์คํ์ด ํ์ํ๋ฉด ๋จธ๋ฌด๋ ์๊ฐ ์ฐ์ฅ)
์ฝ๋๊ฐ ์คํ์ค์ด์ง๋ง ์ฌ์ฉ์์ ์ด๋ฒคํธ๋ฅผ ๋ฐ์ ์๋ ์์ ์ถ๊ฐ์ ์ธ ์ฝ๋ (ex. ํ์ผ ๋ค์ด๋ก๋)๋ฅผ ์คํํ๋ ๋์ ๋จธ๋ฌด๋ฆ
ํ๋ฒํผ์ ๋๋ฒ ๋๋ฌ ์ฑ์ ๋ค์ ์ด์์ ๋, ์ฒ์๋ถํฐ ์ฌ์คํ๋์ง ์๋๋ค๋ฉด background ์ํ์ ์๋ค๊ฐ ์ฌ๋ผ์จ ๊ฒ
ex) background์์ ์์ ์ ์ฌ์
์ฑ์ด background์ ์์ผ๋ฉฐ ์คํ๋๋ ์ฝ๋๊ฐ ์๋ ์ํ
์ฑ์ ์คํํ ๋ ์ต์ด๋ก ์คํํ ์ฝ๋
ํ์ํ ์ฃผ์ ๊ฐ์ฒด๋ค์ ์์ฑํ๊ณ ์ฑ ์คํ ์ค๋น๊ฐ ๋๋๊ธฐ ์ง์ ์ ํธ์ถ๋จ
applicationWillResignActive
Active -> InActive ์ํ๋ก ์ ์ด๋ ๋ ์คํ
App์ด Inactive ์ํ๋ก ์ ํ๋๊ธฐ ์ง์ ํธ์ถ
sceneWillEnterForeground(_:)
์ฑ์ด background๋ not running์์ foreground๋ก ๋ค์ด๊ฐ๊ธฐ ์ง์ ์ ํธ์ถ
sceneWillResignActive(_:)
App Switcher ๋ชจ๋(ํ ๋ฐ ์ธ์ด ์ฌ๋ ธ์ ๊ฒฝ์ฐ ๋๋ ํ ๋ฒํผ ๋ชจ๋ธ ํ ๋ฒํธ ๋๋ฒ ๋๋ ์ ๊ฒฝ์ฐ)
App์ด Inactive ์ํ๋ก ์ ํ๋๊ธฐ ์ง์ ํธ์ถ
๋ฐ๋ก ํธ์ถ๋๋ ๋ฉ์๋๋ ์์ผ๋ฉฐ background ์ํ์์ ํน๋ณํ ์์ ์ด ์์ ๋ ์ด ์ํ๊ฐ ๋ฉ๋๋ค.
์ฐธ๊ณ ์๋ฃ)
sihyungyou.github.io
[coding-sojin2.tistory.com](https://coding-sojin2.tistory.com/196#:~:text=%EC%95%B1%EC%9D%98%20%EC%83%9D%EB%AA%85%EC%A3%BC%EA%B8%B0%20(App's,%EC%9D%98%20%EA%B3%BC%EC%A0%95%EC%9D%84%20%EB%9C%BB%ED%95%A9%EB%8B%88%EB%8B%A4.)