Skip to content

Instantly share code, notes, and snippets.

@bjhomer
Last active December 15, 2015 19:49
Show Gist options
  • Save bjhomer/5314527 to your computer and use it in GitHub Desktop.
Save bjhomer/5314527 to your computer and use it in GitHub Desktop.
-Wformat-nonliteral is picky
NSString *template = NSLocalizedString(@"My name is %@", @"A label for displaying the user's name");
NSString *str = [NSString stringWithFormat:template, @"John"];
// warning: format string is not a string literal [-Wformat-nonliteral]
label.text = str;
NSString *str = [NSString stringWithFormat:NSLocalizedString(@"My name is %@", @"A label for displaying the user's name"), @"John"];
// No warning.
label.text = str;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment