UILabel attributed text is never nil

We need to check if UILabel has attributed text or not, but UILabel.attributedText always returns some default attributes for all labels even though we are setting plain text on labels, while as per the documentation this value is supposed to be nil by default.


Please help if anybody has faced the similar situation. Thanks in advance.

I tested on XCode 10.2.

Effectively, it is not nil but it is empty.


Here is the content.

label.attributedText Optional(Label{

NSColor = "UIExtendedSRGBColorSpace 0 0 0 1";

NSFont = "<UICTFont: 0x7fa3efc0d3a0> font-family: \".SFUIText\"; font-weight: normal; font-style: normal; font-size: 17.00pt";

NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 4, Tabs (\n 28L,\n 56L,\n 84L,\n 112L,\n 140L,\n 168L,\n 196L,\n 224L,\n 252L,\n 280L,\n 308L,\n 336L\n), DefaultTabInterval 0, Blocks (\n), Lists (\n), BaseWritingDirection -1, HyphenationFactor 0, TighteningForTruncation NO, HeaderLevel 0";

NSShadow = "NSShadow {0, -1} color = {(null)}";

})


If some attributed text was defined, I get

label.attributedText Optional(someText{

})


Probably, you should file a bug report against documentation

Thanks,


I am also getting same attributes while I am not setting any attributedText on label, will try to report a bug.

UILabel attributed text is never nil
 
 
Q