Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/extensions/Variables/includes/ExtVariables.php on line 198

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/extensions/Variables/includes/ExtVariables.php on line 198

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/extensions/Variables/includes/ExtVariables.php on line 198

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/extensions/Variables/includes/ExtVariables.php on line 198
PreferenceBundles: Difference between revisions - iPhone Development Wiki

PreferenceBundles: Difference between revisions

From iPhone Development Wiki
(Removed PSTitleValueCell recipe)
(Extended description, removed entry plist and directed towards that section on PreferenceLoader, formatting)
Line 1: Line 1:
'''Preference Bundles''' are bundles for extending the [[Preferences.app|Settings]] application.
'''Preference Bundles''' are bundles for extending the [[Preferences.app|Settings]] application. Developers can build their own bundles and place them in <tt>/Library/PreferenceBundles/</tt> for others to use.


== Structure of a Preference Bundle ==
== Structure of a Preference Bundle ==
Preference bundles should have an extension of <tt>.bundle</tt>. The principle class of the bundle should be a subclass of [[PSListController]]. Most of the time there are lots of  ''preference specifier plists'' which defines a page of setting. If a specifier plist is called <tt>spec.plist</tt>, there should be a corresponding localization file called <tt>spec.strings</tt>. The bundle can have a 29&times;29 icon, with a preferred name of <tt>icon.png</tt>.


For more information, see [[Preferences_specifier_plist|Preferences Specifier Plist Format]].
Preference bundles must have the extension <tt>.bundle</tt>. The principle class of the bundle should be a subclass of [[PSListController]] or [[PSViewController]]. When providing localization files, if a specifier plist is called <tt>spec.plist</tt>, there should be a corresponding localization file called <tt>spec.strings</tt>. The bundle can have a 29&times;29 icon, with a preferred name of <tt>icon.png</tt>.
 
For more information on specifiers, see [[Preferences_specifier_plist|Preferences Specifier Plist Format]].


== Issues with OS 3.2 and 4.0 ==
== Issues with OS 3.2 and 4.0 ==
Line 10: Line 11:
<tt>PSViewController</tt> underwent a massive change after 3.1, breaking all custom subclasses on the iPad and on 4.0 - it is now a UIViewController.
<tt>PSViewController</tt> underwent a massive change after 3.1, breaking all custom subclasses on the iPad and on 4.0 - it is now a UIViewController.


Improper implementations of <tt>PSListController</tt> subclasses will fail to work properly on 4.0. You must set <tt>_specifiers</tt> within the <tt>-(id) specifiers</tt> method (instead of returning a different array of specifiers.) This is because OS 4.0 relies on _specifiers to generate specifier metadata and group indices. Example:
Improper implementations of <tt>PSListController</tt> subclasses will fail to work properly on 4.0 and later. You must set <tt>_specifiers</tt> within the <code>- (id)specifiers</code> method and return it. This is because PSListController relies on <tt>_specifiers</tt> to generate specifier metadata and group indices since iOS 4.0. Example:
 
<source lang="objc">
<source lang="objc">
- (id) specifiers {
- (id)specifiers {
if (!_specifiers){
if (!_specifiers){
_specifiers = [[self loadSpecifiersFromPlistName: kNameOfPreferencesPlist target: self] retain];
_specifiers = [[self loadSpecifiersFromPlistName: kNameOfPreferencesPlist target: self] retain];
}
}
return _specifiers;
return _specifiers;
}
}
</source>
</source>


== Adding a Preference Bundle ==
== Using a Preference Bundle ==


{{main|PreferenceLoader}}
{{main|PreferenceLoader#PreferenceBundle_Approach}}
To add a preference bundle <tt>foo.bundle</tt> to the front page of the Settings application, save this as a plist in <tt>/Library/PreferenceLoader/Preferences/</tt>:
entry = {
  bundle = foo;
  cell = PSLinkCell;
  icon = icon.png;
  isController = 1;
  label = "Description of the setting";
};


== References ==
== References ==


* [http://www.touchrepo.com/guides/preferencebundles/PreferenceBundles.doc iPhone Settings Within Settings.app], by Skylar Cantu.
* [http://www.touchrepo.com/guides/preferencebundles/PreferenceBundles.doc iPhone Settings Within Settings.app], by Skylar Cantu.
{{Navbox Library}}
{{Navbox Library}}
[[Category:Directories in /System/Library]]
[[Category:Directories in /System/Library]]

Revision as of 06:16, 1 August 2014

Preference Bundles are bundles for extending the Settings application. Developers can build their own bundles and place them in /Library/PreferenceBundles/ for others to use.

Structure of a Preference Bundle

Preference bundles must have the extension .bundle. The principle class of the bundle should be a subclass of PSListController or PSViewController. When providing localization files, if a specifier plist is called spec.plist, there should be a corresponding localization file called spec.strings. The bundle can have a 29×29 icon, with a preferred name of icon.png.

For more information on specifiers, see Preferences Specifier Plist Format.

Issues with OS 3.2 and 4.0

PSViewController underwent a massive change after 3.1, breaking all custom subclasses on the iPad and on 4.0 - it is now a UIViewController.

Improper implementations of PSListController subclasses will fail to work properly on 4.0 and later. You must set _specifiers within the - (id)specifiers method and return it. This is because PSListController relies on _specifiers to generate specifier metadata and group indices since iOS 4.0. Example:

- (id)specifiers {
	if (!_specifiers){
		_specifiers = [[self loadSpecifiersFromPlistName: kNameOfPreferencesPlist target: self] retain];
	}
	return _specifiers;
}

Using a Preference Bundle

References