Converting NSString to unichar in iOS

lakshmen picture lakshmen · Mar 6, 2013 · Viewed 7.9k times · Source

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?

Answer

rmaddy picture rmaddy · Mar 6, 2013

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];