본문 바로가기

IOS 개발

[iOS] class UIApplication : UIResponder

UIApplication

class UIApplication : UIResponder

 

요약

iOS에서 실행되는 앱의 중앙 집중식 제어 및 조정

Summary

The centralized point of control and coordination for apps running in iOS.

 

Declaration

class UIApplication : UIResponder

 

토론

모든 iOS 앱에는 정확히 하나의 UIApplication 인스턴스 (또는 매우 드물게 UIApplication의 서브 클래스)가 있습니다. 앱이 시작되면 시스템은 UIApplicationMain (_ : _ : _ : _ :) 함수를 호출합니다. 다른 작업 중에서도 이 함수는 Singleton UIApplication 객체를 만듭니다. 그런 다음 공유 클래스 메소드를 호출하여 오브젝트에 액세스 하십시오.

앱 애플리케이션 객체의 주요 역할은 들어오는 사용자 이벤트의 초기 라우팅을 처리하는 것입니다. 제어 오브젝트 (UIControl 클래스의 인스턴스)에 의해 전달 된 조치 메시지를 적절한 대상 오브젝트로 전달합니다. 응용 프로그램 객체는 열린 창 목록 (UIWindow 객체)을 유지하며 이를 통해 앱의 UIView 객체를 검색 할 수 있습니다.

UIApplication 클래스는 UIApplicationDelegate 프로토콜을 준수하고 프로토콜의 일부 메소드를 구현해야하는 델리게이트를 정의합니다. 응용 프로그램 개체는 중요한 런타임 이벤트 (예 : 앱 시작, 메모리 부족 경고 및 앱 종료)를 대리자에게 알려 적절하게 대응할 수있는 기회를 제공합니다.

앱은 openURL (_ :) 메소드를 통해 이메일 또는 이미지 파일과 같은 리소스를 공동으로 처리 할 수 ​​있습니다.
예를 들어, 이메일 URL과 함께  이 메소드를 호출하는 앱은 메일 앱을 시작하고 메시지를 표시합니다.

이 클래스의 API를 사용하면 장치 별 동작을 관리 할 수 ​​있습니다. UIApplication 객체를 사용하여 다음을 수행하십시오.

• 들어오는 터치 이벤트를 일시 중단합니다 (beginIgnoringInteractionEvents ())

 원격 알림 등록 (registerForRemoteNotifications ())

 실행 취소 다시 실행 UI 트리거 (applicationSupportsShakeToEdit)

 URL 체계를 처리하기 위해 설치된 앱이 등록되어 있는지 확인 (canOpenURL (_ :))

 백그라운드에서 작업을 완료 할 수 있도록 앱 실행을 확장합니다 (beginBackgroundTask (expirationHandler :), beginBackgroundTask (withName : expirationHandler :)).

 로컬 알림 예약 및 취소 (scheduleLocalNotification (_ :), cancelLocalNotification (_ :))

 원격 제어 이벤트 수신 조정 (beginReceivingRemoteControlEvents (), endReceivingRemoteControlEvents ())

 앱 수준 상태 복원 작업 수행 (상태 복원 동작 관리 작업 그룹의 방법)

 

Discussion

Every iOS app has exactly one instance of UIApplication (or, very rarely, a subclass of UIApplication). When an app is launched, the system calls the UIApplicationMain(_:_:_:_:) function; among its other tasks, this function creates a Singleton UIApplication object. Thereafter you access the object by calling the shared class method.

A major role of your app’s application object is to handle the initial routing of incoming user events. It dispatches action messages forwarded to it by control objects (instances of the UIControl class) to appropriate target objects. The application object maintains a list of open windows (UIWindow objects) and through those can retrieve any of the app’s UIView objects.

The UIApplication class defines a delegate that conforms to the UIApplicationDelegate protocol and must implement some of the protocol’s methods. The application object informs the delegate of significant runtime events—for example, app launch, low-memory warnings, and app termination—giving it an opportunity to respond appropriately.

Apps can cooperatively handle a resource, such as an email or an image file, through the openURL(_:) method. For example, an app that calls this method with an email URL causes the Mail app to launch and display the message.

The APIs in this class allow you to manage device-specific behavior. Use your UIApplication object to do the following:

 

  • Temporarily suspend incoming touch events (beginIgnoringInteractionEvents())
  • Register for remote notifications (registerForRemoteNotifications())
  • Trigger the undo-redo UI (applicationSupportsShakeToEdit)
  • Determine whether there is an installed app registered to handle a URL scheme (canOpenURL(_:))
  • Extend the execution of the app so that it can finish a task in the background (beginBackgroundTask(expirationHandler:), beginBackgroundTask(withName:expirationHandler:))
  • Schedule and cancel local notifications (scheduleLocalNotification(_:), cancelLocalNotification(_:))
  • Coordinate the reception of remote-control events (beginReceivingRemoteControlEvents(), endReceivingRemoteControlEvents())
  • Perform app-level state restoration tasks (methods in the Managing the State Restoration Behavior task group)

 

 

 

[참조 : Open in Developer Documentation]