Skip to content

Instantly share code, notes, and snippets.

@jenshandersson
Created January 5, 2014 20:24
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jenshandersson/8273360 to your computer and use it in GitHub Desktop.
Save jenshandersson/8273360 to your computer and use it in GitHub Desktop.
String concatenation in Objective-C, using one line of code. Takes a list of NSObject and concatenates their description.
#define $(...) ((NSString *)[[NSArray arrayWithObjects:__VA_ARGS__, nil] componentsJoinedByString:@""])
/*
* Example
*/
NSString *string = $(@"Hello", @" ", @"World!", @"\n", @"1 + 2 = ", @(1+2));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment