Tuesday, June 30, 2009

iPhone NSUserDefaults and UISegmentedControl

Alright, iPhone forums mostly suck - very technically unfriendly - it actually reflects poorly on Apply - no cool factor here.

Anyhow, here's the prob:

NSUserDefaults is what you use to save some app state data to non-vol memory when you exit. I have a switch that toggles the display of an advanced options form. I save the state of this switch successfully. When the app is relaunched, the state is right, I'm able to display this form okay. But, the segmentedcontrol thing is not enabled. I have to cycle the switch twice before it gets enabled.

One line here is not working - the "YES" line :


if( [myDefaults boolForKey:@"advOpts"] ){

advOpts.on = YES;
lineStyleCtrl.enabled = YES;
[self advOptsToggle:nil];

}