Skip to content

Conversation

@Mammadbayli
Copy link

@Mammadbayli Mammadbayli commented Dec 28, 2018

When dynamically creating controls and registering them, they are not deallocated when they are unregistered, I figured the cause could probably be the fields dictionary keeping a reference to them.
Here is my snippet of code:

 merchant.visibleParams?.map { $0.associatedControl }.forEach { control in
            control.onChange = { _ in self.validate() }
            self.validator.registerField(control, rules: [RequiredRule()]) //here I register
            section.elements.append(control)
   }

When I update the UI and unregister those controls, they are not deallocated:

   node.subnodes?.filter { $0.debugName == "dynamic" }.forEach {  control in
        self.validator.unregisterField(control as! ValidatableField)
    }

@RajatJain4061
Copy link
Member

@Mammadbayli Your PR is failing 1 check. Can you merge master branch once then push again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants