On Aug 10, 2014, at 09:01 , Luc Van Bogaert <luc.van.boga...@me.com> wrote:
> I was thinking of using a weak property for my custom view to reference the > document and set this property from the same windowDidLoad: method, but I'm > not sure if this is a good approach to take. Any advise on this? It’s not a bad approach, but it’s probably not necessary, since the view can already get the document as ‘self.window.windowController.document’. In a simple project, putting a reference to the document from a view is fine, but in a larger project I’d be a bit reluctant. The “problem” is that it puts some implementation details (that your data model is implemented in a subclass of NSDocument) in a place where they’re really irrelevant. A better approach is to define your data model separately from the document, even if the document is responsible for creating and owning the data model. The window controller would vend references to the data model (not the document) to views and view controllers that need it. In an even more sophisticated project, this may still over-constrain your design. Another approach is to create an auxiliary data model in the window controller, that’s specific to the needs of the custom view. The window controller is then responsible (usually via KVO observations) for keeping the auxiliary model in sync with the main data model. The point here is to reduce the amount of information that’s globally known, because you’ll find (in later design iterations) that global knowledge will frustrate your attempts to rearrange your design as you add features, or come to understand the design problem better. _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com