Hi everyone,
I am trying to check a string to see if there are any misspelled words in it. I'm using apples UITextChecker class to do so like so:
#import <UIKit/UITextChecker.h>
id textChecker = [UITextChecker new];
NSInteger currentOffset = 0;
NSRange currentRange = NSMakeRange(0, 0);
NSRange stringRange = NSMakeRange(0, 2);
NSArray *guesses;
NSString *theLanguage = [[UITextChecker availableLanguages] objectAtIndex:0];
if (!theLanguage)
theLanguage = @"en_US";
currentRange = [textChecker rangeOfMisspelledWordInString:currentText range:stringRange
startingAt:currentOffset wrap:NO language:theLanguage];
// NSLog("@currentRange is %i", currentRange);
if (currentRange.location == NSNotFound) {
NSLog(@"No wrong words");
}
else {
NSLog(@"Words were found wrong");
}
}
It always returns "Words were found wrong", no matter what words is put in
What am I doing wrong??
Thanks!!