If one uses interface builder to drag a Switch to a xib-file, the state can be set to on/off in IB. Is there a way to save the state of the switch until next time the app starts so that the switch is in the same state previous to being closed?
Share
you may save it using NSUserDefaults.
first connect your switch as an IBOutlet
Also connect your switch as an IBAction, event type “Value Changed”
then in your UIViewController’s
viewDidLoadand in the new
switched:actionhope this helps.