Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Well, I found a solution that works using UIKit/UITextChecker. It correctly finds the user's most preferred language dictionary, but I'm not sure if it includes learned words in the actual <code>rangeOfMisspelledWords...</code> method. If it doesn't, calling <code>[UITextChecker hasLearnedWord]</code> on currentWord inside the bottom if statement should be enough to find user-taught words.</p> <p>As noted in the comments, it may be prudent to call <code>rangeOfMisspelledWords</code> with each of the top few languages in <code>[UITextChecker availableLanguages]</code>, to help multilingual users.</p> <pre><code>-(void) checkForDefinedWords { NSArray* words = [message componentsSeparatedByString:@" "]; NSInteger wordsFound = 0; UITextChecker* checker = [[UITextChecker alloc] init]; //get the first language in the checker's memory- this is the user's //preferred language. //TODO: May want to search with every language (or top few) in the array NSString* preferredLang = [[UITextChecker availableLanguages] objectAtIndex:0]; //for each word in the array, determine whether it is a valid word for(NSString* currentWord in words){ NSRange range; range = [checker rangeOfMisspelledWordInString:currentWord range:NSMakeRange(0, [currentWord length]) startingAt:0 wrap:NO language:preferredLang]; //if it is valid (no errors found), increment wordsFound if (range.location == NSNotFound) { //NSLog(@"%@ %@", @"Valid Word found:", currentWord); wordsFound++; } else { //NSLog(@"%@ %@", @"Invalid Word found:", currentWord); } } //After all "words" have been searched, save wordsFound to validWordCount [self setValidWordCount:wordsFound]; [checker release]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload