Why is it taking range.length
nil
. I entered text Demo@123
. In this special character is their but length will taking nil
.
NSRange rang = [textField.text rangeOfCharacterFromSet:[NSCharacterSet symbolCharacterSet]];
if ( !rang.length ) {
return NO; // no specialCharacter
}
NSRange is not an object, it's a struct. Lose the
*
character.not
You should be getting a warning for this.
Okey, going through the Unicode tables, it seems that
@
is not a symbol character. It is categorized as punctuation ([NSCharacterSet punctuationCharacterSet]
).