• 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: Validating form input w/o core data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Validating form input w/o core data


  • Subject: Re: Validating form input w/o core data
  • From: Graham Cox <email@hidden>
  • Date: Wed, 28 Sep 2011 17:02:37 +1000

On 28/09/2011, at 11:41 AM, William Squires wrote:

> Is there a general way of validating the contents of a field before it resigns first responder status?


The preferred, supported way is to use a NSFormatter attached to the field. This has the ability to fully constrain and convert values to and from the field's text representation. This is designed to be subclassed. It's unusual to subclass NSTextField itself, especially as it's not the text field that is actually performing the text entry, but a hidden NSTextView called the field editor. Formatters can disallow the focus to be changed away from the text field if the content is not valid. To prevent characters from being entered as they're typed, you'll also want to use the field editor's delegate methods to reject unwanted characters (formatters only validate after the entry is submitted).

--Graham


_______________________________________________

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: Validating form input w/o core data
      • From: Andre Masse <email@hidden>
References: 
 >Validating form input w/o core data (From: William Squires <email@hidden>)

  • Prev by Date: Re: Equivalent of UITextField's textField:shouldChangeCharactersInRange:replacementString for NSTextField
  • Next by Date: (Problems) Scaling NSViews with scaleUnitSquareToSize
  • Previous by thread: Validating form input w/o core data
  • Next by thread: Re: Validating form input w/o core data
  • Index(es):
    • Date
    • Thread