• 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 an NSTextField
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Binding an NSTextField


  • Subject: Re: Binding an NSTextField
  • From: Mike Abdullah <email@hidden>
  • Date: Fri, 4 Jul 2008 09:53:04 +0100


On 4 Jul 2008, at 06:15, Alex Wait wrote:

I have two methods setTheString and theString.

They return the value of another NSTextField on my window.
In IB I binded the value of the textField to App Controller and the Model
Key Path to "theString".


theString() is only called when the app first starts up.

Firstly, it's -theString, not theString().

What you are doing sounds like a big no-no in MVC design. It sounds to me like your code does something like:

- (NSString *)theString
{
	return [textField stringValue];
}


In which case, how on Earth is the binding supposed to know when the result of that method has changed? It is not KVO compliant.


Instead, you want to create a perfectly *standard* accessor method for the -theString and -setTheString: that returns an instance variable. Then, bind both of your text fields to it. That will ensure proper KVO compliance.
_______________________________________________


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


References: 
 >Binding an NSTextField (From: "Alex Wait" <email@hidden>)

  • Prev by Date: Re: IB3 and custom controls: problem with actions
  • Next by Date: Re: Outline View and Bindings
  • Previous by thread: Binding an NSTextField
  • Next by thread: IB3 and custom controls: problem with actions
  • Index(es):
    • Date
    • Thread