mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-05 16:35:33 +00:00
24 lines
577 B
Swift
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)
|
|
}
|
|
}
|