How to check if NSString is numeric (integer or float):
NSScanner *scan = [NSScanner scannerWithString:@"string"];
if (![scan scanFloat:NULL] || ![scan isAtEnd])
{
NSlog (@"string exist like 'abbc','12ww','1.5w',' 5 ' etc");
}
else
{
NSlog (@"only numeric value like '12','12.5','1.5' etc");
}
No comments:
Post a Comment