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

Responding to the Launch of Your App

by yongmin.Lee 2021. 2. 24.

Overview

The system launches your app when the user taps your app’s icon on the Home screen. 

Et launch time, UIKit automatically creates the UIApplication object and your app delegate.

It then starts your app’s event loop.

Process

1. App touch

2. swift๋Š” C ๊ณ„์—ด์˜ ์–ธ์–ด๊ฐ€ ์•„๋‹ˆ๊ธฐ ๋•Œ๋ฌธ์— main()๊ฐ™์€ ์‹œ์ž‘์ ์ด ์—†์œผ๋ฏ€๋กœ @main์–ด๋…ธํ…Œ์ด์…˜ (xcode 11์ดํ•˜์—์„œ๋Š” @UIApplicationMain)์„ ํ†ตํ•ด ์•ฑ์˜ ๋ณธ์ฒด์— ํ•ด๋‹นํ•˜๋Š” UIApplication ๊ฐ์ฒด์ƒ์„ฑ

4. UIApplication ๊ฐ์ฒด๋Š” Info.plistํŒŒ์ผ์„ ๋ฐ”ํƒ•์œผ๋กœ ์•ฑ์— ํ•„์š”ํ•œ ๋ฐ์ดํ„ฐ์™€ ๊ฐ์ฒด ๋กœ๋“œ

5. ์ปค์Šคํ…€ ์ฝ”๋“œ๋ฅผ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด AppDelegate ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•˜๊ณ  UIApplication ๊ฐ์ฒด์™€ ์—ฐ๊ฒฐ

6. AppDelegate์˜  func application(UIApplication, willFinishLaunchingWithOptions: [UIApplication.LaunchOptionsKey : Any]?) -> Bool ๋ฉ”์„œ๋“œ๋ฅผ ํ†ตํ•ด ์‹คํ–‰์— ํ•„์š”ํ•œ ์ค€๋น„ ์ง„ํ–‰

7. ์‹คํ–‰ ์ง์ „ func application(UIApplication,didFinishLaunchingWithOptions: [UIApplication.LaunchOptionsKey : Any]?) -> Bool ํ•จ์ˆ˜ ํ˜ธ์ถœ

8. Main run loop ์‹คํ–‰ ๋ฐ ์ด๋ฒคํŠธ ํ๋ฅผ ์ด์šฉํ•ด ์ด๋ฒคํŠธ ์ˆœ์ฐจ ์ฒ˜๋ฆฌ

9. ์•ฑ์„ ๋” ์ด์ƒ ์‚ฌ์šฉํ•˜์ง€ ์•Š์œผ๋ฉด iOS system์— terminate ๋ฉ”์‹œ์ง€ ์ „๋‹ฌ, applicationWillTerminate(_:) ์‹คํ–‰

10. ์•ฑ ์ข…๋ฃŒ

Main run loop

Main Run Loop๋ผ๋Š” ๊ฒƒ์€ ์œ ์ €๊ฐ€ ์ผ์œผํ‚ค๋Š” ์ด๋ฒคํŠธ๋“ค์„ ์ฒ˜๋ฆฌํ•˜๋Š” ํ”„๋กœ์„ธ์Šค์ž…๋‹ˆ๋‹ค. 

UIApplication ๊ฐ์ฒด๋Š” ์•ฑ์ด ์‹คํ–‰๋  ๋•Œ, Main Run Loop๋ฅผ ์‹คํ–‰

Main Run Loop๋ฅผ View์™€ ๊ด€๋ จ๋œ ์ด๋ฒคํŠธ๋‚˜ View์˜ ์—…๋ฐ์ดํŠธ์— ํ™œ์šฉ

Main Run Loop๋Š” View์™€ ๊ด€๋ จ๋˜์–ด ์žˆ๊ธฐ ๋•Œ๋ฌธ์— Main ์“ฐ๋ ˆ๋“œ์—์„œ ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค.

 

 

 

'iOS ๐ŸŽ > iOS' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

viewcontroller๊ฐ„ ๋ฐ์ดํ„ฐ ์ „๋‹ฌํ•˜๋Š” 6๊ฐ€์ง€ ๋ฐฉ๋ฒ•  (0) 2021.03.02
Managing iOS App's Life Cycle  (0) 2021.02.24
MVC, MVP, MVVM Pattern  (0) 2021.02.17
Delegation Pattern  (0) 2021.02.17
Design Pattern  (0) 2021.02.16