iOS

Application Lifecycle

App states, AppDelegate, SceneDelegate, background modes, app termination

20 面接問題·
Junior
1

What is UIApplicationDelegate?

回答

UIApplicationDelegate is a protocol that defines callback methods for the application lifecycle. It enables responding to important events such as launch, backgrounding, or foreground transition. Every iOS application must implement this protocol in its AppDelegate class to manage its lifecycle correctly. It's the central point for initializing third-party services, configuring notifications, and managing global state transitions. Since iOS 13, this protocol shares responsibilities with SceneDelegate for managing multiple windows.

2

When is the application(_:didFinishLaunchingWithOptions:) method called?

回答

This method is called when the application launches, after UIApplication initialization and before the UI is displayed. It's ideal for initializing third-party services, configuring the database, registering for notifications, and setting up global parameters. Long operations should be avoided as they delay the initial display.

3

What are the main states in the iOS application lifecycle?

回答

The lifecycle has five main states: Not Running (app not launched or terminated), Inactive (app in foreground but not receiving events, temporary interruptions), Active (app running normally and receiving events), Background (app executing in background with ~30 seconds before suspension), and Suspended (app frozen in memory, no execution). Understanding these states enables proper resource management, permissions handling, and battery optimization. Transitions between these states trigger AppDelegate or SceneDelegate methods.

4

What is the difference between applicationWillResignActive and applicationDidEnterBackground?

5

What is the role of applicationDidBecomeActive?

+17 面接問題

次の面接に向けてiOSをマスター

すべての問題、flashcards、技術テスト、コードレビュー演習、面接シミュレーターにアクセス。

無料で始める