Jump to content

who and when will create preference bundle file in /var/mobile/Library/Preferences/tweakid.plist


CookieFJ

4 posts in this topic

Recommended Posts

Posted

Thanks for the preference template.

Just noted that the initialization not correct as I expected.

value not same as in Root.plist. looks like random value.

in %ctor, tried to fetch the value from /var/mobile/Library/Preferences/tweakid.plist, but failed since I can't find the plist file in Filza.

After do some setting in tweak setting, the plist file was created. Then the values are synced up with setting.

Question: who and when will create preference bundle file?

Thanks.

Posted
static void loadPrefs() {
	NSMutableDictionary *settings = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/var/mobile/Library/Preferences/com.youcompany.tweakprefs.plist"];

	isEnabled		= ( [settings objectForKey:@"isEnabled"] ? [[settings objectForKey:@"isEnabled"] boolValue] : isEnabled );
	isRecent		= ( [settings objectForKey:@"isRecent"] ? [[settings objectForKey:@"isRecent"] boolValue] : isRecent );
	nRecent 		= ( [settings objectForKey:@"nRecent"] ? [[settings objectForKey:@"nRecent"] intValue] : nRecent );
}

%ctor {
    loadPrefs();
    CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)loadPrefs, CFSTR("com.youcompany.tweakprefs.prefschanged"), NULL, CFNotificationSuspensionBehaviorCoalesce);
}


<?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>items</key>
	<array>
		<dict>
			<key>cell</key>
			<string>PSGroupCell</string>
			<key>footerText</key>
			<string>turn on to make this tweak function</string>
		</dict>
		<dict>
			<key>cell</key>
			<string>PSSwitchCell</string>
			<key>default</key>
			<false/>
			<key>defaults</key>
			<string>com.yourcompany.tweakprefs</string>
			<key>key</key>
			<string>isEnabled</string>
			<key>label</key>
			<string>Enable</string>
		</dict>
		<dict>
			<key>cell</key>
			<string>PSGroupCell</string>
			<key>footerText</key>
			<string>Options</string>
		<dict>
			<key>cell</key>
			<string>PSSwitchCell</string>
			<key>default</key>
			<true/>
			<key>defaults</key>
			<string>com.youcompany.tweakprefs</string>
			<key>PostNotification</key>
			<string>com.youcompany.tweakprefs.prefschanged</string>
			<key>key</key>
			<string>isRecent</string>
			<key>label</key>
			<string>Show Recent</string>
		</dict>
		<dict>
			<key>cell</key>
			<string>PSTextCell</string>
			<key>label</key>
			<string>Recent Number </string>
		</dict>
		<dict>
			<key>cell</key>
			<string>PSSliderCell</string>
			<key>defaults</key>
			<string>com.youcompany.tweakprefs</string>
			<key>default</key>
			<integer>3</integer>
			<key>min</key>
			<integer>1</integer>
			<key>max</key>
			<integer>5</integer>
			<key>isSegmented</key>
			<true/>
			<key>segmentCount</key>
			<integer>4</integer>
			<key>showValue</key>
			<true/>
			<key>key</key>
			<string>nRecent</string>
		</dict>
	</array>
	<key>title</key>
	<string>Tweak Setting</string>
</dict>
</plist>

 

Posted
4 hours ago, CookieFJ said:

static void loadPrefs() {
	NSMutableDictionary *settings = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/var/mobile/Library/Preferences/com.youcompany.tweakprefs.plist"];

	isEnabled		= ( [settings objectForKey:@"isEnabled"] ? [[settings objectForKey:@"isEnabled"] boolValue] : isEnabled );
	isRecent		= ( [settings objectForKey:@"isRecent"] ? [[settings objectForKey:@"isRecent"] boolValue] : isRecent );
	nRecent 		= ( [settings objectForKey:@"nRecent"] ? [[settings objectForKey:@"nRecent"] intValue] : nRecent );
}

%ctor {
    loadPrefs();
    CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)loadPrefs, CFSTR("com.youcompany.tweakprefs.prefschanged"), NULL, CFNotificationSuspensionBehaviorCoalesce);
}


<?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>items</key>
	<array>
		<dict>
			<key>cell</key>
			<string>PSGroupCell</string>
			<key>footerText</key>
			<string>turn on to make this tweak function</string>
		</dict>
		<dict>
			<key>cell</key>
			<string>PSSwitchCell</string>
			<key>default</key>
			<false/>
			<key>defaults</key>
			<string>com.yourcompany.tweakprefs</string>
			<key>key</key>
			<string>isEnabled</string>
			<key>label</key>
			<string>Enable</string>
		</dict>
		<dict>
			<key>cell</key>
			<string>PSGroupCell</string>
			<key>footerText</key>
			<string>Options</string>
		<dict>
			<key>cell</key>
			<string>PSSwitchCell</string>
			<key>default</key>
			<true/>
			<key>defaults</key>
			<string>com.youcompany.tweakprefs</string>
			<key>PostNotification</key>
			<string>com.youcompany.tweakprefs.prefschanged</string>
			<key>key</key>
			<string>isRecent</string>
			<key>label</key>
			<string>Show Recent</string>
		</dict>
		<dict>
			<key>cell</key>
			<string>PSTextCell</string>
			<key>label</key>
			<string>Recent Number </string>
		</dict>
		<dict>
			<key>cell</key>
			<string>PSSliderCell</string>
			<key>defaults</key>
			<string>com.youcompany.tweakprefs</string>
			<key>default</key>
			<integer>3</integer>
			<key>min</key>
			<integer>1</integer>
			<key>max</key>
			<integer>5</integer>
			<key>isSegmented</key>
			<true/>
			<key>segmentCount</key>
			<integer>4</integer>
			<key>showValue</key>
			<true/>
			<key>key</key>
			<string>nRecent</string>
		</dict>
	</array>
	<key>title</key>
	<string>Tweak Setting</string>
</dict>
</plist>

 

/var/mobile/Library/Preferences/xxxxxxx.plist is create when the "setting > yourhack" made changes

Toggle switch or enter string.

the plist will auto generate when you change something inside Setting.

inside the plist you set.

com.youcompany.tweakprefs

this need to change to your key.

com.abcde.appname

so your plist should auto named:

com.abcde.appname.plist

Posted

Thank you for your answer. I got it.

May I have further questions:

Preference not initialize as Root.plist expected. For example, nRecent slider indicates 2 but not default 3. What will cause this?

 

Update: looks it is set to previous value before uninstalled. So, there should be somewhere to save tweak's preference besides /var/mobile/Library/Preferences/xxxxxxx.plist or Root.plist. I made sure these 2 files do not exist before I re-install my tweak.

Archived

This topic is now archived and is closed to further replies.

×
  • Create New...

Important Information

We would like to place cookies on your device to help make this website better. The website cannot give you the best user experience without cookies. You can accept or decline our cookies. You may also adjust your cookie settings. Privacy Policy - Guidelines