在Swift中向textview添加文本

时间:2014-11-17 08:15:01

标签: ios arrays for-loop swift

如何在标签或tableview中添加文本,而不是更新label / tableview?

var personArray: [Person] = [
Person(name: "Heine", sex: "Guy"),
Person(name: "Magnus", sex: "Girl"),
Person(name: "Sarah", sex: "Girl")
]

@IBOutlet weak var thePeople: UILabel!

func updatePeople()
{
    for peop in personArray{
        thePeople.text = ""
    }
}

1 个答案:

答案 0 :(得分:3)

thePeople.text = thePeople.text+"NewText"

或更短

thePeople.text += "NewText"