swift - 我想在字符串类型变量中添加多个变量,并且每个值都将从 swift 4 的下一行开始
问题描述
我有一个变量 var 结果:String = ""
现在我在不同的变量中得到不同的字符串,我想将这些值分配给我的结果变量,每个值都将在新行中。即这是我的代码
结果 = 结果 + (方法 ?? "") 结果 = 结果 + "\n"
result = result + (content ?? "" )
result = result + "\n"
result = result + (acceptHeader ?? "")
result = result + "\n"
result = result + (url ?? "")
result = result + "\n"
result = result + (timeStamp ?? "")
result = result + "\n"
result = result + (publicKey ?? "")
我正在打印这个结果 它正在打印我这个
get
application/json
https://www.google.com
2020-04-07T11:08:34.989Z
但是当我将此值分配给某个变量时,它会给出这个 get\n\napplication/json\nhttps://www.google.com\n2020-04-07T11:08:34.989Z\n
我希望我的值将被分配给变量,就像它被打印出来一样。即像这样
get
application/json
https://www.google.com
2020-04-07T11:08:34.989Z
解决方案
推荐阅读
- python - Segmented scroll down page to check for existence of element - Python selenium, driver.execute_script
- ios - 将 CircularProgressRing 的值更新为 7 天图表中选择的值
- angular - 角度 9 中的 echart 代码错误,但可以在角度 7 中工作
- javascript - 将 JS 函数附加到 pug 以创建动态 url
- prediction - 无人驾驶 AI H2O 中的时间序列
- html - 浮动元素对齐不一致
- javascript - 如何将ngrx效果调用组合到单个流中?
- sql - 为什么我的 Access Max() 子查询不起作用?
- rabbitmq - 如何在 python 中使用 RabbitMQ 进行简单的单元测试?
- mongodb - 如果一个结果匹配,$limit 会停止获取吗?