在iOS UITextChecker上’;他的执行速度非常慢
在iOS上,在iOS UITextChecker上’;他的执行速度非常慢,ios,objective-c,ipad,Ios,Objective C,Ipad,在iOS上,UITextChecker的执行速度非常慢,我想在我的项目中添加和删除大约50000个(learnWord:/unlearnWord:)。这个过程需要5到6个多小时。有没有办法优化它?或者有什么简单的替代方案 我尝试了以下演示: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { NSString *word
UITextChecker的执行速度非常慢,我想在我的项目中添加和删除大约50000个(learnWord:/unlearnWord:
)。这个过程需要5到6个多小时。有没有办法优化它?或者有什么简单的替代方案
我尝试了以下演示:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSString *word = @"test";
CFTimeInterval startTime1 = CACurrentMediaTime();
BOOL hasLearnWord = [UITextChecker hasLearnedWord:word];
CFTimeInterval endTime1 = CACurrentMediaTime();
NSLog(@"Execution Time 1: %f, hasLearnWord: %@", endTime1 - startTime1, hasLearnWord ? @"Yes" : @"No");
CFTimeInterval startTime2 = CACurrentMediaTime();
[UITextChecker unlearnWord:word];
CFTimeInterval endTime2 = CACurrentMediaTime();
NSLog(@"Execution Time 2: %f", endTime2 - startTime2);
CFTimeInterval startTime3 = CACurrentMediaTime();
[UITextChecker learnWord:word];
CFTimeInterval endTime3 = CACurrentMediaTime();
NSLog(@"Execution Time 3: %f", endTime3 - startTime3);
return YES;
}
结果:
2014-03-05 05:48:20.064 demo[316:60b] Execution Time 1: 0.593178, hasLearnWord: Yes
2014-03-05 05:48:20.643 demo[316:60b] Execution Time 2: 0.576586
2014-03-05 05:48:21.219 demo[316:60b] Execution Time 3: 0.575505