|
|
@@ -1061,6 +1061,62 @@ done:
|
|
|
return expectedSize;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
++ (BOOL) validateEmail:(NSString *)email
|
|
|
+{
|
|
|
+ NSString *regex1 = @"\\A[a-z0-9]+([-._][a-z0-9]+)*@([a-z0-9]+(-[a-z0-9]+)*\\.)+[a-z]{2,4}\\z";
|
|
|
+ NSString *regex2 = @"^(?=.{1,64}@.{4,64}$)(?=.{6,100}$).*";
|
|
|
+ NSPredicate *test1 = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex1];
|
|
|
+ NSPredicate *test2 = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex2];
|
|
|
+ return [test1 evaluateWithObject:email] && [test2 evaluateWithObject:email];
|
|
|
+}
|
|
|
++ (BOOL)checkPassword:(NSString *) password
|
|
|
+{
|
|
|
+ NSString *pattern = @"^(?![0-9]+$)(?![a-zA-Z]+$)[a-zA-Z0-9]{6,18}";
|
|
|
+ NSString *pattern1 = @"^(?=.*)(?=.*[a-z])(?=.*[~!@#$%^&*:;,.=?$\x22]).{8,16}$";
|
|
|
+ NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", pattern];
|
|
|
+ NSPredicate *pred1 = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", pattern1];
|
|
|
+ BOOL isMatch = [pred evaluateWithObject:password];//||[pred evaluateWithObject:password];
|
|
|
+ return isMatch;
|
|
|
+
|
|
|
+}
|
|
|
++ (UIViewController *)getCurrentVC
|
|
|
+{
|
|
|
+ UIViewController *rootViewController = [UIApplication sharedApplication].keyWindow.rootViewController;
|
|
|
+
|
|
|
+ UIViewController *currentVC = [self getCurrentVCFrom:rootViewController];
|
|
|
+
|
|
|
+ return currentVC;
|
|
|
+}
|
|
|
++ (UIViewController *)getCurrentVCFrom:(UIViewController *)rootVC
|
|
|
+{
|
|
|
+ UIViewController *currentVC;
|
|
|
+
|
|
|
+ if ([rootVC presentedViewController]) {
|
|
|
+ // 视图是被presented出来的
|
|
|
+
|
|
|
+ rootVC = [rootVC presentedViewController];
|
|
|
+ }
|
|
|
+
|
|
|
+ if ([rootVC isKindOfClass:[UITabBarController class]]) {
|
|
|
+ // 根视图为UITabBarController
|
|
|
+
|
|
|
+ currentVC = [self getCurrentVCFrom:[(UITabBarController *)rootVC selectedViewController]];
|
|
|
+
|
|
|
+ } else if ([rootVC isKindOfClass:[UINavigationController class]]){
|
|
|
+ // 根视图为UINavigationController
|
|
|
+
|
|
|
+ currentVC = [self getCurrentVCFrom:[(UINavigationController *)rootVC visibleViewController]];
|
|
|
+
|
|
|
+ } else {
|
|
|
+ // 根视图为非导航类
|
|
|
+
|
|
|
+ currentVC = rootVC;
|
|
|
+ }
|
|
|
+
|
|
|
+ return currentVC;
|
|
|
+}
|
|
|
@end
|
|
|
|
|
|
|