Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ichitaso/503dd22f5a4774874a52 to your computer and use it in GitHub Desktop.
Save ichitaso/503dd22f5a4774874a52 to your computer and use it in GitHub Desktop.
static BOOL tweakEnBOOL;
#define SETTINGSFILENEW "com.imokhles.Prefs"
#define PREFERENCES_CHANGED_NOTIFICATION "com.imokhles.Prefs.preferences-changed"
// non ARC
static void iMoLoadPreferences() {
CFPreferencesAppSynchronize(CFSTR(SETTINGSFILENEW));
tweakEnBOOL = !CFPreferencesCopyAppValue(CFSTR("Enabled"), CFSTR(SETTINGSFILENEW)) ? YES : [(id)CFBridgingRelease(CFPreferencesCopyAppValue(CFSTR("Enabled"), CFSTR(SETTINGSFILENEW))) boolValue];
}
// with ARC
static void iMoLoadPreferences() {
CFPreferencesAppSynchronize(CFSTR(SETTINGSFILENEW));
tweakEnBOOL = !CFPreferencesCopyAppValue(CFSTR("Enabled"), CFSTR(SETTINGSFILENEW)) ? YES : [(id)CFPreferencesCopyAppValue(CFSTR("Enabled"), CFSTR(SETTINGSFILENEW)) boolValue];
}
%ctor {
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(),
NULL,
(CFNotificationCallback)iMoLoadPreferences,
CFSTR(PREFERENCES_CHANGED_NOTIFICATION),
NULL,
CFNotificationSuspensionBehaviorCoalesce);
iMoLoadPreferences();
}
// and to check value within tweak.
// Example
%hook SBLockScreenViewController
- (void)finishUIUnlockFromSource:(int)arg1 {
%orig();
if (tweakEnBOOL) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Unlock" message:@"your device unlock finished ;)" delegate:nil cancelButtonTitle:@"OK :)" otherButtonTitles:nil, nil];
[alertView show];
}
}
%end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment