dMurdZ
dMurdZ

Reputation: 1079

Swift Realm: can you observe when a Results object changes?

When a Results object is returned from a query it is dynamic. So, if you query for all Dog objects, and then you create a new Dog, your Results will include that new Dog. Is there anyway to track when/what index gets changed in the Results object? Looking through their documentation, the only tool I see would be Realm NotificationTokens. But notifications aren't a great solution for table views, as your only option is to reload the whole data set. I'm looking for something closer to NSFetchedResultsController.

Upvotes: 0

Views: 1674

Answers (1)

TiM
TiM

Reputation: 16021

Sadly not yet. At present, the notification token is the only way you can receive events for when the data in a Realm file is changed (No matter what it is.)

That being said, fine-grain notifications (The ability to register for events in where specific changes occur) is on the Realm roadmap, and should be coming in a future release soon.

For the time being, if you want to track when a new Dog property is created, you can always use the NSNotification system to manually fire off an app-wide event notifying interested objects in the changes.

Upvotes: 1

Related Questions