>
> In practice, I never do it that way any more. I always create a derived
> property on the view or window controller that’s based on the data model
> property. So, from the views’ point of view, the view/window controller *is*
> the data model, but it’s insulated from the real data model. (Specifically,
> doesn’t have to #import the data model header files, which has housekeeping
> benefits.)
>
> The cost is writing a trivial getter and setter, and a
> ‘keyPathsForValuesAffecting…’ method in the controller.
>
I've tried really hard to understand this but I'm not quite getting it, sorry,
must just be a bit dense today.
My model object has a property, codeURL, it's a URL.
My view has an NSTextField which is bound to the codeURL via a transformer. All
good thus far.
The browse button pulls up an NSOpenPanel and the selected URL of that wants to
be set back on the codeURL property. Currently I have the model object as a
property of the view and in the NSOpenPanel callback I'm doing
[ self.modelObject setCodeURL:newURL ];
which sets the URL and the change propagates back to the text view via the
binding. That does indeed require importing the model object header.
What derived property can I write on the view which removes that dependency? I
can write a derived codeURL property on the view quite easily, the setter of
which updates the NSTextField, the getter of which uses the NSTextField string,
that's a setter/getter and keyPathsForValuesAffecting.. . I can then have the
browse button set that property with
[ self setCodeURL:newURL ]
instead .. but how do I then connect/bind that codeURL property to the real one
in the model object?
_______________________________________________
Cocoa-dev mailing list ([email protected])
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 [email protected]