Skip to content

Instantly share code, notes, and snippets.

@OneSadCookie
Created February 5, 2014 22:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save OneSadCookie/8834981 to your computer and use it in GitHub Desktop.
Save OneSadCookie/8834981 to your computer and use it in GitHub Desktop.
NSUInteger lengthA = [a length];
NSUInteger lengthB = [b length];
NSUInteger keyLength = lengthA + lengthB + 1;
assert(keyLength * sizeof(unichar) < SOME_REASONABLE_MAXIMUM_FOR_STACK_ALLOCATION);
unichar cat[keyLength];
[a getCharacters:cat range:NSMakeRange(0, lengthA)];
cat[lengthA] = '.';
[b getCharacters:cat + lengthA + 1 range:NSMakeRange(0, lengthB)];
NSString *key = [[NSString alloc] initWithCharactersNoCopy:cat length:keyLength freeWhenDone:NO];
... [dict objectForKey:key];
[key release];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment