ios - Filtering Out Inappropriate Words from a Chatroom -
Actually, I am posting a function below which posts a chat post in the chat room (other course work Calling) This works perfectly, however, my app was rejected by Apple because of the potential of inappropriate content in my chat room, so, by creating an array of inappropriate words, for loop through that array User's post using * based on the length of the words decided to filter out inappropriate content by searching for an inappropriate term for the message (under the variable message) and transferring that word with that amount. Below is my code, but I'm missing some stuff. Please tell me whether to add code, or it's a better way to do it. Here is my code (Note: Blacklist is my incomplete word): Why do not you just do this in the loop
- (zero) displayChatMessage: (NSString *) Message by user: (NSString *) Username {int i = 0; Int goodJobRunCount = 0; (I = 0; i & lt; [blacklist calculation]; i ++) {nssting * car = [blacklist objectitancex: i]; NSRange searchResult = [Message limitoffstring: car]; If (searchResult.location == NSNotFound) {goodJobRunCount = goodJobRunCount + 1; If (goodjourboncount> = i) {message2 = [NSString stringWithFormat: message]; }} And {the length of the nsuinter = search result. Lamps; Int runlevel = 0; Message2 = [NSString stringWithFormat: @ ""]; While (run length: Lt; length) {NSString * string2 = [message2 stringByAppendingFormat: @ "*"]; Message2 = [NSString stringWithFormat: string2]; RunLength = runLength + 1; }}} [Chat AppendTatal Librac: [NSString stringWithFormat: @ "% @:% @", user name, message]]; [Chattoobotam chat: chat];
< Code> (int i = 0; i & lt; blacklist.count; i ++) {NSMutableString * stars = [NSMutableString alloc] init]; NSRange searchResult = [Message limitoffstring: (NSString *) [blackList objectItindex: if (searchResult.location == NSNotFound) is in progress; // break or whatever, for obj-c (int j = 0; j & lt; (nsstring *) [black list object endx: i]. Length; j ++) [stars ependrasting: @ "*"] ; Message = [message stringing overwriting offstring: (nssting *) [blacklist objectwithx: i] with straightening: stars]; }
Comments
Post a Comment