๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
IOS๐ŸŽ/iOS+Swift

[iOS] iOS13์ดํ›„์˜ AppDelegate์™€ SceneDelegate

by Jouureee 2021. 4. 7.

iOS 12 ์ด์ „์˜ appDelegate์˜ ์—ญํ•  

1. ํ•˜๋‚˜์˜ ์•ฑ์— ํ•˜๋‚˜์˜ window๊ฐ€ ์กด์žฌ!

 

iOS 13 ์ดํ›„์˜ appDelegate์™€ scenceDelegate์˜ ์—ญํ• 

1. window ๊ฐœ๋…์ด scene์œผ๋กœ ๋Œ€์ฒด๋˜๊ณ  ํ•˜๋‚˜์˜ ์•ฑ์— ์—ฌ๋Ÿฌ scene์„ ๊ฐ€์งˆ์ˆ˜ ์žˆ๊ฒŒ ๋˜์—ˆ๋‹ค. 

 

2. UILifecycle์„ ๋”์ด์ƒ ApplDelegate์—์„œ ๊ด€๋ฆฌํ•˜์ง€ ์•Š๋Š”๋‹ค.

 

3. AppDelegate์— Session Lifecycle ์—ญํ• ์ด ์ถ”๊ฐ€๋˜์—ˆ๋‹ค.

Scene Session์ด ์ƒ์„ฑ(created)๋˜๊ฑฐ๋‚˜ ์‚ญ์ œ(discarded)๋ ๋•Œ Appdelegate์— ์•Œ๋ฆฌ๋Š” ๋ฉ”์†Œ๋“œ(Scene Session)๊ฐ€ ์ถ”๊ฐ€๋˜์—ˆ๋‹ค.

Scene Session์€ ์•ฑ์—์„œ ์ƒ์„ฑํ•œ ๋ชจ๋“  scene์˜ ์ •๋ณด๋ฅผ ๊ด€๋ฆฌํ•œ๋‹ค.

 

Scene์ด๋ž€?

๊ธฐ์กด์˜ window ๊ฐœ๋…์—์„œ ํ™•์žฅ๋œ ๋ฒ„์ „์ธ๊ฑฐ ๊ฐ™๋‹ค. ๊ธฐ์กด ์•ฑ์€ window ํ•˜๋‚˜๋ฐ–์— ๊ฐ€์ง€์ง€ ๋ชปํ–ˆ์œผ๋‚˜ ๋ฉ€ํ‹ฐ ๋ทฐ๊ฐ€ ๊ฐ€๋Šฅํ•ด์กŒ๊ธฐ ๋•Œ๋ฌธ!

app switcher๋ฅผ ํ†ตํ•ด ์—ฌ๋Ÿฌ scene์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

Scene์—๋Š” UI ํ•˜๋‚˜์˜ ์ธ์Šคํ„ด์Šค๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” window์™€ viewController๊ฐ€ ๋“ค์–ด์žˆ๋‹ค. 

Scene๋“ค์€ ๊ฐ™์€ ๋ฉ”๋ชจ๋ฆฌ์™€ ์•ฑ ํ”„๋กœ์„ธ์Šค ๊ณต๊ฐ„์„ ๊ณต์œ ํ•˜๋ฉฐ ์„œ๋กœ ๋™์‹œ์— ์‹คํ–‰๋œ๋‹ค. 

 

 

Scene Session์ด๋ž€?

scene ๊ณ ์œ ์˜ ๋Ÿฐํƒ€์ž„ ์ธ์Šคํ„ด์Šค๋ฅผ ๊ด€๋ฆฌํ•œ๋‹ค. ์‚ฌ์šฉ์ž๊ฐ€ ์•ฑ์— ์ƒˆ๋กœ์šด scene์„ ์ถ”๊ฐ€ํ•˜๊ฑฐ๋‚˜ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์ ์œผ๋กœ scene ์š”์ฒญํ•˜๋ฉด ์‹œ์Šคํ…œ์€ ๊ทธ scene์„ ์ถ”์ ํ•˜๋Š” session๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•œ๋‹ค. ๊ทธ session์— ๊ณ ์œ  ์‹๋ณ„์ž์™€ scene์˜ ๊ตฌ์„ฑ ์„ธ๋ถ€์‚ฌํ•ญ์ด ๋“ค์–ด์žˆ๋‹ค.

