开发者

Why does NSNumberFormatter not accept plus number

开发者 https://www.devze.com 2023-04-09 21:06 出处:网络
if(![myNumberFormatter numberFromString:[tempColumn objectAtIndex:j]]) { numericalColumns[j] = NO; if(j == 8)
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]);
    }
}

What I find:

0   good
-19.49883745    good
+38.85928608    bad
+46.94000154    b开发者_开发技巧ad
-0.36042119     good
+38.30408636    bad
-44.29029741    good
+26.91823821    bad
-79.06183133    good
-16.69693020    good


Try doing this:

[myNumberFormatter setPositivePrefix:@"+"];

before calling numberForString

0

精彩评论

暂无评论...
验证码 换一张
取 消