Skip to content

Instantly share code, notes, and snippets.

@Sakurina
Created June 18, 2011 15:56
Show Gist options
  • Save Sakurina/1033214 to your computer and use it in GitHub Desktop.
Save Sakurina/1033214 to your computer and use it in GitHub Desktop.
an example for @r_plus
-(void) setMasterToggle:(id)value specifier:(id)specifier {
// You'd set the "set" property for your switch in your plist to
// "setMasterToggle:specifier:" so this gets called
[self setPreferenceValue:value specifier:specifier];
BOOL boolValue = [value boolValue];
// "SlaveToggle" is the ID of the toggle that depends on this switch
PSSpecifier* slaveSpecifier = [self specifierForID:@"SlaveToggle"];
if (!boolValue)
[self setPreferenceValue:[NSNumber numberWithBool:NO] specifier:slaveSpecifier];
[slaveSpecifier setProperty:[NSNumber numberWithBool:boolValue] forKey:@"enabled"];
// Of course, you might want to split that behavior out into another method
// you could call during your initializer otherwise it will remain enabled
// when you first launch the prefs bundle.
[[NSUserDefaults standardUserDefaults] synchronize];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment