Skip to content

Commit 3297ec8

Browse files
committed
Workaround to trigger didSet inside the initializer
1 parent 8db33fd commit 3297ec8

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

Source/TokenField/ICToken.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,10 @@ class ICToken: UIView {
9494
self.init()
9595
if let attributes = normalAttributes { normalTextAttributes = attributes }
9696
if let attributes = highlightedAttributes { highlightedTextAttributes = attributes }
97-
// didSet is not called within the initializer
98-
setText(text)
99-
}
100-
101-
private func setText(_ text: String) {
102-
self.text = text
97+
({
98+
// Workaround to trigger didSet inside the initializer
99+
self.text = text
100+
})()
103101
}
104102

105103
// MARK: - Private Methods

0 commit comments

Comments
 (0)