Localizable.stringsから返された値を持つキーを持つプッシュ通知をデバイスに送信しました。引数の数は可変ですが、時には1つだけ必要になることもありますが、必要な場合もあります。未知数の引数を持つ文字列をローカライズ
通常、私はこれを使用する文字列をローカライズする:
String.localizedStringWithFormat(NSLocalizedString(notification.localisedKey, comment: "a comment"), notification.localisedArguments)
notification.localisedArguments
が単一の値である場合は、これはのみ動作します。配列の場合、クラッシュします。どのように私はiOSの9と下の等価を行うことができます
NSString.localizedUserNotificationString(forKey: notification.localisedKey, arguments: notification.localisedArguments)
:
iOSの10でこの問題を回避するには、次のコードを使用しているのですか?
関連:https://stackoverflow.com/questions/42457503/how-to-properly-use-varargs-for-localizing-strings。 –
@MartinRそのコードはそれを解決しました!ありがとう! – Tometoyou