Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add text to textview in Swift

How do i add text to a label or tableview, instead of updating the 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 = ""
    }
}
like image 706
Heinevolder Avatar asked Nov 19 '25 03:11

Heinevolder


1 Answers

thePeople.text = thePeople.text+"NewText"

or shorter

thePeople.text += "NewText"
like image 81
iCode Avatar answered Nov 20 '25 15:11

iCode



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!