Reputation: 5041
I'm trying to localize my app, but the app crashes when it encounters my localized strings, that use localizedStringWithFormat
. Here's an example:
cell.productRangeLabel.text = String.localizedStringWithFormat(NSLocalizedString("Questions %s", comment: "Subtitle showing the number of questions on each pack"), product.info!.range)
In the debugger (LLDB), product.info!.range
prints the correct string, and if I print the NSLocalizedString only, it outputs the correct translation ("Preguntas %s), but in combination with localizedStringWithFormat it gives me an error:
Execution was interrupted, reason: EXC_BAD_ACCESS (code=EXC_I386_GPFLT). The process has been returned to the state before expression evaluation.
Before localizing, that string worked fine ("Questions \(product.info!.range)"
).
I don't know if this matters, but importing the xliff file was a nightmare. Xcode kept crashing, and I'm sure there are missing strings, but it eventually did create the Localizable.strings file.
Update: I was using the iPhone 6s (9.3) simulator when it crashed. Now I tried with the iPhone 4s (9.3), and it doesn't crash, but all strings that are variables are garbled, like: "Preguntas ☨^^" instead of "Preguntas 1-50"
Upvotes: 3
Views: 998