Changing 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.
String
literalsSwift
label.text = "the new text"
Objective-C
// Dot Notation
label.text = @"the new text";
// Message Pattern
[label setText:@"the new text"];
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];