I have a UITextField called textfield. And I have this code to check if the text in the textfield is equal to “exampletext”
if ([textfield.text isEqualToString:@"exampletext"]) {
NSLog(@"Correct");
} else {
NSLog(@"Wrong");
}
But I also want to check if the text in the textfield is almost equal to “exampletext”, if the text is almost the same as “exampletext”. Like if the text was “eampletex” I want to NSLog(@”Close”)
Are there any ways to check if the textfield text is like 50% equal to “exampletext”?
Or any ways to check if the textfield text has 50% the same characters as “exampletext”?
Or something else like that?
Here’s my go at it. Create a custom character set from the string you want to match. Check each character in the texfield.text against that character set, and if the number of matches is close to the number of letters in the string, do something..
Not sure if this is 100% what you’re looking for, but maybe it will help anyway…