iOS developer iOS developer - 1 month ago 16
iOS Question

How to get ASCII value of a string?

How can I get the ascii value of the string which I enter in the text field? I also want to check if the alphabet which I type is lower case, upper case, comma or space. The function should return YES or NO.

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{

// if (string.) {
// <#statements#>
// }

[self performSelector:@selector(delayCall) withObject:nil afterDelay:0.1];


return YES;

}

Answer

This is going to help you.

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{


    char cStr = [string characterAtIndex:0];

    NSLog(@"%d",(int)cStr);


    return YES;

}