uikit๋Š” session ์ •๋ณด๋ฅผ ๊ทธ scene ์ž์ฒด์˜ ์ƒ์•  ๋™์•ˆ ์œ ์ง€ํ•˜๊ณ  app switcher์—์„œ ์‚ฌ์šฉ์ž๊ฐ€ ๊ทธ scene์„ ํด๋กœ์ง•ํ•˜๋Š” ๊ฒƒ์— ๋Œ€์‘ํ•˜์—ฌ ๊ทธ session์„ ํŒŒ๊ดดํ•œ๋‹ค. session๊ฐ์ฒด๋Š” ์ง์ ‘ ์ƒ์„ฑํ•˜์ง€ ์•Š๊ณ  uikit๊ฐ€ ์•ฑ์˜ ์‚ฌ์šฉ์ž ์ธํ„ฐํŽ˜์ด์Šค์— ๋Œ€์‘ํ•˜์—ฌ ์ƒ์„ฑ๋œ๋‹ค.

 

appDelegate๊ฐ€ ํ•˜๋Š” ์ผ

์šฐ์„  appDelegate.swift๋ฅผ ์‚ดํŽด๋ณด์ž

class AppDelegate: UIResponder, UIApplicationDelegate {
	...
}

UIApplicationDelegate๋ฅผ ํ”„๋กœํ† ์ฝœ๋กœ ์ฑ„ํƒํ•˜๊ณ  ์žˆ๋‹ค. 

์•ˆ์— ์•ฑ์˜ ์ƒ๋ช…์ฃผ๊ธฐ์™€ ๊ด€๋ จ๋œ ๋ฉ”์†Œ๋“œ๋“ค์„ ๋ณด๋ฉด 

 

didFinishLaunchingWithOptions

//์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ์‹คํ–‰๋œ ์งํ›„ ์‚ฌ์šฉ์ž์˜ ํ™”๋ฉด์— ๋ณด์—ฌ์ง€๊ธฐ ์ง์ „์— ํ˜ธ์ถœ
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool

 

 

willFinishLaunchingWithOptions

//์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ์ตœ์ดˆ ์‹คํ–‰๋  ๋•Œ ํ˜ธ์ถœ๋˜๋Š” ๋ฉ”์†Œ๋“œ 
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool	

 

applicationWillResignActive

//์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด InActive ์ƒํƒœ๋กœ ์ „ํ™˜๋˜๊ธฐ ์ง์ „์— ํ˜ธ์ถœ 
func applicationWillResignActive(_ application: UIApplication)

 

applicationDidEnterBackground

//์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ๋ฐฑ๊ทธ๋ผ์šด๋“œ ์ƒํƒœ๋กœ ์ „ํ™˜๋œ ์งํ›„ ํ˜ธ์ถœ
func applicationDidEnterBackground(_ application: UIApplication)

applicationWillEnterForeground

//์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด Active ์ƒํƒœ๊ฐ€ ๋˜๊ธฐ ์ง์ „, ํ™”๋ฉด์— ๋ณด์—ฌ์ง€๊ธฐ ์ง์ „์— ํ˜ธ์ถœ 
func applicationWillEnterForeground(_ application: UIApplication)

 

applicationDidBecomeActive

//์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด Active ์ƒํƒœ๋กœ ์ „ํ™˜๋œ ์งํ›„ ํ˜ธ์ถœ
func applicationDidBecomeActive(_ application: UIApplication)

 

applicationWillTerminate

