Changing Text in an Existing Label
suggest changeChanging the text of an existing UILabel can be done by accessing and modifying the text property of the UILabel. This can be done directly using String literals or indirectly using variables.
Setting the text with String literals
Swift
label.text = "the new text"
Objective-C
// Dot Notation
label.text = @"the new text";
// Message Pattern
[label setText:@"the new text"];
Setting the text with a variable
Swift
let stringVar = "basic String var"
label.text = stringVar
Objective-C
NSString * stringVar = @"basic String var";
// Dot Notation
label.text = stringVar;
// Message Pattern
[label setText: stringVar];
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents