I need to check if a char is digit or not.
NSString *strTest=@\"Test55\";
char c =[strTest characterAtIndex:4];
I need to find out if \'c\' is
Note: The return value for characterAtIndex:
is not a char
, but a unichar
. So casting like this can be dangerous...
An alternative code would be:
NSString *strTest = @"Test55";
unichar c = [strTest characterAtIndex:4];
NSCharacterSet *numericSet = [NSCharacterSet decimalDigitCharacterSet];
if ([numericSet characterIsMember:c]) {
NSLog(@"Congrats, it is a number...");
}