我正在尝试将字典的内容显示到 UITextView
或 UILabel
中。我可以使用 println()
成功完成此操作,但是当尝试将值添加到 .text 属性时,它只会添加第一行。
for (x, y) in dict
{
println("\(x): \(y)")
display.text = "("\(x): \(y)") // prints only first item
display.text = "\(dict)" // prints [item1: 1, item2: 2....] I need it on separate lines and no [].
}
最佳答案
我不太确定你在问什么。您是否在字符串的多行上要求“(x:y)”?使用换行转义符:
var fullDict = ""
for (x, y) in dict {
fullDict += "(\(x): \(y))\n"
}
display.text = fullDict
关于ios - 如何将字典的内容转储到 UITextView 或 UILabel 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31685399/