View Full Version : How to know which views are using my custom ModelView?

5th July 2011, 14:15

Giving that a model can be shared between several views.. How can I know which views are using my model from inside the my model class?


5th July 2011, 14:27
In general, you can't; this would violate the model/view design. Models are sources of data and nothing more; they provide data upon request, without regard for the view asking for it.

Most often, if you find yourself wanting this sort of information, there's something wrong with your design.

5th July 2011, 14:36
seems that public ItemModel API doesn't allow to know connected views.

I think it is correct because the Models provide data and don't need to know where and how these data are displayed.

If you need you can inherits your model class and reimplement setModel in order to save views list