Reputation: 251
I am developing an app in Xcode using Objective-c and I have a problem with an NSStrign variable and NSLocalizedString (to translate to other idioms).
My problem is that if I use this way, it works great: (All this code is in my ViewDidLoad method)
NSString *decDate = @"11/2016";
_updateLabel.text = [NSString stringWithFormat:@"Updated: %@", decDate];
And the result is:
Updated: 11/2016
But if I try to use NSLocalizedString to translate this String, it doesn't´t works:
NSString *decDate = @"11/2016";
_updateLabel.text = [NSString stringWithFormat:NSLocalizedString (@"Updated: %@", decDate)];
In this case, Xcode said me "Unused variable 'decDate'"
And the result is:
Updated: NSString
Can someone help me? Thank you very much!
Upvotes: 0
Views: 87
Reputation: 4850
NSLocalizedString
takes two arguments, the key and a comment. You're using decDate
as the comment.
Your stringWithFormat
should look like this:
[NSString stringWithFormat:NSLocalizedString(@"Updated: %@", nil), decDate]
Upvotes: 2