New developer here.
I’m making my first iPhone app. The app will display a word on screen and then a group of words associated with the first word in a list off to the side.
This requires me to store NSStrings in NSArrays, and the NSArrays in an NSDictionary.
I know that my Model should set the contents of my collection classes so that I can tell my View what words to display via my Controller, but I’m trying to figure out where/how to set the contents of my NSArray and NSDictionary.
I thought that I should make properties for the NSArrays and NSDictionary in my header file, and then set their contents in my implementation file under their respective “setters”, but it hasn’t worked so far.
Does anyone have any pointers?
Thank you!
You’d normally have all the strings, arrays and dictionaries in the model. The model will expose such getters as are necessary to allow an external actor to query that data.
It’s the controller’s job to query that data and then push it out to the view.
The view may communicate back to the controller if a user interaction occurs, such as a button press or a list scroll. If so then the controller will likely want to query the model again.
So the actual owner of the data is the model. The controller and view pass ephemeral data back and forth between themselves and the controller will sometimes take data from the model and pass it to the view.