How to update invalidated object sent to DetailViewController


#1

I am working on an application that passes an object from an array of objects listed in a UITableView. The local realm database displays everything in that table view, but the async call comes back late. SO MY ISSUE:

  • A user taps an object and goes into the detail view of that object from array
  • Async network call finally returns and updates the parent view array of objects
  • If user taps on something in Detail view and the object is now invalidated it crashes.

How do I validate or update the object passed into the detail view so the user is unaware and a crash does not happen and the object is updated? I am new to Realm and appreciate any help. Thank you.


#2

The question is a tad unclear.

It seems you are using an array of realm objects as the dataSource for your tableView. On that - I might suggest using a Realm Results object instead so if the objects are updated you’ll be notified via an observer.

But then the async call comes back late. What does that mean?

When you are showing the data in the detail view, what’s the correlation between that and an async call in the parent view?

How is the data in the detail view invalidated? If you’re observing the object, it will always be valid and current.