Observing changes to Realm result set
up vote 4 down vote favorite I'm working on an iOS app that uses a Realm database. In my AppDelegate , I define a Realm result set like this: var results: Results<RealmWidget>! var notificationToken: NotificationToken? = nil do let realm = try Realm() if results == nil results = realm.objects(RealmWidget.self) catch print(error.localizedDescription) I observe this result set for changes like this: if notificationToken == nil notificationToken = results.observe (changes: RealmCollectionChange) in switch changes case .update(_, _, let insertions, _): if insertions.count > 0 // show badge on tab bar // play sound to get the user's attention default: break Anytime a new RealmWidget object is inserted in the database (which happens as a result of receiving data from a server), I want to show a badge on the UITabBar in my UI. This code appears to be working properly. In another part of my app, I have a view controller with a UITableView that i