In some of my screens in my program the localized strings work and in some it doesn’t.
(Xcode 4.2)
What I’ve done:
-
Added a Localizable.strings in the folder “Resources”
-
in my .h file, inside the @interface ClassViewController : UIViewController {} I added:
IBOutlet UILable *labelName; -
Also in the .h file, I added
property (nonatomic, assign) IBOutlet UILabel *labelName; -
In the .m file, I added :
@synthetize labelName; -
Still in the .m file, I added inside “-(foid)dealloc” :
[labelName release]; -
In -(void)viewDidLoad I added :
self.labelName.text = [NSString stringWithFormat:@"KEY"]; -
Finally, in the xib file (with the Interface manager), I linked the label object with the variable.
So, as I said, this method works in some screen and not in others. Any idea?
Solution:
That what a stupid mistake. the line to enter the text should be:
NSLocalizedString(@"KEY", nil);
Use instead:
From the Documentation: