-(BOOL) Checkidentitycardno: (nsstring*) Cardno
{
if (cardno.length! = 18) {
return NO;
}
nsarray* Codearray = [Nsarray arraywithobjects:@ "7", @ "9", @ "10", @ "5", @ "8", @ "4", @ "2", @ "1", @ "6", @ "3", @ "7", @ "9", @ "10", @ "5", @ "8", @ "4", @ "2", nil];
nsdictionary* checkcodedic = [nsdictionary dictionarywithobjects:[nsarray arraywithobjects:@ "1", @ "0", @ "X", @ "9", @ "8" , @ "7", @ "6", @ "5", @ "4", @ "3", @ "2", Nil] Forkeys:[nsarray arraywithobjects:@ "0", @ "1", @ "2", @ "3", @ "4", @ "5", @ "6", @ "7", @ " 8 "@" 9 "@" ten ", Nil]];
nsscanner* scan = [Nsscanner scannerwithstring:[cardno substringtoindex:17];
int Val;
BOOL isnum = [scan scanint:&val] && [scan isatend];
if (!isnum) {
return NO;
}
int sumvalue = 0;
for (int i =0; i<17; i++) {
Sumvalue+=[[cardno Substringwithrange:nsmakerange (i, 1)] intvalue]* [[Codearray objectatindex:i] intValue];
}
nsstring* strlast = [checkcodedic objectforkey:[nsstring stringwithformat:@ "%d", sumvalue%11]];
if ([Strlast isequaltostring: [[Cardno Substringwithrange:nsmakerange (1)]uppercasestring]]) {
return YES;
}
return NO;
}
-(BOOL) Ismobilenumber: (NSString *) mobilenumstring
{
NSString *pattern = @ "^1+[3578]+\\d{9}";
Nspredicate *pred = [Nspredicate predicatewithformat:@ "Self MATCHES%@", pattern];
BOOL IsMatch = [pred evaluatewithobject:mobilenumstring];
return isMatch;
}
IOS-Verify that the correct ID number and phone number are entered