Skip to content

Instantly share code, notes, and snippets.

@supermarin
Created December 5, 2012 22:14
Show Gist options
  • Select an option

  • Save supermarin/4219990 to your computer and use it in GitHub Desktop.

Select an option

Save supermarin/4219990 to your computer and use it in GitHub Desktop.
NSString literals
// Currently, there's too much effort for printing strings with arguments.
// The current way
NSString *sentence = [NSString stringWithFormat:@"This is a text with argument %@", argument];
// Possible literal
NSString *sentence = @("This is a text with argument %@", argument);
@S2Ler
Copy link

S2Ler commented Dec 6, 2012

Have you tried to ask Apple for this new feature? :)

@supermarin
Copy link
Author

@umairsd correct, that's the original proposal :)

@dilejmon, I haven't; wanted to see what others are saying. I don't know either what's the best place to ask this question :)
In the meantime, @neilco has built a macro _(@"text: %@", argument) , but I find it a bit confusing for newcomers.

We ended up with NSStringWithFormat(@"text: %@", argument) , you can find it in ObjectiveSugar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment