Search code examples
macoscocoansdocumentnsviewcontroller

In OS X who owns the model, NSDocument or NSViewController


Working in iOS I've never dealt with OS X and NSDocument based apps. Where should the model reference live, inside the NSDocument or the representedObject in the NSWindow's content NSViewController? Or both?


Solution

  • It should be stored in the NSDocument object as stated by the Apple documentation in here. In particular, check Figure 1-1. Further below, on the same page, Apple states that a data model corresponds to a document type, so if you have different models you should use different document types that should be stored in NSDocument objects.