//์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ์ข…๋ฃŒ๋˜๊ธฐ ์ง์ „์— ํ˜ธ์ถœ 
func applicationWillTerminate(_ application: UIApplication)

์ด ๋ฉ”์†Œ๋“œ๋“ค์€ ์•ฑ์˜ ์ƒํƒœ ๋ณ€ํ™”์— ๊ด€ํ•œ ๋ฉ”์†Œ๋“œ๋“ค์ด๋‹ค.

UIApplicationDelegate ํ”„๋กœํ† ์ฝœ ๋‚ด์— ๋“ค์–ด์žˆ์œผ๋ฉฐ ์ด๋ฅผ AppDelegate๊ฐ€ ํ”„๋กœํ† ์ฝœ๋กœ ์ฑ„ํƒํ•˜๊ณ  ์žˆ๋‹ค. ์ฆ‰ ์•ฑ ์ƒํƒœ ๋ณ€ํ™”์— ๊ด€ํ•œ ์ž‘์—…๋“ค์„ ์•ฑ ์ „๋ฐ˜์ ์ธ ๋ถ€๋ถ„์„ ๊ด€์—ฌํ•˜๋Š” Appdelegate ๊ฐ์ฒด์—๊ฒŒ ์•Œ๋ฆด ์ˆ˜ ์žˆ๋„๋ก ์ƒํ˜ธ์ž‘์šฉํ•˜๊ณ  ์žˆ๋‹ค. ์—ฌ๊ธฐ๊นŒ์ง€๋Š” ์ƒํƒœ๋ณ€ํ™”๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” UIApplicationDelegate์™€ ์•ฑ ์ „๋ฐ˜์  ๋ถ€๋ถ„์„ ๊ด€์—ฌํ•˜๋Š” Appdelegate์— ๊ด€ํ•œ ๊ด€๊ณ„์ด๋‹ค.

 

์œ„์—์„œ๋„ ๋ณด์‹œ๋‹ค์‹œํ”ผ ios 13์ดํ›„์—๋Š” app ๊ธฐ๋ฐ˜ -> scene ๊ธฐ๋ฐ˜์œผ๋กœ ํ™•์žฅ๋˜์—ˆ๋Š”๋ฐ

์ด์—๋Œ€ํ•œ UIApplicationDelegate์ด ์ˆ˜ํ–‰ํ•˜๋Š” ์•ฑ์˜ ์ƒ๋ช…์ฃผ๊ธฐ์— ๋Œ€ํ•ด App ๊ธฐ๋ฐ˜๊ณผ Scene๊ธฐ๋ฐ˜์„ ๊ฐ๊ฐ ์‚ดํŽด๋ณด๊ณ  ๊ทธ ์ฐจ์ด์ ์— ๋Œ€ํ•œ AppDelegate์— Session LifeCycle์ด ์ถ”๊ฐ€๋œ ์ด์œ ์™€ SceneDelegate์— UILifeCycle์ด ์ถ”๊ฐ€๋œ ์ด์œ ๋ฅผ ์ฐพ์•„๋ณด์ž

 

1) ios 12 ์ด์ „ - ์•ฑ ๊ธฐ๋ฐ˜ ๋ผ์ดํ”„ ์‚ฌ์ดํด ์ด๋ฒคํŠธ

- iOS 12 ๋ฐ ์ด์ „ ๋ฒ„์ „์—์„œ๋Š” UIApplicationDelegate ๊ฐ์ฒด๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ˆ˜๋ช…์ฃผ๊ธฐ ์ด๋ฒคํŠธ์— ์‘๋‹ตํ•œ๋‹ค.

 

