判断字符串为6~12位“字符”

来源:互联网 发布:mac如何卸载flash插件 编辑:程序博客网 时间:2024/04/29 06:45

- (BOOL)isValidateName:(NSString *)name{

        NSUInteger  character = 0;

        for(int i=0; i< [name length];i++){

            int a = [name characterAtIndex:i];

            if( a > 0x4e00 && a < 0x9fff){ //判断是否为中文

                character +=2;

            }else{

                character +=1;

            }

        }


    if (character >=6 && character <=12) {

        return YES;

    }else{

        return NO;

    }


}

1 0
原创粉丝点击