In objective c, how can i check if a string/NSNumber is an integer or int
For NSString, if you use intValue/integerValue, there are certain cases which are not handled as it takes into consideration only the beginning the string.
For example @"bl3h" was not considered an integer but @" 3h" gave an output of 3
My solution for NSString:
Use :
NSCharacterSet *charSet = [NSCharacterSet characterSetWithCharactersInString:strName];
NSCharacterSet *numSet = [NSCharacterSet decimalDigitCharacterSet];
if([numSet isSupersetOfSet: charSet])
{
// It is an integer (or it contains only digits)
}