I have a parent UIView with a number of subviews. Periodically I need to remove a subview and completely remove it from the system. What is the correct way to do this? I tried t
Swift 4: extend UIView
extension UIView { public func removeAllSubviews() { for subview in self.subviews { subview.removeFromSuperview() } } }
or
extension UIView { public func removeAllSubviews() { self.subviews.forEach { $0.removeFromSuperview() } } }