Search code examples
iosobjective-cnsstringunichar

Converting NSString to unichar in iOS


I have seen questions in stackoverflow that convert unichar to NSString but now I would like to do the reverse.

How do i do it?

Need some guidance.. Thanks

For example, I have an array of strings:[@"o",@"p",@"q"];

These are strings inside. How do i convert it back to unichar?


Solution

  • The following will work as long as the first character isn't actually two composed characters (in other words as long as the character doesn't have a Unicode value greater than \UFFFF):

    unichar ch = [someString characterAtIndex:0];