Skip to content

Instantly share code, notes, and snippets.

@roymckenzie
Last active January 30, 2017 17:19
Show Gist options
  • Save roymckenzie/dd56a2bee59de19897d7eff24a5e5e46 to your computer and use it in GitHub Desktop.
Save roymckenzie/dd56a2bee59de19897d7eff24a5e5e46 to your computer and use it in GitHub Desktop.
final class DataDisplayViewController: UIViewController {
private var realmNotificationToken: NotificationToken?
override func viewDidLoad() {
super.viewDidLoad()
startRealmNotification()
}
private func startRealmNotification() {
do {
let realm = try Realm()
realmNotificationToken = realm.addNotificationBlock() { [weak self] _, _ in
// TODO:- UPDATE UI
}
} catch {
print("Error setting up Realm Notification: \(error.localizedDescription)")
}
}
deinit {
realmNotificationToken?.stop()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment