Setting it up programmatically or in IB doesn't matter for this.
UISwitch is a very simple control. It has a single property, on. You set it to YES or NO, and of course the user can change it by tapping the control.
You need to have a separate data model object that holds the current value of the choice. Update it via the action method of the switch whenever it's pressed. You need to set this property based on the value in the data model when the switch is going to appear. This is in the viewDidLoad method of the viewController and perhaps also in the viewWillAppear method of the viewController. This design is called MVC.
My guess is that you're not saving the value and restoring it in viewDidLoad or viewWillAppear.