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

Re: NSTextField and bindings


  • Subject: Re: NSTextField and bindings
  • From: Fritz Anderson <email@hidden>
  • Date: Tue, 4 May 2004 11:10:01 -0500

Look in the documents by doing a full-text search for "Key-Value Validation."

<http://developer.apple.com/documentation/Cocoa/Conceptual/ KeyValueCoding/Concepts/Validation.html>

-- F

On 4 May 2004, at 10:45 AM, Steve Sims wrote:

I have an NSTextField in my app and I'm using bindings to hook it up to my data model. Now it's important that this text field keeps a value, and is not set to an empty string. With that in mind I wrote a quick setter method as follows:

- (void)setText:(NSMutableString *)newText {
if ((text != newText) && ([newText length]>0)) {
[text release];
text = [newText copy];
}
}

Now whilst this ensures that within my data model the text field keeps its value when an empty string is attempted to be entered in the UI the UI does not reflect this: the text field on screen stays empty.

I tried adding in [self willChangeValueForKey:@"text"]; and [self didChangeValueForKey:@"text"]; calls at the beginning and end of this setter (outside the if) since I thought that may force the UI to update, but it didn't work.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >NSTextField and bindings (From: Steve Sims <email@hidden>)

  • Prev by Date: Re: Lost Main Menu (was bug in IB ?)
  • Next by Date: Re: NSTextField and bindings
  • Previous by thread: NSTextField and bindings
  • Next by thread: Re: NSTextField and bindings
  • Index(es):
    • Date
    • Thread