First, thanks to everyone who suggested ways to handle this. Next, an
admission of guilt for faulty memory; mine, not my Mac's: in poking
around, I discovered that I'd asked pretty much the same question (for
ints) nearly 2 years ago and had gotten similar answers. My apologies.
I've deci
On 20 Mar 2008, at 23:38, John Stiles wrote:
Localization concerns still apply in theory but in practice there
are few locales which don't use standard numeric characters.
Actually, well, I don't know if sscanf knows about using "," for the
decimal separator in Europe or not.
As long as y
You could always do this
float value;
if (1 == sscanf([myString UTF8String], "%f", &value))
{
// the string was a valid float
}
else
{
// it wasn't
}
For integer, replace "float" with "int" and "%f" with "%d".
Localization concerns still apply in theory but in practice there are
few loca
On 20 Mar 2008, at 23:26, Quincey Morris wrote:
On Mar 20, 2008, at 16:13, Boyd Collier wrote:
According to Apple's documents, the selector doubleValue returns
0.0 if the instance of an NSString that is the receiver "doesn’t
begin with a valid text representation of a floating-point
num
Setting up NSScanner for this is trivial, if I'm understanding the
question...
double doubleValue;
NSScanner *scanner = [NSScanner scannerWithString: stringToCheck];
if ([scanner scanDouble: &doubleValue])
{
// doubleValue has your double's value.
}
else
On Mar 20, 2008, at 16:13, Boyd Collier wrote:
According to Apple's documents, the selector doubleValue returns 0.0
if the instance of an NSString that is the receiver "doesn’t begin
with a valid text representation of a floating-point number." Is
there a simple way to distinguish betwee
According to Apple's documents, the selector doubleValue returns 0.0
if the instance of an NSString that is the receiver "doesn’t begin
with a valid text representation of a floating-point number." Is
there a simple way to distinguish between the string 0.0, which
shouldn't be considered