In app setting(turn on/off narrator)

Discussion in 'iOS Programming' started by pinyourwings22, Mar 8, 2011.

  1. pinyourwings22 macrumors member

    Joined:
    Aug 20, 2008
    Location:
    Ohio
    #1
    Hi,

    I am creating a storybook app, and I want to put an option on the front page(using a on/off switch) which will tell every other view that the narrator should be turned off. As a programmer, my first instinct is to use a global variable of some kind, but I can't seem to set this "preference" globally, and I got the vibe that using global variables was frowned upon anyways. Also, I don't want to create a Settings bundle because this may be the only preference I implement, and it's not something that I feel needs to be placed in the Settings app.

    So my main problem is accessing that switch's value when I am in another view. Any help would be much appreciated. Thanks!
     
  2. pinyourwings22 thread starter macrumors member

    Joined:
    Aug 20, 2008
    Location:
    Ohio
    #2
    Nevermind, I figured it out. I used NSUserDefaults :)

    Code:
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    	[defaults setBool:narratorSetting.on forKey:@"narratorSetting"];
    Code:
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    	if ([defaults boolForKey:@"narratorSetting"]) [self performSelector:@selector(narrator) withObject:nil afterDelay:1];
     

Share This Page