Preferences specifier plist

From iPhone Development Wiki
Revision as of 05:27, 17 December 2014 by Kirb (talk | contribs) (PSLinkListCell & PSSegmentCell: fill out how shortTitles is used)
Jump to: navigation, search

This document provides the specification of the .plist files that specify the layout of an iOS preference pane.

Root level

The root level of the plist may contain these keys:

key type meaning depends
entry dictionary Specifier-like dictionary. -
title string localizable string Title of the preference pane. -
items array ... of specifiers Array of specifier dictionaries. -

Specifier Keys and Values

You can use any keys that your controller recognizes in the plist for further customization.

General to-do: Add explanations of each specifier and potentially a screenshot of it (gif for the spinner?).

Cell types

Must be one of the following:

  • PSButtonCell
  • PSEditTextCell
  • PSEditTextViewCell
  • PSGiantIconCell
  • PSGiantCell
  • PSGroupCell
  • PSLinkCell
  • PSLinkListCell
  • PSListItemCell
  • PSSecureEditTextCell
  • PSSegmentCell
  • PSSliderCell
  • PSSpinnerCell
  • PSStaticTextCell
  • PSSwitchCell
  • PSTitleValueCell

The cell type is determined from the class method +[PSTableCell cellTypeFromString:].

General keys

key type meaning depends
cell string <cell type> Specifier cell type. -
label string localizable string Label of specifier. -
defaults string bundle ID User defaults associated with this specifier. -
key string Key of the user defaults. defaults ≠ nil
default any Default value of control. -
id string Specifier ID. -
get string selector Getter.
Signature: -(id)getValueForSpecifier:(PSSpecifier*)specifier;
set string selector Setter.
Signature: -(void)setValue:(id)value forSpecifier:(PSSpecifier*)specifier;
enabled boolean Whether the control is enabled by default. -
height float Height of the cell. -
PostNotification string Darwin notification string to be posted when a change happens. -
detail string class name Detail controller class. -
cellClass string class name Customized cell class -
requiredCapabilities array ... of <capability>s Required capabilities of the device such that this specifier can be shown. -
dontIndentOnRemove boolean Prevents the cell from being indented when the table view is in editing mode. -

Keys apply to all cells unless otherwise stated in their respective subsection.


key type meaning depends
action string selector Action.
Signature: -(void)speciferPerformedAction:(PSSpecifier*)specifier;
or -(void)speciferPerformedAction;
confirmation dictionary <confirmation> Definitions of the confirmation sheet before action is performed. -
isDestructive boolean Whether the action to be performed is destructive. The OK button will be in red if true if less than iOS7. confirmation ≠ nil

The confirmation value is a dictionary containing the following fields:

key type meaning
prompt string localizable string Content of confirmation sheet.
title string localizable string Title of confirmation sheet.
okTitle string localizable string Title of the OK button.
cancelTitle string localizable string Title of the cancel button.

To do: confirm this last table. Tests suggest "prompt" is the title, "title" is the okTitle, "okTitle" is MIA, cancelTitle works as stated. Investigate history of "isDestructive" key.

PSEditTextCell & PSSecureEditTextCell

key type meaning depends
keyboard string {"numbers", "phone"} Type of keyboard. nil or invalid values uses a normal keyboard. -
autoCaps string {"sentences", "words", "all"} Autocapitalization type for cells that requires a keyboard. keyboard = nil
placeholder string localizable string Placeholder. -
suffix string localizable string Suffix. -
bestGuess string selector Initial value of text field. -
noAutoCorrect boolean Disable auto-correction. -
isIP boolean Input field intended for entering IP address (Use Numbers keyboard). -
isURL boolean Input field intended for entering URL (Use URL keyboard). -
isNumeric boolean Input field intended for entering numbers (Use NumberPad keyboard). -
isEmail boolean Input field intended for entering e-mail (Use EmailAddress keyboard). -
isEmailAddressing boolean ? -
prompt string localizable string Setup prompt. -
okTitle string localizable string Title for OK button in setup prompt. prompt ≠ nil
cancelTitle string localizable string Title for cancel button in setup prompt. prompt ≠ nil

