How can I enumerate NSString by pulling each unichar out of it? I can use characterAtIndex but that is slower than doing it by an incrementing unichar*. I didn’t see anything in Apple’s documentation that didn’t require copying the string into a second buffer.
Something like this would be ideal:
for (unichar c in string) { ... }
or
unichar* ptr = (unichar*)string;
You can speed up
-characterAtIndex:by converting it to it’s IMP form first:EDIT: It appears that the
CFStringReference contains the following method:This means you can do the following:
If you don’t want to allocate memory for coping the buffer, this is the way to go.