• 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: Setting Min, MAx and range of characters for NSTextField
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting Min, MAx and range of characters for NSTextField


  • Subject: Re: Setting Min, MAx and range of characters for NSTextField
  • From: Kyle Sluder <email@hidden>
  • Date: Fri, 10 Apr 2009 00:52:21 -0400

On Thu, Apr 9, 2009 at 7:02 PM, Preston Jackson
<email@hidden> wrote:
> Anyone have any ideas on this?

First, you typically don't bind views directly to the model.  You
instead bind them through a controller.

I did a quick test, however, in which I did bind an NSTextField
straight to my model.  I created a simple NSObject subclass with an
NSString property called "uppercaseString".  I also implemented
-validateUppercaseString:error: to always convert the string to
uppercase.  I then bound an NSTextField to this property, and turned
on "Validates Immediately."  It works like a charm.

Here is my implementation of -validateUppercaseString:error:, for reference.

- (BOOL)validateUppercaseString:(id *)newValue error:(NSError **)error
{
   if(*newValue == nil)
      return YES;

   *newValue = [*newValue uppercaseString];
   return YES;
}

How does your implementation differ?  Are you perhaps mutating the
*newValue instead of returning a new object, as the documentation says
you must?  http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/KeyValueCoding/Concepts/Validation.html#//apple_ref/doc/uid/20002173-168285

--Kyle Sluder
_______________________________________________

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: Setting Min, MAx and range of characters for NSTextField
      • From: Preston Jackson <email@hidden>
References: 
 >Setting Min, MAx and range of characters for NSTextField (From: development2 <email@hidden>)
 >Re: Setting Min, MAx and range of characters for NSTextField (From: Preston Jackson <email@hidden>)

  • Prev by Date: Re: OO idiom avoiding switch and if
  • Next by Date: Undocumented flags in LSCopyItemInfoForRef
  • Previous by thread: Re: Setting Min, MAx and range of characters for NSTextField
  • Next by thread: Re: Setting Min, MAx and range of characters for NSTextField
  • Index(es):
    • Date
    • Thread