2017-11-14 11 views
0

ローカライズされた変数を使用して通知を作成しようとしました。シミュレータでは、すべてエラーなしで動作します。たとえ通知が必要な場合でも表示されますが、iPhoneでテストするとアプリがクラッシュします。NSLocalizedString - スレッド1:String.localizedStringWithFormatを使用したEXEC_BAD_ACCESS

func getContent(fromName: String, andDue: String, andAmount: Double) -> UNMutableNotificationContent { 
     let currency = self.appDelegate.settings.getShortCurrency() // standard währung aus dem System holen 
     let content = UNMutableNotificationContent() 


     content.subtitle = NSLocalizedString("REMINDERTITLE", comment: "Reminder: some payments are overdue...") 


    // Error in this line: 
    content.body = String.localizedStringWithFormat(NSLocalizedString("REMINDERTEXT", comment: "Hey, %@'s payment from %@ %@ is overdue since %@! Do you want to send him a reminder message?"), fromName, andAmount, currency, andDue) 

     content.badge = 1 
     content.sound = UNNotificationSound(named: "droppingCoin.wav") 

     return content 
    } 

エラーがある:

スレッド1:EXC_BAD_ACCESS(コード= 1、アドレス= 0x4084900000000000)この行の

content.body = String.localizedStringWithFormat(NSLocalizedString("REMINDERTEXT", comment: "Hey, %@'s payment from %@ %@ is overdue since %@! Do you want to send him a reminder message?"), fromName, andAmount, currency, andDue) 

コメントテキストは.stringsファイルで定義されている実際のローカライズされたテキスト値です。

ありがとうございます!

答えて

2

andAmountに間違った書式指定子を使用しています。 andAmountはdoubleでオブジェクトではないので、%@の代わりに%fを使用してください。

+0

本物!いや、どうして私はそれを逃しただろうか?本当にありがとう! –

関連する問題