• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Binding not setting model property
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Binding not setting model property


  • Subject: Re: Binding not setting model property
  • From: Roland King <email@hidden>
  • Date: Sun, 19 Jan 2014 14:44:36 +0800

>
> 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@hidden)

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:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Binding not setting model property
      • From: Quincey Morris <email@hidden>
References: 
 >Binding not setting model property (From: Roland King <email@hidden>)
 >Re: Binding not setting model property (From: Dave Fernandes <email@hidden>)
 >Re: Binding not setting model property (From: Roland King <email@hidden>)
 >Re: Binding not setting model property (From: Quincey Morris <email@hidden>)
 >Re: Binding not setting model property (From: Roland King <email@hidden>)
 >Re: Binding not setting model property (From: Quincey Morris <email@hidden>)

  • Prev by Date: iOS 7 downloadable fonts
  • Next by Date: Re: Binding not setting model property
  • Previous by thread: Re: Binding not setting model property
  • Next by thread: Re: Binding not setting model property
  • Index(es):
    • Date
    • Thread