NSLocalizedString does not show compiler error when number of arguments incorrect
| Originator: | shefali50 | ||
| Number: | rdar://23622446 | Date Originated: | 20-nov-2015 |
| Status: | Open | Resolved: | |
| Product: | iOS SDK | Product Version: | All |
| Classification: | iOS SDK | Reproducible: | Yes |
Apple bug reporter number : 23622446
Summary:
in Xcode Version 7.0.1 (7A1001) am seeing that in NSString localization, the compiler does not give a warning if incorrect number of arguments are provided. This will lead to bugs. Is there a way around this?
[NSString localizedStringWithFormat: NSLocalizedString(@"%@ %@", @"two strings"), @"name"]; //This gives no compiler warning
[NSString stringWithFormat:@"%@ %@", @"name"]; //this gives a warning saying 'More '%' conversions than data arguments'. This is desirable
[NSString stringWithFormat:NSLocalizedString(@"%@ %@", @"two strings"), @"name"]; //This gives no compiler warning
Pls refer to https://forums.developer.apple.com/thread/26396
for replies on this
Steps to Reproduce:
1. create a new single app project
2. in the view controller, paste the three lines of code as in description
3. run the project
Expected Results:
the compiler should warn about data arguments not being the same in number as the formats in case of localized strings also
Actual Results:
the app will exception on those lines
Version:
iPhone simulator
Notes:
Configuration:
Xcode Version 7.0.1 (7A1001), any iPhone simulator
Attachments:
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!