May 26, 2014

[iOS] is Numeric ?

The simplest way to get to know one string is a number.

+ (BOOL) isNumeric:(NSString *)str
{
    NSScanner *sc = [NSScanner scannerWithString: str];
    if ( [sc scanFloat:NULL] )
    {
        return [sc isAtEnd];
    }
    return NO;

}

No comments:

Post a Comment