- (void)uploadUserNameDataWithUserName:(NSString *)userName
{
NSString *regex = @"(^[\u4E00-\u9FA5A-Za-z]+$)";
NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
if(![pred evaluateWithObject:userName])
{
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"昵称只能由中文或字母组成" delegate:self cancelButtonTitle:@"确定" otherButtonTitles: nil];
[alertView show];
}
else
{
if (userName.length == 0) {
dispatch_async(dispatch_get_main_queue(), ^{
[MTCustomAlertView showCustomAlertViewWithContent:@"用户昵称不能为空" andRect:KTOASTRECT andTime:3.0f andObject:self];
});
} else if (userName.length > 10) {
dispatch_async(dispatch_get_main_queue(), ^{
[MTCustomAlertView showCustomAlertViewWithContent:@"请输入10个以内中文、字母或汉字" andRect:KTOASTRECT andTime:3.0f andObject:self];
});
} else {
if ([MTUnit allSpace:userName]) {
dispatch_async(dispatch_get_main_queue(), ^{
[MTCustomAlertView showCustomAlertViewWithContent:@"不能输入空格" andRect:KTOASTRECT andTime:3.0f andObject:self];
});
} else {
_userName = userName;
NSDictionary *params = @{
@"userId" : [WMUserDataManager readPassWord],
@"nickname" : userName
};
[self uploadUserInfoNetworking:params];
[MTNotification postNotificationName:uploadUserHeadImageOrUserNameNote object:self userInfo:nil];
}
}
}
}
网友评论