Reputation: 11320
I'm going through my code to make sure that all of my properties have the proper weak/strong modifier and I ran across this situation which I don't know what to do with. Keep in mind that I'm fairly new to iOS programming.
I have a normal MVC hierarchy where my controller creates an object called FieldManager
. This FieldManager
is used by my controller to dynamically create textfields. However, this FieldManager
also needs to be used by the controller's model to periodically query the manager to find out information about the fields (such as is it required, should it's text be capitalized...etc).
So to summarize, I have a controller which creates an object that is used both by the controller and the controller's model. Therefore, I don't know if I should make the model's reference to FieldManager
a weak property or the controller's reference to it a weak property. It seems that I should make both weak properties, otherwise FieldManager
will get released. What should I do?
Thanks.
Upvotes: 0
Views: 103
Reputation: 10114
Things like that should belong to your model, so the way to go is to have a datasource.
Your controller asks the datasource to create and return the textfields, the datasource contacts the model and asks for a field manager for that model.
That's the way I would do it...
Upvotes: 1