FS.O
FS.O

Reputation: 401

UILabel's text property without overriding it

I have a modal class named Weather, this class has a NSString property called degrees that contains the current weather (in °C degrees).

I have my main viewController caled MainVC that has a UILabel that presents the current weather, the label is changing dynamiclly according to the Weather object's degrees property, I want that when the label's text changes, it'll automatically add "°C" to the text on the label.

How can I do that without overriding the label's setText: method?

Upvotes: 0

Views: 105

Answers (1)

Bamsworld
Bamsworld

Reputation: 5680

Where the label is currently being set you could do something like -

label.text = [NSString stringWithFormat:@"%@°C", degreesFromWeatherObject];

Upvotes: 1

Related Questions