In Android, we have mutable live data object when we update it let say on a different thread we attached to it an observer. When the object gets updated the observer is listening and update the UI accordingly.
liveDataService.setValue(response); ==> updating the object with new data
And in the Activity(let say like TableViewController for swift/IOS)
We put the observer
liveDataService.observeForever(s -> {
Log.d(TAG, getString(R.string.service_observer_message));
updateUI(s);
}); ==> When liveDataService changes we update the UI
Now I want to do the same for Swift/IOS
I see the function
addObserver(_:forKeyPath:options:context:)
But I can not attach it to an Array that gets the update in the background only to NSObject
What is the best method to accomplish this task?
Thanks Eran