Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
StateManager Singleton class
class StateManager {
static let sharedInstance = StateManager()
var viewStore: [String: UIView] = [:]
// Associates a view for the given state
public func addView(_ view: UIView, forState state: String, superview: UIView) {
viewStore[state] = view
superview.addSubview(view)
}
// Remove all views
public func removeAllViews() {
for (_, view) in self.viewStore {
view.removeFromSuperview()
viewStore = [:]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment