Monday, April 30, 2012

How to check if NSString contains only numbers.




NSCharacterSet *_NumericOnly = [NSCharacterSet decimalDigitCharacterSet];
NSCharacterSet *myStringSet = [NSCharacterSet characterSetWithCharactersInString:mystring];
    
if ([_NumericOnly isSupersetOfSet: myStringSet])
{
    //String entirely contains decimal numbers only.
   
        
}






2 comments: