Monday, July 16, 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.
   
        
}

No comments:

Post a Comment