Skip to content

Instantly share code, notes, and snippets.

@kharmabum
Created March 9, 2014 22:32
Show Gist options
  • Save kharmabum/9455944 to your computer and use it in GitHub Desktop.
Save kharmabum/9455944 to your computer and use it in GitHub Desktop.
Looping through NSString Unicode characters - http://www.objc.io/issue-9/unicode.html
NSString *s = @"The weather on \U0001F30D is \U0001F31E today.";
// The weather on ๐ŸŒ is ๐ŸŒž today.
NSRange fullRange = NSMakeRange(0, [s length]);
[s enumerateSubstringsInRange:fullRange
options:NSStringEnumerationByComposedCharacterSequences
usingBlock:^(NSString *substring, NSRange substringRange,
NSRange enclosingRange, BOOL *stop)
{
NSLog(@"%@ %@", substring, NSStringFromRange(substringRange));
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment