On 10 Aug 2014, at 19:15, Quincey Morris <quinceymor...@rivergatesoftware.com> 
wrote:

> 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’.

Of course, why didn't I think of that?!
Am I right that you can't use dot notation to reference 'document' because 
'self.window.windowController' returns an 'id' type object, or am i missing 
somethind. I'm getting an error in XCode when using the above dot notation.

> 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.

Let's see if I understand this correctly: do you mean I could create a separate 
model class, eg. "Drawing" with all of it's properties and reference this in my 
document class as an instance variable or even as a property.
Then, from my custom view, instead of using [[self.window.windowController 
document] someProperty]', I could use '[self.window.windowController 
someProperty]', which in turn would message my model object to return the value 
of 'someProperty' using 'return [self.document someProperty]' ? 

> 
> 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.
> 

Thanks for any advise.
Luc.

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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

Reply via email to