Need to filter our swear words that are inputted to the iPhone app and inserted to our database. I'd like to catch this before passing to our database.
Currently, I was using: stringByReplacingOccurrencesOfString:@"swear" withString:@"" but this seems inefficient to list 20+ words that need to be filtered. What's the best way to approach this?
Here is my complete code
NSUserDefaults *p = [NSUserDefaults standardUserDefaults];
NSString* string1 = [[p valueForKey:@"user"] stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
NSString* string2 = [[p valueForKey:@"pass"] stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
NSString* string3 = [[[[[[[[[[[[[[tvA.text stringByReplacingOccurrencesOfString:@"\n" withString:@" "] stringByReplacingOccurrencesOfString:@"&" withString:@"and"] stringByReplacingOccurrencesOfString:@"ç" withString:@"c"] stringByReplacingOccurrencesOfString:@"+" withString:@"plus"] stringByReplacingOccurrencesOfString:@"swear" withString:@""] stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
NSString* urlString = [NSString stringWithFormat:@"http://domain.com/qa.php?user=%@&pass=%@&id=%@&body=%@",string1,string2,[p valueForKey:@"a"],string3];
id val1 = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlString]];