Arash
Arash

Reputation: 23

Equivalent of charCodeAt in Objective C

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 the 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!

Upvotes: 2

Views: 1197

Answers (1)

Macmade
Macmade

Reputation: 54059

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).

Upvotes: 2

Related Questions