Skip to content

Commit 326c97a

Browse files
nguyenhuymaicki
authored andcommitted
When update title of a button node, need to get title node via setter (facebookarchive#3167)
* When update title of a button node, need to get title node via setter * Explain why we need to call self.titleNode * Fix previous comment
1 parent 74b9b56 commit 326c97a

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

Source/ASButtonNode.mm

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,12 @@ - (void)updateTitle
197197
newTitle = _normalAttributedTitle;
198198
}
199199

200-
ASTextNode *titleNode = _titleNode;
201-
202-
if ((titleNode != nil || newTitle.length > 0) && [titleNode.attributedText isEqualToAttributedString:newTitle] == NO) {
203-
titleNode.attributedText = newTitle;
200+
// Calling self.titleNode is essential here because _titleNode is lazily created by the getter.
201+
if ((_titleNode != nil || newTitle.length > 0) && [self.titleNode.attributedText isEqualToAttributedString:newTitle] == NO) {
202+
_titleNode.attributedText = newTitle;
204203
__instanceLock__.unlock();
205204

206-
self.accessibilityLabel = titleNode.accessibilityLabel;
205+
self.accessibilityLabel = _titleNode.accessibilityLabel;
207206
[self setNeedsLayout];
208207
return;
209208
}

0 commit comments

Comments
 (0)