FROM : Matt Neuburg
DATE : Sun Jul 09 00:07:45 2006
I'm using an NSNumberFormatter, created in code, to validate a string
entered by the user. I create the NSNumberFormatter, set its characteristics
including its behavior, which I'm setting at NSNumberFormatterBehavior10_4,
and then send it getObjectValue:forString:range:error: to get back a BOOL
telling me whether the string is a valid number according to my criteria.
However, it isn't quite working as advertised.
(1) setAllowsFloats:NO does nothing. I would expect this to mean that a
non-integer would be invalid, but it isn't so. getObjectValue: returns YES.
(2) The docs say that setMaximum:nil will disable checking for maximum
value. But on the contrary, if I setMaximum:nil, checking does occur, and in
fact all values are deemed invalid.
Only the first is really important; I'd like to detect that the number is an
integer. This works just fine if the behavior is
NSNumberFormatterBehavior10_0, so is NSNumberFormatterBehavior10_4 just
broken? I'll be glad to file a bug if this is one.
m.
--
matt neuburg, phd = <email_removed>, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
DATE : Sun Jul 09 00:07:45 2006
I'm using an NSNumberFormatter, created in code, to validate a string
entered by the user. I create the NSNumberFormatter, set its characteristics
including its behavior, which I'm setting at NSNumberFormatterBehavior10_4,
and then send it getObjectValue:forString:range:error: to get back a BOOL
telling me whether the string is a valid number according to my criteria.
However, it isn't quite working as advertised.
(1) setAllowsFloats:NO does nothing. I would expect this to mean that a
non-integer would be invalid, but it isn't so. getObjectValue: returns YES.
(2) The docs say that setMaximum:nil will disable checking for maximum
value. But on the contrary, if I setMaximum:nil, checking does occur, and in
fact all values are deemed invalid.
Only the first is really important; I'd like to detect that the number is an
integer. This works just fine if the behavior is
NSNumberFormatterBehavior10_0, so is NSNumberFormatterBehavior10_4 just
broken? I'll be glad to file a bug if this is one.
m.
--
matt neuburg, phd = <email_removed>, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
| Related mails | Author | Date |
|---|---|---|
| No related mails found. | ||






Cocoa mail archive