To do: Check "prompt", "okTitle" and "cancelTitle" as they appear to not work on iOS 6. Are these in the correct place?
Check what "suffix" does. Find "bestGuess" selector signature. Solve the mystery of "isEmailAddressing".


This specifier doesn't show a label so it is recommended to use a previous specifier to indicate what this specifier represents.

The text area expands to fit the whole cell, so setting a height key will provide more space to write.

Saved value is HTML text, <div> being the root tag block.


The font in this cell is bigger than normal.

To do: Find out the actual font and icon sizes.


This specifier doesn't show a label so it is recommended to use a specifier before this one to indicate what this specifier represents.


key type meaning depends
footerText string Text displayed in a small font after this specifier. -
footerAlignment integer 0:left; 1:center; 2:right; defaults to 1. -
headerCellClass class The cell class using which to render the header. -
footerCellClass class The cell class using which to render the footer. -
isStaticText boolean Whether the cells in this group has static text. Used in conjunction with PSStaticTextCell. -

If you want to make a Image Header read this.

To do: Research "isStaticText" interaction with "PSStaticTextCell".


key type meaning depends
bundle string filename Bundle file name. This bundle will be loaded for additional resources. -
internal boolean Directory to search for the bundle.
If true, search in /AppleInternal/Library/PreferenceBundles/.
If false, search in /System/Library/PreferenceBundles/.
bundle ≠ nil
isController boolean Whether the bundle contains a controller class. bundle ≠ nil
overridePrincipalClass boolean Overrides the principal class by the detail controller when bundle has a controller. isController = true
pane string class name Edit pane class.
If bundle is absent, the edit pane class is obtained from the current bundle.
Default value is PSEditingPane.
detail ≠ nil
hasIcon boolean Whether the specifier will have an icon. bundle ≠ nil
icon string filename File name of the icon to use. Default value is icon.png. The height of the icon should be 29px. hasIcon = true
customControllerClass string class name Custom controller class to use when the view become visible -
lazy-bundle NSBundle A bundle. This bundle will be loaded for additional resources. -

This specifier is useful for loading extra resources and custom code.

If none of these keys are specified, the framework will try to load a plist using the label text as name.

PSLinkListCell & PSSegmentCell

key type meaning depends
validValues array ...of strings List of values to choose from. -
validTitles array ...of localizable strings Titles corresponding to the list of values. -
shortTitles array ...of localizable strings Short titles corresponding to the list of values, displayed in the link cell. -
valuesDataSource string selector Selector to call to get the list of values dynamically. validValues = nil
titlesDataSource string selector Selector to call to get the list of titles dynamically. validTitles = nil
staticTextMessage string localizable string The message to be added below the cells list of PSListItemsController. cell = "PSLinkListCell"

valuesDataSource and titlesDataSource are performed on the target sent from -[PSListController loadSpecifiersFromPlistName:target:]. They must return an NSArray containing the values and (localized) titles respectively. Their signatures should be


In order to make a PSLinkListCell actually work like a list, you must supply the key-value pair

	detail = PSListItemsController;


key type meaning depends
min float Minimum value of slider. -
max float Maximum value of slider. -
showValue boolean Show the value. -
rightImage string filename Image displayed next to the slider on the right. -
leftImage string filename Image displayed next to the slider on the left. -

This specifier doesn't show a label so it is recommended to use a previous specifier to indicate what this specifier represents.

Images must reside in the same directory. They can be symlinks to files elsewhere though.


PSSpinnerCell is a simple cell with an animating spinner (UIActivityIndicatorView) inside it. Available only in iOS 7 (or higher)[citation needed]. There is no way to start or stop the animation manually, it is always running. Therefore, this cell is meant to be dynamically inserted and deleted from a PSListController subclass.



key type meaning depends
alternateColors boolean Use an orange switch instead of blue. iOS < 7
control-loading boolean Show an activity indicator view instead of switch (e.g. VPN cell) -
negate boolean Invert the value displayed. -

