It’s easy way to do spell check about various countries’ language.(一种快捷方便的方法来对各种国家的语言做拼写检查.)
#import "ZWSpellCheckTool.h"
ZWSpellCheckTool *spellCheckTool =[[ZWSpellCheckTool alloc]init];
spellCheckTool.languageType=1;
NSMutableArray *errorArr =[spellCheckTool ZWWordCheckToolWith:self.textContentView.text];
self.textContentView.attributedText=[spellCheckTool addSelectedErrorWordIntext:self.textContentView.text WithTextFont:self.textContentView.font WithArr:errorArr WithErrorColor:[UIColor redColor] WithUnderline:YES];
-(void)spellCheck {
//耗时操作,创建子线程,用于查找输入错误的单词
__weak typeof(self) weakSelf = self;
dispatch_queue_t downloadQueue = dispatch_queue_create("findErrorWords", NULL);
dispatch_async(downloadQueue, ^{
ZWSpellCheckTool *spellCheckTool =[[ZWSpellCheckTool alloc]init];
//设置检查语言类型
spellCheckTool.languageType=1;
//返回错误的单词
NSMutableArray *errorArr =[spellCheckTool ZWWordCheckToolWith:weakSelf.textContentView.text];
dispatch_sync(dispatch_get_main_queue(), ^{
//在回到主线程,刷新UI,给错误单词标红
weakSelf.textContentView.attributedText=[spellCheckTool addSelectedErrorWordIntext:weakSelf.textContentView.text WithTextFont:weakSelf.textContentView.font WithArr:errorArr WithErrorColor:[UIColor redColor] WithUnderline:YES];
}); });
}