Reputation: 12051
I have an NSString in one class, a UILabel in another class and the 3rd UILabel in my 3rd class. They are all on 3 different views in IB. I want my 1st class to save some string to NSString and I want my 2nd view UILabel to equal this NSString and my 3rd class' UILabel to equal my 2nd class' UILabel. How do I do that?
Thanks in advance!
Upvotes: 0
Views: 101
Reputation: 27601
This is a common question with a common pattern for a solution.
Create a model class to hold your string. Instantiate an object of this class in your application delegate (perhaps in applicationDidFinishLaunching:
), and pass it along to all three of your view controllers. Use Key-Value Observing on your model class by your sub-view controllers, so they get alerted to any changes in the model (i.e. changes to the string).
Upvotes: 1