You can dynamically set the UISwitch's state by returning YES or NO in the get method. When the switch's state changes, the set method is called.

Switch issues on iOS 7

Since iOS 7.0 and above the "alternateColors" key does not work. To be able to change the color of a switch, you must subclass PSSwitchTableCell in a PreferenceBundle as follows:

#import <Preferences/Preferences.h>
#import <Preferences/PSSwitchTableCell.h> //if this header is not found, update your headers or uncomment the part below
Only uncomment this if you have older headers

@interface PSTableCell : UITableViewCell
@interface PSControlTableCell : PSTableCell
-(UIControl *)control;
@interface PSSwitchTableCell : PSControlTableCell
-(id)initWithStyle:(int)arg1 reuseIdentifier:(id)arg2 specifier:(id)arg3 ;
@interface SRSwitchTableCell : PSSwitchTableCell //our class

@implementation SRSwitchTableCell

-(id)initWithStyle:(int)arg1 reuseIdentifier:(id)arg2 specifier:(id)arg3 { //init method
	self = [super initWithStyle:arg1 reuseIdentifier:arg2 specifier:arg3]; //call the super init method
	if (self) {
		[((UISwitch *)[self control]) setOnTintColor:[UIColor redColor]]; //change the switch color
	return self;


Then set this key-value pair for the specifier:

	cellClass = SRSwitchTableCell;

A detailed tutorial about this has been written on


This specifier makes use of the get key to get the value in the runtime.


key type meaning depends
alignment integer Text alignment. 0:left; 1:center; 2:right; defaults to 1. cell ∈ {"PSGroupCell", "PSStaticTextCell"}

To do: check which specifiers support this key.

PSSpecifier runtime properties of plist keys

The table above only shows the keys recognized by SpecifiersForPlist when translating the plist into an array of PSSpecifiers. They may correspond to the actual properties of the specifier. If you would like to generate a PSSpecifier in runtime, some actions may differ:

keys corresponding action
cell Use the constructor, or change the cellType ivar.
label Use the name declared property.
get Use the constructor, or change the getter ivar.
set Use the constructor, or change the setter ivar.
action Change the action ivar.
default Use the value property.
icon -[PSSpecifier setProperty:forKey:] Use the iconImage and UIImage as a key and property, or -[PSSpecifier setupIconImageWithPath:]
autoCaps, keyboard, noAutoCorrect -[PSSpecifier setKeyboardType:autoCaps:autoCorrection:]
isIP, isURL, isNumeric, isEmail, isEmailAddressing Change the textFieldType ivar.
bestGuess Change the bestGuess ivar of the PSTextFieldSpecifier class.
validValues, validTitles, shortTitles -[PSSpecifier setValues:titles:shortTitles:]
confirmation Create an instance of PSConfirmationSpecifier.


Use the following snippet to create a PSSpecifier in the runtime:

	PSSpecifier* specifier = [PSSpecifier preferenceSpecifierNamed:@"title"
								  cell:<cell type>
	[specifier setProperty:@YES forKey:@"enabled"];

Using @selector(setPreferenceValue:specifier:) as setter and @selector(readPreferenceValue:) as getter will ease the load on the work as the specifier will use its properties to make itself work, namely "defaults", "key", "default", "PostNotification".


The red delete button in VPN is in fact very easy to implement. All you need to do is add the following code:

#import <UIKit/UIPreferencesDeleteTableCell.h>

@interface PSDeleteTableCell : UIPreferencesDeleteTableCell

@implementation PSDeleteTableCell
-(void)setValueChangedTarget:(id)target action:(SEL)action userInfo:(NSDictionary*)info {
	[self setTarget:target];
	[self setAction:action];
-(UILabel*)titleTextLabel {
	UILabel* res = [super titleTextLabel];
	res.textColor = [UIColor whiteColor];
	return res;

And add the following key-value pair to the button specifier:

	cellClass = PSDeleteTableCell;

Note that UIPreferencesDeleteTableCell no longer exists as of iOS 6.0. It appears to be replaced by a boolean on PSButtonCell, isDestructive.


PSLinkCell is useful for linking to sub-preference-panes. The simplest example just needs 2 keys:

	cell  = PSLinkCell;
	label = "Settings-iPhone";

The label is the important part. When user clicked on the link cell, iPhoneOS will use the unlocalized label as the file name of the plist for the next pane. In the example above, the main settings screen will appear.

If you use just 2 keys, only plists inside Preferences can be loaded. In order to load your own plist, you must use a custom subclass of PSListController in detail:

	cell   = PSLinkCell;
	label  = "My Awesome Pane";
	detail = MyListController;

MyListController can simply be an empty subclass of PSListController:

@interface MyListController : PSListController {}
@implementation MyListController

The key thing is when you place MyListController inside your bundle, its bundle property will return your bundle which My Awesome Pane.plist can be found.


To display a value like Preferences -> General -> About, add the cell to your plist:

	cell = PSTitleValueCell;
	label = Version;
	get = "valueForSpecifier:";

And add the getter method to your controller:

- (NSString *)valueForSpecifier:(PSSpecifier *)specifier {
	return @"1.0";

Custom cells

Making a custom cell, header or footer is useful because it allows you to customize the style, add an image, etc.

All you need to do is make a class that looks like:

@interface CustomCell : PSTableCell <PreferencesTableCustomView> {
	UILabel *_label;

@implementation CustomCell
- (id)initWithSpecifier:(PSSpecifier *)specifier {
	self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell" specifier:specifier];
	if (self) {
		CGRect frame = [self frame];

		_label = [[UILabel alloc] initWithFrame:frame];
		[_label setLineBreakMode:UILineBreakModeWordWrap];
		[_label setNumberOfLines:0];
		[_label setText:@"You can use attributed text to make this prettier."];
		[_label setBackgroundColor:[UIColor clearColor]];
		[_label setShadowColor:[UIColor whiteColor]];
		[_label setShadowOffset:CGSizeMake(0,1)];
		[_label setTextAlignment:UITextAlignmentCenter];

		[self addSubview:_label];
		[_label release];
	return self;

- (float)preferredHeightForWidth:(float)arg1 {
	// Return a custom cell height.
	return 60.f;

Then, set the cellClass, headerCellClass or footerCellClass in your specifier. For example:

	cell = PSGroupCell;
	footerCellClass = CustomCell;

A cell doesn't have to be specified for custom cells.

Constructing a PSLinkCell at runtime

If you want to dynamically add a specifier for a PSLinkCell that lazy-loads a bundle, you can do it like this:

PSSpecifier* specifier = [PSSpecifier preferenceSpecifierNamed:@"title"

[specifier setProperty:@"/System/Library/PreferenceBundles/prefs.bundle" forKey:@"lazy-bundle"];
specifier->action = @selector(lazyLoadBundle:);

// Now add the specifier to your controller.

Making an editable PSListController

With this you can perform a "swipe-to-delete" on the rows.

You just have to use a subclass of PSEditableListController (which is a subclass of PSListController) for your List Controller. For example:

@interface MyListController : PSEditableListController {}

@implementation MyListController
- (id)specifiers {
	if (!_specifiers) {
	//add a sample specifier to the list
		PSSpecifier* testSpecifier = [PSSpecifier preferenceSpecifierNamed:@"test"
		_specifiers = [[NSArray arrayWithObjects:testSpecifier, nil] retain];
	return _specifiers;

Please note, you will only be able to delete a specifier, if it's class is either PSLinkListCell, PSListItemCell or PSTitleValueCell

To perform a custom action when the specifier gets deleted, you have to implement a method in your PSEditableListController subclass like this:

	UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Removing specifier: "
							message:[specifier name]
	[alert show];

and set the deletionAction Key of the specifier:

extern NSString* PSDeletionActionKey;

	construct the PSSpecifier* testSpecifier here

[testSpecifier setProperty:NSStringFromSelector(@selector(removedSpecifier:)) forKey:PSDeletionActionKey];

Custom Settings Libraries

External links