/**
*? 過(guò)濾敏感詞匯
*
*? @return YES/NO
*/
+ (BOOL)checkIllegalWords:(NSString *)words {
// 讀取文件
NSString *filterPath = [[NSBundle mainBundle] pathForResource:@"filter" ofType:@"txt"];
NSString *filterStr = [[NSString alloc] initWithContentsOfFile:filterPath encoding:NSUTF8StringEncoding error:nil];
NSArray *filterArr = [filterStr componentsSeparatedByString:@"\r\n"];
BOOL isLegal = YES;
for (NSString *oneItem in filterArr) {
if ([words rangeOfString:oneItem].location != NSNotFound) {
isLegal = NO;
break;
}
}
return isLegal;
}