To run the example project, clone the repo, and run pod install
from the Example directory first.
self.converterService = [LWConverterService serviceWithDBPath:dbPath bihuaDBPath:bihuaDBPath];
//查询拼音,五笔(异步)
[self.converterService queryWithZi:zi updateUIBlock:^(NSString *pinyin, NSString *wubi) {
if(!pinyin){
pinyin = @"";
}
pinyinText = [NSString stringWithFormat:@"%@ %@", pinyinText, pinyin];
if(!wubi){
wubi = @"";
}
wubiText = [NSString stringWithFormat:@"%@ %@", wubiText, wubi];
}];
//查询笔顺(异步)
[self.converterService queryBiShunWithZi:zi updateUIBlock:^(NSString *bishun) {
if(!bishun){
bishun = @"";
}
bishunText = [NSString stringWithFormat:@"%@ %@", bishunText, bishun];
}];
//翻译
__weak typeof(self) weakSelf = self;
[self.converterService fanyiZi:self.sourceText to:self.translateLanguage updateUIBlock:^(NSString *translation, BOOL isError) {
if (isError) {
//todo: handle error
} else {
//todo: set translation
}
}];
if([inputText isEqualToString:@""] || [LWEncryptService isEncryptString:inputText]){
//decrypt text from paste
NSString *pasteText = [UIPasteboard myPasteboard].string;
if([LWEncryptService isEncryptString:pasteText]){
NSString *decryptText = [LWEncryptService decryptText:text]
//todo: print decryptText
}
}else{ // encrypt text
NSArray *array = [LWEncryptService getShortcut];
NSUInteger index = arc4random() % array.count;
NSString *encryptText = [LWEncryptService encryptText:inputText displayText:array[index]];
//todo: print encryptText
}
LWWordConverter is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'LWWordConverter'
luowei, luowei@wodedata.com
LWWordConverter is available under the MIT license. See the LICENSE file for more info.