반응형
Combine Publisher로 Background나 Foreground 진입시 처리하는 방법은 다음과 같습니다.
var cancellableBag = Set<AnyCancellable>()
NotificationCenter.default.publisher(for: UIApplication.willResignActiveNotification)
.sink { [weak self] _ in
guard let self else { return }
// Background 진입시 처리
}.store(in: &cancellableBag)
NotificationCenter.default.publisher(for: UIApplication.willEnterForegroundNotification)
.sink { [weak self] _ in
guard let self else { return }
// Foreground 진입시 처리
}.store(in: &cancellableBag)
반응형
'Develop > iOS' 카테고리의 다른 글
XCode - Unable to process request - PLA Update availabl (0) | 2024.11.17 |
---|---|
다크모드 'traitCollectionDidChange’ deprecated in iOS 17.0 (0) | 2024.03.22 |
휴대전화번호 포멧(000-0000-0000)으로 만들기 (0) | 2024.01.16 |
SwiftUI 에서 Background나 Foreground 진입시 처리 (0) | 2024.01.05 |
SegmentView (0) | 2023.12.30 |
UITextField hyphen(-) 연속 입력시 en dash(–)로 변경되는것 막기 (0) | 2023.12.14 |
Keyboard Height 계산해서 Publisher 하기 (0) | 2023.12.13 |
TextField에 clearButton 추가하기 (0) | 2023.12.13 |