开发者

Equivalent of charCodeAt in Objective C

开发者 https://www.devze.com 2023-02-19 17:56 出处:网络
Good Morning All, I have an Objective C question that is coming from JavaScript.I have a piece of code that is being run in JavaScript (code that I was handed) and it is running a critical conversion

Good Morning All,

I have an Objective C question that is coming from JavaScript. I have a piece of code that is being run in JavaScript (code that I was handed) and it is running a critical conversion method that uses the .charCodeAt(SOME_CHARACTER) JavaScript method to return th开发者_StackOverflow中文版e Unicode code associated with that specific character.

What I need to do is find the objective c method that does the same thing. I have tried searching through the NSString and Unichar classes but didn't have any luck and I didn't find anything on here when I searched so I'm hoping someone could help me out.

Thanks!


Well, simply use the characterAtIndex: method of NSString:

- (unichar)characterAtIndex:(NSUInteger)index

If I remember correctly, unichar is a typedef to two bytes (kind of short).

0

精彩评论

暂无评论...
验证码 换一张
取 消