基本上,我在 iphone 应用程序中有一个聊天室,我想阻止其中不恰当的词。我有一个名为 blackList 的这些单词的数组。但是,每当我运行下面的代码时,我都会收到“”的错误和“ use of undeclared identifier 'foundRange'
”的警告incompatible pointer types passing NSString to parameter of type 'CFStringRef (aka 'const struct _ CFString
。问题是什么?请在您的答案中提供代码。这是我的代码:
- (void)displayChatMessage:(NSString*)message fromUser:(NSString*)userName {
int i=0;
for (i=0; i<[blackList count] ; i++){
NSString *one = [NSString stringWithFormat:@"%@",[blackList objectAtIndex:i]];
if (CFStringFindWithOptions(message,one , CFRangeMake(0,CFStringGetLength(message)), kCFCompareCaseInsensitive, &foundRange) == true) {
/*do nothing*/
}
else {
[chat appendTextAfterLinebreak:[NSString stringWithFormat:@"%@: %@", userName, message]];
[chat scrollToBottom:chat];
}
}
}