Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens if I set both UILabel.text and UILabel.attributedText?

I have an attributed string which I am making out of HTML using DTCoreText, and I want to set it as the value of my UILabel. However, I want to check at a later point if the value of the string has changed, in comparison to the UILabel. Is it possible to set both the UILabel's text and attributedText properties? Will the attributedText simply overshadow the text property, so the text property can be kept as an internal value?

like image 750
Jason Avatar asked Nov 12 '22 11:11

Jason


1 Answers

According to the documentation, assigning to text replaces attributedText with the same contents (albeit as an unstyled attributed string), and assigning to attributedText replaces text with the same contents (without any formatting information).

If you want to attach arbitrary information to an obj-c object, you should use associated objects.

like image 83
Lily Ballard Avatar answered Nov 15 '22 06:11

Lily Ballard