Reputation: 1004
I am trying to learn iphone programming so please be patient. I have a simple application implemented using a root model and two views selectable by a Tab bar control. The user enters a value in the view A and pressed a button. The appropriate IBAction of the button sets a property in the root model and then it calls a method(DoCalculation) inside root model to perform some calculations. The result of calculations are a series of numeric data which will be saved in a NSMUTuableArray. This array is used to update the information in view B. My questions are: Is this a reasonable architecture of this simple app? Do you see any problem with it?
Another question is should I update view B right after the calculations are done in Root model or should I store then in an arrray and the view should update itself when it becomes visible?
Upvotes: 0
Views: 77
Reputation: 47729
That's one of many ways it could be done. Retained data can be stored in individual instance variables or in a structure such as an NSMutableDictionary or NSMutableArray.
Generally you don't update the view until it's about to display (eg, in viewWillAppear), since you have to wait until the view is created anyway, before it can be updated. (You can force creation early by referencing the view property of the view controller, but it's generally better to wait for it to be created by the flow of the app, since a created view occupies a lot of storage.)
Upvotes: 1