AppDelegate๋Š” ๋ณ„๋„ ํ™”๋ฉด์— ํ‘œ์‹œ๋œ ์ฐฝ์„ ํฌํ•จํ•˜์—ฌ ๋ชจ๋“  ์•ฑ์˜ ์ฐฝ์„ ๊ด€๋ฆฌํ•˜๋Š” ์—ญํ• ์„ ์ˆ˜ํ–‰ํ•˜๋ฉฐ ๋”ฐ๋ผ์„œ ์•ฑ์˜ ์ƒํƒœ ์ „ํ™˜์— ๋”ฐ๋ผ ์•ฑ ์ „์ฒด์˜ UI๊ฐ€ ๋ฐ”๋€Œ๋„๋ก ์ƒํ˜ธ์ž‘์šฉํ•œ๋‹ค.

 

์‹คํ–‰ ํ›„ UI๊ฐ€ ํ™”๋ฉด์— ํ‘œ์‹œ๋ ์ง€ ์—ฌ๋ถ€์— ๋”ฐ๋ผ์„œ ์‹œ์Šคํ…œ์ด ์•ฑ์„ ๋น„ํ™œ์„ฑ์ƒํƒœ ๋˜๋Š” ๋ฐฑ๊ทธ๋ผ์šด๋“œ์ƒํƒœ๋กœ ์ „ํ™˜ํ•œ๋‹ค.

foreground ๋กœ ์‹œ์ž‘ํ• ๋•Œ ์‹œ์Šคํ…œ์€ ์•ฑ์„ ์ž๋™์œผ๋กœ active ์ƒํƒœ๋กœ ์ „ํ™˜ํ•œ๋‹ค.

๊ทธ ํ›„์— ์ƒํƒœ๋Š” ์•ฑ์ด ์ข…๋ฃŒ๋ ๋•Œ๊นŒ์ง€ ํ™œ์„ฑ/ ๋น„ํ™œ์„ฑ/ ๋ฐฑ๊ทธ๋ผ์šด๋“œ๋กœ๋งŒ ๋ณ€ํ•œ๋‹ค.

 

 

 

  1. not running  - ์•„์ง ์‹คํ–‰ํ•˜์ง€ ์•Š๋Š” ์ƒํƒœ์ด๊ฑฐ๋‚˜ ์‹คํ–‰์ค‘์ธ๋ฐ ์‹œ์Šคํ…œ์— ์˜ํ•ด ์ข…๋ฃŒ๋œ ์ƒํƒœ
  2. inActive - ์•ฑ์ด foreground ์ƒํƒœ๋กœ ๋Œ์•„๊ฐ€์ง€๋งŒ ์ด๋ฒคํŠธ๋Š” ๋ฐ›์ง€ ์•Š๋Š” ์ƒํƒœ, ์•ฑ์˜ ์ƒํƒœ ์ „ํ™˜ ๊ณผ์ •์—์„œ ์ž ๊น ๋จธ๋ฌด๋Š” ๋‹จ๊ณ„
  3. Active - ์ด๋ฒคํŠธ๋ฅผ ๋ฐ›๋Š” ๋‹จ๊ณ„/ ์ผ๋ฐ˜์ ์œผ๋กœ ์•ฑ์ด ๋Œ์•„๊ฐ€๋Š” ์ƒํƒœ
  4. background - ์•ฑ์ด suspended๋กœ ์ง„์ž…ํ•˜๊ธฐ ์ „ ์ƒํƒœ, ์ž‘์—…ํ•˜๋Š” ์ค‘ (์‚ฌ์‹ค์ƒ ์•ฑ์˜ ์ข…๋ฃŒ) ๋Œ€๋ถ€๋ถ„ ์•ฑ์€ suspended์ƒํƒœ๋กœ ์ดํ–‰ํ•˜๋Š” ๋„์ค‘์— ์ผ์‹œ์ ์œผ๋กœ ์ด ์ƒํƒœ์— ์ง„์ž…ํ•˜์ง€๋งŒ ํŒŒ์ผ ๋‹ค์šด๋กœ๋“œ, ์—…๋กœ๋“œ ๋“ฑ ํŠน์ • ์‹œ๊ฐ„๋™์•ˆ ์ด ์ƒํƒœ๋กœ ๋‚จ์•„์žˆ๊ฒŒ ๋˜๋Š” ๊ฒฝ์šฐ๋„ ์žˆ์Œ
  5. suspended - ์•ฑ์ด background ์ƒํƒœ์— ์žˆ์ง€๋งŒ ์•„๋ฌด ์ฝ”๋“œ๋„ ์‹คํ–‰ํ•˜์ง€ ์•Š๋Š” ์ƒํƒœ, ์‹œ์Šคํ…œ์ด ์ž„์˜๋กœ background ์ƒํƒœ์˜ ์•ฑ์„ suspended ์ƒํƒœ๋กœ ๋งŒ๋“ ๋‹ค. (not running)

 

