I would like to make a preference bundle for my jailbreak tweak. I successfully made a preference bundle with a switch that works.
But I would like a setting to choose color. Example:
Blue
Color > Yellow
Green
So if I click on Color, it would bring me to another screen which ask me to choose either "Blue", "Yellow" or "Green"
I have looked at tutorials on the net, and I think this is a PSLinkList
.
But I want my tweak to read the plist and record what color is chosen.
I think it would read the validValues
of the PSLinkList
, am I right?
But what code would I use to read the plist?
EDIT: Nate helped me with adding the PSListcontroller but I met one problem:
Here is my plist http://pastebin.com/uNKzLBrf
<?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>label</key>
<string>Main</string>
</dict>
<dict>
<key>cell</key>
<string>PSSwitchCell</string>
<key>default</key>
<true/>
<key>defaults</key>
<string>com.junyi00.prefs</string>
<key>key</key>
<string>enabled</string>
<key>label</key>
<string>Enable</string>
</dict>
<dict>
<key>cell</key>
<string>PSGroupCell</string>
<key>label</key>
<string>Colors</string>
</dict>
<dict>
<key>cell</key>
<string>PSListLinkCell</string>
<key>defaults</key>
<string>com.junyi00.prefs</string>
<key>detail</key>
<string>PSListItemsController</string>
<key>key</key>
<string>color</string>
<key>label</key>
<string>Color</string>
<key>validTitles</key>
<array>
<string>Default</string>
<string>Random</string>
<string>Yellow</string>
<string>Blue</string>
<string>Red</string>
<string>Green</string>
</array>
<key>validValues</key>
<array>
<string>Default</string>
<string>Random</string>
<string>Yellow</string>
<string>Blue</string>
<string>Red</string>
<string>Green</string>
</array>
</dict>
</array>
<key>title</key>
<string>Flash Color</string>
</dict>
</plist>
Help me with this?
Take a look at this older tutorial. (Note: for others reading this, the tutorial does not use PreferenceLoader, which should now be used for this task)
In your case, I think the
MyAppName.plist
should contain something like this:Which could then be read in by your code like this:
I've skipped over some steps here, as it sounds like you're familiar with the general process of adding your jailbreak app, or tweak's, settings to Preferences.app. If this doesn't work for you, post a comment asking for clarification.