In my view controller I have some model information that comes down from a web application in the viewDidLoad method. Immediately following that download I create a NSObject that consists of six NSString properties and a UIImage to store that model information. Also in the viewDidLoad method I would like to update my custom view with this initial model information. Four of Seven fields in the view (including the UIImageView) won't change at all after the initial sync. The others about once every 30 seconds. So here are a couple questions.

  1. Too synchronize my model and view the first time should I just pass the entire NSObject as a parameter to the custom view and then update its label and image fields in a method contained in the custom view?

  2. To update the three fields that do change in the future. Should I make a simpler method in my custom view that just updates those three fields and pass in pieces of the NSObject as a parameter?

  3. Is passing an entire model object to a custom view through the controller good practice? Does it really matter in terms of efficiency if I pass the entire NSObject to the custom view if I am only going to use three of its properties.

Thanks for your time! If there is a more preferred way to do this please let me know!

有帮助吗?

解决方案

If your question is whether or not you should use "view models", the answer is yes. If your view only needs an object with three strings then make a model that has three strings. Try to separate your "view models" from your "data access" models.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top