2) iOS 13 ์ดํ›„ - ์”ฌ ๊ธฐ๋ฐ˜ ๋ผ์ดํ”„ ์‚ฌ์ดํด ์ด๋ฒคํŠธ

- iOS 13 ์ด์ƒ์—์„œ๋Š” UISceneDelegate ๊ฐ์ฒด๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์žฅ๋ฉด ๊ธฐ๋ฐ˜ ์•ฑ์˜ ์ƒ๋ช…์ฃผ๊ธฐ ์ด๋ฒคํŠธ์— ์‘๋‹ตํ•œ๋‹ค.

 

SceneDelegate๊ฐ€ ํ•˜๋Š” ์ผ

์•ฑ ์ƒ๋ช…์ฃผ๊ธฐ์— ๊ด€์—ฌํ•˜๋Š” ์—ญํ• ์„ sceneDelegate๊ฐ€ ๋– ๋งก๊ฒŒ ๋˜์—ˆ๋‹ค ! ๋”ฐ๋ผ์„œ ์”ฌ ๊ธฐ๋ฐ˜ ๋ผ์ดํ”„ ์‚ฌ์ดํด์„ ๋‹ด๋‹นํ•œ๋‹ค.

sceneDelegate.swift์— ์žˆ๋Š” ๋ฉ”์†Œ๋“œ๋“ค์— ๋Œ€ํ•ด ํ•˜๋‚˜์”ฉ ์‚ดํŽด๋ณด์ž

class SceneDelegate: UIResponder, UIWindowSceneDelegate {
    ...
    }

์šฐ์„  SceneDelegate๋Š” UIWindowSceneDelegate ํ”„๋กœํ† ์ฝœ์„ ์ฑ„ํƒํ•˜๊ณ  ์žˆ๊ณ  ์—ฌ๊ธฐ์„œ ์ด๋ฆ„์œผ๋กœ ์œ ์ถ”ํ•  ์ˆ˜ ์žˆ๋“ฏ์ด window ํ™”๋ฉด ๊ทธ๋ฆฌ๋Š”๋ฐ ๊ด€๋ จ๋œ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•˜๋Š” ๊ฒƒ์„ ์•Œ ์ˆ˜ ์žˆ๋‹ค.

 

willConnectTo

//iOS 12์˜ application (_ : didFinishLaunchingWithOptions :) ๊ฐ™์€ ๊ธฐ๋Šฅ
// scene์ด ์•ฑ์— ์ถ”๊ฐ€๋  ๋•Œ ํ˜ธ์ถœ
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions)

 

sceneDidDisconnect

//scene์˜ ์—ฐ๊ฒฐ์ด ํ•ด์ œ๋  ๋•Œ ํ˜ธ์ถœ
func sceneDidDisconnect(_ scene: UIScene)

 

sceneDidBecomeActive

 //app switcher์—์„œ ์„ ํƒ๋˜๋ฉด inActive ์ƒํƒœ์—์„œ active์ƒํƒœ๋กœ ์ „ํ™˜
 func sceneDidBecomeActive(_ scene: UIScene)

 

sceneWillResignActive

