Re: Preventing empty NSTextFields that use NSNumberFormatter
Re: Preventing empty NSTextFields that use NSNumberFormatter
- Subject: Re: Preventing empty NSTextFields that use NSNumberFormatter
- From: Keary Suska <email@hidden>
- Date: Mon, 04 Aug 2014 15:31:16 -0600
On Aug 4, 2014, at 12:01 PM, Sean McBride <email@hidden> wrote:
> NSNumberFormatter, applied to an NSTextField, will very nicely reject things like letters, and optionally a bunch of things like negative numbers, non-integers, etc.
>
> But I've just noticed that it doesn't seem to help if the textfield is left entirely empty. Is that not something NSNumberFormatter can help with? I just find that surprising with all the other options it has...
Unfortunately, no.
> If it can't, I guess the best choices are using NSControlTextEditingDelegate or key value validation...?
Yes, or subclass. If your backing property is a C primitive you could use setNilValueForKey to force nil to mean something.
HTH,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
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