spiegel-keyman/ios/engine/KMEI/KeymanEngine/Classes/Notification/NotificationObserver.swift
2017-11-07 11:04:25 +07:00

24 lines
577 B
Swift

//
// NotificationObserver.swift
// KeymanEngine
//
// Created by Gabriel Wong on 2017-10-30.
// Copyright © 2017 SIL International. All rights reserved.
//
import Foundation
/// NotificationCenter observer which automatically deregisters itself when deinitializing.
public class NotificationObserver {
private let observer: NSObjectProtocol
private let center: NotificationCenter
public init(observer: NSObjectProtocol, center: NotificationCenter) {
self.observer = observer
self.center = center
}
deinit {
center.removeObserver(observer)
}
}