
NotificationCenter.Publisher name publish 할 Notification 의 이름 object 위 name 을 가지는 Notification 을 post 할 object, 만약 nil 이면, 해당 이름을 가지는 모든 노티피케이션을 sender 에 상관없이 publish 한다. Return Value Notification 을 publish 하는 Publisher 를 리턴한다. Notification Publisher 예시 UITextField 는 기본적으로 text 프로퍼티가 바뀔 때마다, UITextField.textDidChangeNotification 을 post 한다. 즉 Notification Center 를 통해 해당 텍스트 변경 이벤트를 구독하는 옵저버를 만들거나..

var observer: NSObjectProtocol? observer = NotificationCenter.default.addObserver(forName: UIApplication.userDidTakeScreenshotNotification, object: nil, queue: nil) { notification in print("user take screenshot!") NotificationCenter.default.removeObserver(observer!) } Notification Center 등록된 옵저버들에게 노티피케이션을 보낼 수 있는 클래스이다. 모든 애플리케이션은 default Notification Center 를 가지고 있다. 노티피케이션을 그룹화하기 위해 새로운 Notif..
Comment