gpt4 book ai didi

ios - NSLocalizedString - 线程 1 : EXEC_BAD_ACCESS with String. localizedStringWithFormat

转载 作者:行者123 更新时间:2023-11-28 12:14:24 25 4
gpt4 key购买 nike

我试图用一些局部变量发出通知。在模拟器中,一切正常,没有错误——甚至通知也能正常显示,但如果我在 iPhone 上测试它,应用程序就会崩溃。

    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
}

错误是:

Thread 1: EXC_BAD_ACCESS (code=1, address=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 文件中定义的实际本地化文本值。

提前致谢!

最佳答案

您对 andAmount 使用了错误的格式说明符。 andAmount 是一个 double 而不是一个对象,所以使用 %f 而不是 %@。

关于ios - NSLocalizedString - 线程 1 : EXEC_BAD_ACCESS with String. localizedStringWithFormat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47284358/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com