I have a question that I suppose the answer is no, but I want to be sure. Is there any way to trigger a method when a class's property values were changed from another class? An example, in iOS:
I've got FirstViewController, that get's an NSString from the server and saves it as @property NSString helloString. But it also saves it locally, using NSSUserDefaults, so when the user enters the app he will see the last helloString saved locally and when server answers (let's say after 5 seconds) it updates this helloString property.
Imagine that the user goes to SecondViewController (where we passed helloString with prepareForSegue in FirstViewController and saved as a property in SecondViewController). SecondViewController displays the saved helloString, and after 5 seconds server answers and updates the helloString property in FirstViewController (and of course to the SecondViewController).
Is there any way (I thought I could use NSNotificationCenter) to trigger a method in SecondServerController when helloString value changed in FirstServerController?
EDIT:
KVO is not a valid option because if we had a ThirdViewController and user went from FirstViewController to SecondViewController and finally to ThirdViewController, and then go back to FirstViewController going through SecondViewcontroller, on [FirstViewController removerObserver:forKeyPath:] method that is inside SecondViewController would crash because FirstViewController was released from memory.
Thank you for your time.