I have a custom UIView
I created in which I have a UIButton
. Inside that view, I have this code:
func setupViews() {
menuControlButton.addTarget(self, action: "toggleButton:", forControlEvents: .TouchUpInside)
}
func toggleButton(sender: MenuControlButton!) {
let isActive = sender.toggleActive() // switches button image and returns whether active or not after
NSUserDefaults.standardUserDefaults().setBool(isActive, forKey: sender.title)
someOtherViewController.reloadCalendar()
}
Is this a bad practice to do though? Especially since I'm calling another controller's function through a custom UIView
.
Should I instead make it so these methods are in the ViewController? Or is there a better way to do this?