Como posso restringir caracteres especiais no UITextField, exceto ponto e sublinhados?

Como posso restringir caracteres especiais em umUITextField exceto ponto e sublinhados?

Eu tentei o trecho de código abaixo, mas sem sorte:

#define ACCEPTABLE_CHARECTERS @" ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_."

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
         NSCharacterSet *acceptedInput = [NSCharacterSet characterSetWithCharactersInString:ACCEPTABLE_CHARECTERS];
        if (![[string componentsSeparatedByCharactersInSet:acceptedInput] count] > 1){
            NSLog(@"not allowed");
            return NO;
        }
        else{
            return YES;
        }
}

questionAnswers(10)

yourAnswerToTheQuestion