为什么NSNumberFormatter不接受加号

时间:2011-10-03 00:36:17

标签: ios

if(![myNumberFormatter numberFromString:[tempColumn objectAtIndex:j]])
{
    numericalColumns[j] = NO;
    if(j == 8)
    {
        NSLog(@" non numerical value in column 8 i = %d object = %@ ", i , [tempColumn           objectAtIndex:j]);
    }
}

我发现:

0   good
-19.49883745    good
+38.85928608    bad
+46.94000154    bad
-0.36042119     good
+38.30408636    bad
-44.29029741    good
+26.91823821    bad
-79.06183133    good
-16.69693020    good

1 个答案:

答案 0 :(得分:2)

尝试这样做:

[myNumberFormatter setPositivePrefix:@"+"];

在调用numberForString

之前