I get the "format not a string..." message when doing the following:
NSString* string1 = [[NSString alloc] initWithFormat:NSLocalizedString(@"Update Now", @"Update Now Item")];
NSString* string2 = [[NSString alloc] initWithFormat:NSLocalizedString(@"Register", @"Register Now")];
It works fine i.e. the app doesn't crash on the device or simulator, and the localized text displays just fine also.
I'm trying to understand why is it then that I'm getting this particular error message. As far as I'm aware this is how you're meant to use localized strings in Objective C.
Simplest way to use localized string is:
NSString* myString = NSLocalizedString(@"Update Now",@"Update Now");
Now keep in mind myString is autoreleased - which you would generally need for a string.
In the examples you give your strings are retained (because you use initWithFormat). Guessing "update now" and such are going to be shown in the user UI, possibly trough a UILabel you don't need a retained string - when you do assign the string to a UILabel it will retain it automatically (as the text is stored in a retained property)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With