2017-11-14 8 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

진짜! 젠장, 어떻게 그걸 놓칠 수 있니? 큰 감사를 드린다! –