Are you trying to convert it to a CGKeyCode? CGKeyCode is just an unsigned short essentially, so NSString's intValue may work (typecasted of course), but it depends what the NSString value is. Can you give an example?
I have a variable of type NSString *sStr = "password". Each letter I enter by means of CGPostKeyboardEvent. The letter "p" and following must to convert in CGKeyCode.