Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

CMT

macrumors regular
Original poster
Aug 24, 2009
104
10
I think I'm experiencing some really crazy thoughts about OOP, as I'm pretty new to it. Well, lets see if someone can help me organize the ideas.

Let's say we are going to build a simple app. One window, a slider and a label. Putting this inside MVC [obviously this is just a simple example I'd never do MVC for this app :) ]

In the model, we would have a class with one variable, to store a value and also a @property to access that var.

In the view, the .xib containing the slider and label (I believe these objects fit in the view)

In the controller, I have to instantiate the slider and label again and also a model object plus other methods telling when the view changes and updating it.

Now, my question. I need to create a model object that remains live. So I can set its value and also retrieve it to show in the label. if i'm correct, I can do this by retaining the object, but where to create and retain it?

Inside a method in a class? if so, which one?

Well I'm quite lost with concepts as you can see. If needed I can do a more detailed description.

Thanks in advance!
 
Usually in either the appDelegate or the controller.

For example, the controller would have an ivar of the same type as the model. And then in the method - viewDidLoad you would alloc/init that model object and set it as your ivar, then setup the position of the slider from the model objects value OR set the model's value and the slider to some predetermined value.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.