gpt4 book ai didi

php - Swift 字符串(格式 :array:) joins strings instead of composing them

转载 作者:行者123 更新时间:2023-11-30 13:48:17 25 4
gpt4 key购买 nike

我的代码中有简单的构造:

output=String(format:message, array: params)

应该格式化在消息的%@中插入数组参数的相应值。然而,它并没有这样做,而是返回由逗号连接的元素,如下所示:

output=("Your subscription to %@ is due to expire in a week; renew it now to miss no transit information!", [In Arrivo HD])

可能是什么问题以及如何在 Swift 中使用数组内容格式化字符串,类似于 php vsprintf?

最佳答案

根据luk2302的建议,解决方案是简单地使用:

 String(format:message, params)

关于php - Swift 字符串(格式 :array:) joins strings instead of composing them,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34636768/

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