Browsing index pages (3 articles)
↧
How do I safeguard that addChild(x) isn't added twice?
I keep running into a problem where addChild(myLabel) is triggered twice, resulting in a crash. Is there a way to safeguard that addChild(myLabel) isn't triggered if it has already added the label? I...
View ArticleAnswer by Cerlin for How do I safeguard that addChild(x) isn't added twice?
How about keeping track of that in a boolean, like var isChildAdded = false if !isChildAdded { addChild(myLabel) isChildAdded = true }
View ArticleAnswer by Narek Tserunyan for How do I safeguard that addChild(x) isn't added...
If you mean usage of this function addChild(_ childController: UIViewController) then I would suggest to check by if !controller.children.contains(controller1) { // your actions } Otherwise if it is...
View Article
Browsing index pages (3 articles)