I am in the process of learning Cocoa. I was going through 3 key classes that form the basis of document architecture in Cocoa.
NSDocumentsubclassNSWindowControlleror its subclassNSDocumentController
I thought NSWindowController must be Controller in terms of MVC and NSDocument being Model. Any view we create in interface builder will be essentially a View. If it is correct then NSWindowController or its subclass should get the instance of NSDocument and it should handle all the saving, loading, updating tasks. But reading the documentation and books, it seems like NSDocument itself handles these tasks. Seems like model is doing a part of controller’s job and I find it difficult to digest. What am I missing? Please can you clarify the conceptual model?
NSDocument can hardly be considered a model object. It is a model controller, it owns the data model. Also, it owns window controllers, which a model object should not be doing.
A model controller should not be confused with a view controller that owns the view.
So, I would say NSDocument cannot be absolutely matched to any of those elements of the Mode-View-Controller pattern.