iOS

SwiftUI State Management

@State, @Binding, @ObservedObject, @EnvironmentObject, @StateObject, data flow

22 면접 질문·
Mid-Level
1

Which property wrapper to use for managing local state in a SwiftUI view?

답변

@State creates a source of truth for mutable data within a view. SwiftUI automatically manages the lifecycle and redraws when the value changes. This is the fundamental mechanism for local state modifications in a single view.

2

What is the purpose of the @Binding property wrapper in SwiftUI?

답변

@Binding creates a bidirectional reference to an existing source of truth. It allows a child view to modify parent data without owning the source itself. This is essential for parent-child communication while maintaining a single source of authority.

3

What is the role of @Published in SwiftUI state management?

답변

@Published marks properties of an ObservableObject class as observable. When a @Published property changes, the class notifies all observers, triggering view redraws. It bridges classes with SwiftUI's reactive system.

4

How to access a parent's @State property in a child view?

5

When to use @AppStorage instead of @State?

+19 면접 질문

다음 면접을 위해 iOS을 마스터하세요

모든 질문, flashcards, 기술 테스트, 코드 리뷰 연습, 면접 시뮬레이터에 접근하세요.

무료로 시작하기