UITextChecker: memory problem with learning thousands of words

I am trying to analyze a medical dictionary (.csv file) and then study all these words using the UITextChecker: learnword method so that the spellchecker approves these medical terms as valid words.

I call this method on another thread, but the word count in the csv file is about 50KB.

- (void)parseMyCSVFile{

for (int i = 1; i < [csvContent count]; i++) {
    NSString *learntWord = [NSString stringWithFormat:@"%@",[csvContent objectAtIndex:i]];

    NSString *s = learntWord;
    NSCharacterSet *doNotWant = [NSCharacterSet characterSetWithCharactersInString:@" ()\n\""];
    s = [[s componentsSeparatedByCharactersInSet: doNotWant] componentsJoinedByString: @""];


    if ([UITextChecker hasLearnedWord:s]){

        NSLog(@"skipped");

    }
    else
    {
        [UITextChecker learnWord:s]; // Memory Issue Here
        NSLog(@"learning");
    }

    HUD.detailsLabelText = [NSString stringWithFormat:@"%i of %i",i,[csvContent count]];
}

[self performSelectorOnMainThread:@selector(bgWorkEnded) withObject:nil waitUntilDone:YES];

}

I applied the Time Profiler tool and found out that the problem is that I am learning a word inside a loop.

The application tries to load the dictionary up to 5000 words (approximately), and then it will work.

Any help would be appreciated.

thank

+5
source share
2 answers

UIKit - . , , - . UITextChecker , , , . , , .

+1

= 0. . :

for (i=0; i<[csvContent count]; i++)
0

All Articles