//active์ƒํƒœ์—์„œ inactive๋กœ ์ „ํ™˜์‹œ
func sceneWillResignActive(_ scene: UIScene) 

 

sceneWillEnterForeground

//background์—์„œ foreground๋กœ ์ „ํ™˜์‹œ 
func sceneWillEnterForeground(_ scene: UIScene) 

 

sceneDidEnterBackground

//foreground์—์„œ backgRound๋กœ ์ „ํ™˜์‹œ
func sceneDidEnterBackground(_ scene: UIScene)

 

์•ฑ์ด scene์„ ์ง€์›ํ•˜๋ฉด์„œ uikit๋Š” ๋ชจ๋“  ๋ผ์ดํ”„ ์‚ฌ์ดํด ์ด๋ฒคํŠธ๋ฅผ UIapplicationDelegate๋กœ ์ „๋‹ฌํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ ๊ฐ๊ฐ์— ๋Œ€ํ•ด ๋ณ„๋„ ๋ผ์ดํ”„ ์‚ฌ์ดํด์„ ์ œ๊ณตํ•˜๋„๋ก ํ•œ๋‹ค.

 

scene์€ ๊ธฐ๊ธฐ์—์„œ ์‹คํ–‰ ์ค‘์ธ ์•ฑ UI์˜ ํ•œ ์ธ์Šคํ„ด์Šค๋กœ ์œ ์ €๋Š” ๊ฐ ์•ฑ์— ๋Œ€ํ•ด ์—ฌ๋Ÿฌ scene์„ ๋งŒ๋“ค๊ณ  ์ด๋ฅผ ๊ฐœ๋ณ„์ ์œผ๋กœ ํ‘œ์‹œํ•˜๊ฑฐ๋‚˜ ์ˆจ๊ธธ ์ˆ˜ ์žˆ๋‹ค.

๊ฐ scene๋งˆ๋‹ค ๊ณ ์œ ํ•œ ๋ผ์ดํ”„์‚ฌ์ดํด์ด ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ๊ฐ scene๋งˆ๋‹ค ๋‹ค๋ฅธ ์‹คํ–‰ ์ƒํƒœ๊ฐ€ ๋  ์ˆ˜ ์žˆ๋‹ค.

 

1. Unattached : ์œ ์ €๋‚˜ ์‹œ์Šคํ…œ์ด ์•ฑ์˜ ์ƒˆ๋กœ์šด scene์„ ์š”์ฒญํ•˜๋ฉด UIKit์€ ์ด๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ์—ฐ๊ฒฐ๋˜์ง€ ์•Š์€ ์ƒํƒœ๋กœ ๋‘”๋‹ค.

2. Forground Inactive/ Active : ์‚ฌ์šฉ์ž๊ฐ€ ์š”์ฒญํ•˜๋Š” Scene์€ ๋น ๋ฅด๊ฒŒ foreground๋กœ ์ด๋™ํ•œ๋‹ค.

3. Background : ์‹œ์Šคํ…œ์ด ์š”์ฒญํ•œ Scene์€ ์ด๋ฒคํŠธ๋ฅผ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ๋„๋ก background๋กœ ์ด๋™ํ•œ๋‹ค.

4. Suspended : ์œ ์ €๊ฐ€ ์•ฑ์„ ๋‹ซ์œผ๋ฉด UIKit์€ ๊ด€๋ จ scene์„ ๋ฐฑ๊ทธ๋ผ์šด๋“œ ์ƒํƒœ๋กœ ์ด๋™ํ•˜๊ณ  ๊ฒฐ๊ตญ suspended ๋ฉ๋‹ˆ๋‹ค.

 

