Question

For some reason I'm not getting the value from my plist and I'm not sure why here is the plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CachedColors</key>
    <dict>
        <key>com.Halfbrick.Fruit</key>
        <string>0.00000,0.00000,0.00000</string>
        <key>com.amazon.Amazon</key>
        <string>0.00000,0.00000,0.00000</string>
        <key>com.apple.AdSheetPhone</key>
        <string>0.00000,0.00000,0.00000</string>
        <key>com.apple.AppStore</key>
        <string>0.28824,0.37059,0.48235</string>
    <key>default</key>
    <true/>
    <key>gradient</key>
    <false/>
    <key>opaque</key>
    <true/>
    <key>showedMessage</key>
    <true/>
    <key>translucent</key>
    <true/>
</dict>
</plist>

and my method is:

SBApplication *frontApp = [(SpringBoard*)[UIApplication sharedApplication] _accessibilityFrontMostApplication];
NSString *frontAppBundleID = [frontApp displayIdentifier];
NSDictionary *statusBarCachedColors = [NSDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/cc.tweak.statuscolor.plist"];
NSString *colorString = (NSString*)[statusBarCachedColors objectForKey:frontAppBundleID];
NSArray *components = [colorString componentsSeparatedByString:@","];
UIColor *tintColor = [UIColor colorWithRed:[[components objectAtIndex:0] floatValue] green:[[components objectAtIndex:1] floatValue] blue:[[components objectAtIndex:2] floatValue] alpha:1];

whats supposed to happen is, my method would get the Display ID for the current application, then get the value for the app from the plist, then split the value string and make a UIColor from the array. so if I opened the AppStore, it would search the plist and return "0.28824,0.37059,0.48235" and make that into the color, but it doesn't seem to return anything, I've tested the displayIdentifier and that is correct it does display the correct app display id, i just don't know why it isn't getting a value

Was it helpful?

Solution

You miss the item CachedColors.

NSString *colorString = (NSString*)[[statusBarCachedColors objectForKey:@"CachedColors"] objectForKey:frontAppBundleID];

OTHER TIPS

NSString *path = [[NSBundle mainBundle] pathForResource:
                      @"<plist file name>" ofType:@"plist"];

NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:path];

Try this hope it will work.

use this bellow code may be it work..

Get value from plist like bellow...

NSString *path = [[NSBundle mainBundle] pathForResource:@"PlistFileName" ofType:@"plist"];
NSMutableArray  *arrPList = [NSMutableArray arrayWithContentsOfFile:path];

after use your code and try with bellow logic..

float clrRed = [[components objectAtIndex:0] floatValue];
float clrGreen = [[components objectAtIndex:1] floatValue];
float clrBlue = [[components objectAtIndex:2] floatValue];

UIColor *tintColor = [UIColor colorWithRed:clrRed green:clrGreen blue:clrBlue floatValue] alpha:1];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top