Reputation: 51
I want to add words to an existing label without replacing them. For example if a label contains "hello" and I want to add "some other word(s)" but do so with out replacing "hello". So that the final text displayed will read "hello some other word(s)". Thanks to any one that helps!
Upvotes: 4
Views: 8159
Reputation: 59496
It's easy. Given a label populated with "Hello" like this
let label = UILabel()
label.text = "Hello"
you can append more text using this code
label.text = (label.text ?? "") + " some other word(s)"
Upvotes: 7