์ฆ‰ ์‚ฌ์šฉ์ž๊ฐ€ ์•ฑ์˜ UI๋ฅผ ํ•ด์ œํ•˜๋ฉด UIKit์€ ์—ฐ๊ฒฐ๋œ ์žฅ๋ฉด์„ background ์ƒํƒœ๋กœ, ๊ฒฐ๊ตญ์—๋Š” suspended ์ƒํƒœ๋กœ ์ „ํ™˜ํ•œ๋‹ค. UIKit์€ ์–ธ์ œ๋“ ์ง€ background ๋˜๋Š” suspended๋œ Scene์˜ ์—ฐ๊ฒฐ์„ ๋Š์–ด Scene์„ ์—ฐ๊ฒฐ๋˜์ง€ ์•Š์€ ์ƒํƒœ๋กœ ๋˜๋Œ๋ฆด ์ˆ˜ ์žˆ๋‹ค.

 

 

Scene์˜ ๊ฐœ๋…๋•๋ถ„์— AppDelegate์— configurationForConnecting์™€ didDiscardSceneSessions ๋ฉ”์†Œ๋“œ๋ฅผ ํ•„์ˆ˜๋กœ ๊ตฌํ˜„ํ•ด์•ผํ•œ๋‹ค. 

 

configurationForConnecting

//์ƒˆ Scenea ๋งŒ๋“ค๋•Œ UIKit๋ฅผ ์œ„ํ•œ configuration data๋ฅผ ๊ฐ€์ ธ์˜จ๋‹ค.
optional func application(_ application: UIApplication, 
configurationForConnecting connectingSceneSession: UISceneSession, 
                  options: UIScene.ConnectionOptions) -> UISceneConfiguration

 

didDiscardSceneSessions

//์‚ฌ์šฉ์ž๊ฐ€ app switcher์—์„œ ํ•˜๋‚˜ ์ด์ƒ์˜ ์•ฑ Scene์„ ๋‹ซ์•˜์Œ์„ Appdelegate์—๊ฒŒ ์ „๋‹ฌ
optional func application(_ application: UIApplication, 
  didDiscardSceneSessions sceneSessions: Set<UISceneSession>)

 

 

์ด์ œ์•ผ ์•ฑ์˜ ์ „๋ฐ˜์ ์ธ ํ”„๋กœ์„ธ์Šค๋ฅผ ๊ณต๋ถ€ํ•˜๋‹ค๋‹ˆ .. 

์ดํ•ดํ•˜๊ธฐ ์–ด๋ ค์›Œ ์—ฌ๋Ÿฌ ๋ธ”๋กœ๊ทธ๋“ค์„ ๋งŽ์ด ์ฐธ๊ณ  ํ–ˆ๋‹ค. ์กฐ๊ธˆ์€ ์•Œ๊ฒƒ ๊ฐ™๊ธฐ๋„ ํ•˜๊ณ  ๋‚ด์ผ ๋˜ ๋ด์•ผ๊ฒ ์ง€๋งŒ ์ง€๊ธˆ ๋Š๋ผ๋Š” ๋ฐ”๋กœ๋Š” ๊ฐ๊ฐ์˜ ์—ญํ• ์— ๋งž๊ฒŒ๋” ๋ถ„๋‹ด๋˜์–ด ์„œ๋กœ์˜ ์œ„์น˜์— delegate๋ฅผ ํ†ตํ•ด ์ƒํ˜ธ์ž‘์šฉํ•˜๊ณ  ์ž˜ ํ•˜๊ณ  ์žˆ๊ตฌ๋‚˜ ์ •๋„ ์•Œ๊ฒƒ ๊ฐ™๋‹ค.


 

์ฐธ๊ณ  ์ž๋ฃŒ 

๊ณต์‹ ๋ฌธ์„œ

developer.apple.com/documentation/uikit/app_and_environment/managing_your_app_s_life_cycle

๋ธ”๋กœ๊ทธ

duwjdtn11.tistory.com/509

shoveller.tistory.com/entry/App-and-Scenes

medium.com/@jgj455/์˜ค๋Š˜์˜-swift-์ƒ์‹-์•ฑ-์ƒ๋ช…์ฃผ๊ธฐ-878dfe51d182

 

๋Œ“๊ธ€