Skip to content

Instantly share code, notes, and snippets.

@r-plus
Created June 18, 2011 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save r-plus/1033240 to your computer and use it in GitHub Desktop.
Save r-plus/1033240 to your computer and use it in GitHub Desktop.
answer
<dict>
<key>cell</key>
<string>PSSwitchCell</string>
<key>default</key>
<false/>
<key>defaults</key>
<string>jp.r-plus.amdaijirin</string>
<key>key</key>
<string>ALCEnabled</string>
<key>label</key>
<string>ALC[origin word]</string>
<key>icon</key>
<key>Safari.png</key>
<key>set</key>
<string>setMasterToggle:specifier:</string>
</dict>
<dict>
<key>cell</key>
<string>PSSwitchCell</string>
<key>default</key>
<false/>
<key>defaults</key>
<string>jp.r-plus.amdaijirin</string>
<key>key</key>
<string>ALCMobilizerEnabled</string>
<key>label</key>
<string>Mobilizer(ALC only)</string>
<key>enabled</key>
<false/>
<key>id</key>
<string>ALCMobilizerID</string>
</dict>
@implementation DaijirinListController
- (void)setMasterToggle:(id)value specifier:(id)specifier {
NSlog(@"SETTING_START");
// 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:@"ALCMobilizerID"];
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];
}
- (id)specifiers {
if(_specifiers == nil) {
_specifiers = [[self loadSpecifiersFromPlistName:@"Daijirin" target:self] retain];
}
return _specifiers;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment