Saturday, 30 November 2013

Check whether NSString starts with aplhabet letter only.


+(BOOL)validateFirstCharacterAsAlphabet:(NSString *)str;
{
    NSRange first = [str rangeOfComposedCharacterSequenceAtIndex:0];
    NSRange match = [str rangeOfCharacterFromSet:[NSCharacterSet letterCharacterSet] options:0 range:first];
    if (match.location != NSNotFound) {
        // String starts with a letter
        return YES;
    }
    return NO;
    
}