I am trying to read the BOOL Value from a PSSwitchCell but the BOOL is just coming up true all the time. This is my code (logo tweak (iOSopendev))
This is the .xm file, im using the iosopendev logos tweak template and the simple preference loader.
Also, i know this is just a simple tweak, but i am learning how this all works. I have looked at tutorials online, but i can't seem to see why this is not working.
#import <UIKit/UIKit.h>
#define plist_path @"/Library/PreferenceLoader/Preferences/MyTweak.plist"
#define listenToNotification$withCallBack(notification, callback);CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)&callback, CFSTR(notification), NULL, CFNotificationSuspensionBehaviorHold);
%hook SBApplicationIcon
+ (id)sharedInstance
{
%log;
return %orig;
}
static NSMutableDictionary *plistDict = nil;
static void loadSettings(void) {
if (plistDict) {
[plistDict release];
plistDict = nil;
}
plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:plist_path];
}
-(void)launch
{
NSString *number = [[[plistDict objectForKey:@"enabled"] intValue];
if ([number isEqualto:@"1"]) {
NSString *appName = [self displayName];
NSString *message = [NSString stringWithFormat:@"The app %@ has been launched", appName, nil];
UIAlertView *alert1 = [[UIAlertView alloc] initWithTitle:appName message:message delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
alert1.delegate = self;
[alert1 show];
[alert1 release]; }
else {
//Do nothing!
}
%orig;
}
- (void)messageWithNoReturnAndOneArgument:(id)originalArgument
{
%log;
%orig(originalArgument);
// or, for exmaple, you could use a custom value instead of the original argument: %orig(customValue);
}
- (id)messageWithReturnAndNoArguments
{
%log;
id originalReturnOfMessage = %orig;
// for example, you could modify the original return value before returning it: [SomeOtherClass doSomethingToThisObject:originalReturnOfMessage];
return originalReturnOfMessage;
}
%end
%ctor {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
%init;
listenToNotification$withCallBack("dylankelly.MyDev.MyTweak-preferencesChanged", loadSettings);
loadSettings();
[pool drain];
}
This is my plist (part of it) file, which shows up in settings.
<dict>
<key>cell</key>
<string>PSSwitchCell</string>
<key>default</key>
<integer>0</integer>
<key>defaults</key>
<string>dylankelly.MyDev.MyTweak</string>
<key>TrueValue</key>
<integer>1</integer>
<key>FalseValue</key>
<integer>0</integer>
<key>key</key>
<string>enabled</string>
<key>label</key>
<string>Show</string>
<key>PostNotification</key>
<string>dylankelly.MyDev.MyTweak-preferencesChanged</string>
</dict>