-
[iOS] UIApplication μ΄λ?iOS/π€ App 2021. 1. 28. 22:04
μλ νμΈμπΆ
μ΄λ² μκ°μλ `UIApplication` ν΄λμ€μ λν΄μ μμλ³΄κ² μ΅λλ€.
μ΄ ν΄λμ€κ° μΈμ λ±μ₯νλ μ§λ μ΄μ κΈμ μ½κ³ μ€μλ©΄ μ’μ κ² κ°μμ!!!
" iOS μ±μ μ μ΄μ μ‘°μ μ ꡬμ¬μ "
class UIApplication : UIResponder
κ°μ
λͺ¨λ iOS μ±μ μ νν λ¨ νλμ UIApplication μΈμ€ν΄μ€λ₯Ό κ°μ§κ³ μμ΅λλ€.
μμ£Ό λλ¬Έκ²½μ°, UIApplicationλ₯Ό μλΈν΄λμ±ν μΈμ€ν΄μ€λ₯Ό μ¬μ©νλ€κ³ ν©λλ€.
μ±μ΄ μ€νλλ©΄, μμ€ν μ UIApplicationMain(_:_:_:_:) λ₯Ό νΈμΆν©λλ€.
:: μ΄μ κΈμ λμ¨ λ΄μ©μ΄μ§λ§, λ³΄ν΅ AppDelegate.main() μ μ€νμΌλ‘ νΈμΆλ©λλ€.
ν΄λΉ λ©μλμ μμ μ€ νλλ UIApplication μ€λΈμ νΈλ₯Ό λ§λλ κ²μ λλ€.
μ΄κ²μ μ±κΈν€μΌλ‘ λ§λ€μ΄μ§λ©°, shared μμ±μΌλ‘ μ κ·Όν μ μμ΅λλ€.
" This function also sets up the main event loop, including the application’s run loop, and begins processing events."
μ ν¨μλ λν μ±μ λ° λ£¨νλ₯Ό ν¬ν¨νλ λ©μΈ μ΄λ²€νΈ 루νλ₯Ό ꡬμ±ν©λλ€.
μ±μ UIApplication μ€λΈμ νΈλ μ¬μ©μ μ΄λ²€νΈμ μ΄κΈ° λΌμ°ν μ μ²λ¦¬ν©λλ€.
μ¬κΈ°μ λΌμ°ν μ μ λ¬λ°μ μ¬μ©μ μ΄λ²€νΈλ₯Ό μ΄λ€ μ€λΈμ νΈμ μ λ¬ν μ§ κ²°μ νλ μμ μ΄ λκ² μ΅λλ€.
UIApplication μ€λΈμ νΈλ UIControl μΈμ€ν΄μ€κ° μ λ¬ν action message λ₯Ό μ μ ν target μ€λΈμ νΈμ μ λ¬ν©λλ€.
Target-action mechanism
UIApplication μ€λΈμ νΈλ `open` μνμ UIWindow μ€λΈμ νΈ λ¦¬μ€νΈλ₯Ό μ μ§νλ©΄μ, μ± λ΄ UIView μ€λΈμ νΈλ€μ κ²μνλλ° μ¬μ©ν©λλ€.
UIApplication ν΄λμ€λ delegate μ μ μν©λλ€.
μ΄ delegateμ UIApplicationDelegate νλ‘ν μ½μ μ±νν΄μΌ ν©λλ€.
UIApplication μ€λΈμ νΈλ μ΄ delegate μκ² μ€μν λ°νμ μ΄λ²€νΈκ° λ°μν λ μλ €μ€λλ€.
μλ₯Ό λ€μ΄, App launch, low-memory warnings, App termination κ°μ μ΄λ²€νΈ μ λλ€.
μ± μμ, λ©λͺ¨λ¦¬ λΆμ‘± κ²½κ³ , μ± μ’ λ£
μ μ΄λ²€νΈλ€μ μλ €μ€μΌλ‘μ delegate κ° μ μ νκ² λμν μ μκ² ν΄μ£Όλ κ²μ λλ€.
μ±λ€μ νλμ μΌλ‘ 리μμ€λ₯Ό μ μ΄ν μ μμ΅λλ€.
리μμ€λ email κ³Ό image file κ°μ κ²λ€μΈλ°, open(_:options:completionHandler:) λ©μλλ₯Ό μ¬μ©νμ¬ μ μ΄ν©λλ€.
μλ₯Ό λ€λ©΄, μ±μ μ΄ λ©μλμ email URL μ μ λ¬νμ¬ Mail μ±μ μ€ννκ³ λ©μμ§λ₯Ό νλ©΄μ νμν μ μμ΅λλ€.
# μλμλ μμ§ ν΄λ³΄μ§ μμ μμ λ€μ΄ λ§μμ μλ¬Έμ λ¨κ²¨ λμμ΅λλ€. μ΄ν΄κ° λλ μμ μ μλ¬Έμ μ§μ°λ €κ³ ν©λλ€.
UIApplication ν΄λμ€μ API λ κΈ°κΈ°μ νΉμ ν λμμ κ°λ₯νκ² ν΄μ€λλ€. λ€μκ³Ό κ°μ΄ ν μ μμ΅λλ€:
- Temporarily suspend incoming touch events (beginIgnoringInteractionEvents())
= μΌμμ μΌλ‘ ν°μΉ μ΄λ²€νΈμ μ λ ₯μ μ€μ§μν΅λλ€. - Register for remote notifications (registerForRemoteNotifications())
= remote notification μ λ±λ‘ν©λλ€. - Trigger the undo-redo UI (applicationSupportsShakeToEdit)
- Determine whether there is an installed app registered to handle a URL scheme (canOpenURL(_:))
= URL scheme μ μ²λ¦¬νκΈ° μν΄ μ€μΉλμ΄ μλ μ±μ λ±λ‘ν μ§ κ²°μ ν©λλ€. - Extend the execution of the app so that it can finish a task in the background (beginBackgroundTask(expirationHandler:) and beginBackgroundTask(withName:expirationHandler:))
= μ±μ μ€ν μκ°μ λλ €μ ν΄λΉ μμ μ `background`μμ μλ£ν μ μκ² ν©λλ€. - Schedule and cancel local notifications (scheduleLocalNotification(_:) and cancelLocalNotification(_:))
= Local notification μ μ§κ±°λ μ·¨μν©λλ€. - Coordinate the reception of remote-control events (beginReceivingRemoteControlEvents() and endReceivingRemoteControlEvents())
= Remote-control μ΄λ²€νΈμ μμ μ μ‘°μ ν©λλ€. - Perform app-level state restoration tasks (methods in the Managing the State Restoration Behavior task group)
= App-level `state restoration` μμ λ€μ μνν©λλ€.
Subclassing Notes
UIApplicationμ μλΈν΄λμ± ν΄μΌλλ κ²½μ°κ° μκΈΈ λ μ 리ν΄λ³΄κ² μ΅λλ€.
λ!
λ€μ κΈ:
'iOS > π€ App' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[iOS] Frame κ³Ό Bounds μ 곡ν΅μ κ³Ό μ°¨μ΄μ (0) 2021.02.04 [iOS] About the App Launch Sequence (μ± μ€ν μμ μ μΌμ΄λλ μΌλ€) (1) 2021.02.02 [iOS] Responding to the Launch of Your App (곡μλ¬Έμ μ 리) (0) 2021.01.28 [iOS] Managing Your App's Life Cycle (곡μλ¬Έμ μ 리) (0) 2021.01.26 Review of Implement a Custom Control (2) - Food Tracker (0) 2021.01.22 - Temporarily suspend incoming touch events (beginIgnoringInteractionEvents())