iOS

Combine Framework

Publishers, subscribers, operators, subjects, backpressure, error handling, schedulers

24 면접 질문·
Senior
1

What is a Publisher in Combine?

답변

A Publisher is a fundamental protocol in Combine that describes how a sequence of values can be delivered over time. It is responsible for emitting values or errors to subscribers that connect to it. Understanding this concept is essential for working with Combine, as all other framework elements depend on this publication model.

2

What is a Subscriber in Combine?

답변

A Subscriber is a protocol that defines how to consume values emitted by a Publisher. It has three essential methods: receive(subscription:) to acknowledge the subscription, receive(_:) to handle values, and receive(completion:) to manage completion or errors. It is the receiving end of the data flow in Combine.

3

Why should one store the AnyCancellable returned by subscribe()?

답변

AnyCancellable is a token that keeps the subscriber alive. Without storing it in a property or variable, the object is immediately deallocated, canceling the subscription. This common mistake causes the data flow to stop immediately. Keeping AnyCancellable ensures the subscription remains active as long as needed.

4

What is the main role of an operator in Combine?

5

What is the difference between a Publisher and a Subscriber?

+21 면접 질문

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

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

무료로 시작하기