Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

pinyourwings22

macrumors member
Original poster
Aug 20, 2008
30
0
Ohio
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!
 
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];
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.