IT English Collection(29)of Preferences

1 前言

  本节主要介绍了Preference(系统偏好设置),应用的预设置。

  转载请注明出处:http://blog.csdn.net/developer_zhang

2 详述

2.1 原文

  Preferences are settings that an application defines for itself (often as defaults) or that users select for the application. For example, a text editor might have settings for default font, automatic spell-checking, and autosaving frequency. Preferences are recorded in a repository of default or user-specified known as the user defaults (or preferences) system. Your application writes user preferences, in the form of key-value pairs, to the user defaults system and reads preferences from it. Values must be property-list objects. You write and read user preferences to and from the user defaults system by calling methods of the NSUserDefaults class or functions of the PreferenceUtilities (CFPreference). Preferences are not necessarily user configurable; for example, an application can use the user defaults system to store state information.

Note: Although items in the user defaults system must be property-list objects, you should only use NSUserDefaults methods or CFPreference functions to read and write them. Do not use any other API that deals with property lists such as the NSPropertyListSerialization class.


Each User Preference Belongs to a Domain and a User
When you write a user preference to the user defaults system, it puts it in a domain that reflects thescope of the preference. For example, there’s a domain for application-specific defaults and another for defaults that apply to all applications (NSGlobalDomain). Although preferences in these domains arepersistent across application launches, preferences in some domainsexist only while an application is running.

  User preferences are also associated with a particular user. Thus you can look at a preference “record” in the user-defaults repository as being structured in three levels: first user, then domain (usually global or per-application), and then key-value pairs within each domain. The root object for the combined preferences of a user is a dictionary in which, for application-specific domains, the keys are the bundle identifiers of applications.


  Preferences are written to files named with the application’s bundle identifier and having an extension of plist. In iOS the files are located in a special location of an application’s sandbox; in OS X preference files are located in Library/Preferences in a user’s home directory.

Your Application Must Present a User Interface for the Selection of Preferences
  Before your application can store user-configurable preferences in the user defaults system, it must present a user interface for selecting those preferences. On OS X, thisentails designing a preference panel that a user displays by choosing Preferences from the application menu. The application is responsible for writing the settings that the user supplies to the user defaults system.


In iOS, the approach is more nuanced. Applications have two choices for displaying user preferences.

·In a separate preferences view. Applications that have only a few options or options that are likely to change frequently—for example, a sound-muting control for a game—would present those options in view that presents controls for changing their values.
·In the system-provided Settings application. Preference options that users are likely to set once andrarely change thereafter should appear instead in the Settings application provided by the operating system.
  To integrate your application preferences into the Settings application, you must include a specially formatted settings bundle in the top-level directory of your application bundle. This settings bundle provides information about your application preferences to the Settings application, which is then responsible for displaying those preferences and updating the user-defaults system with any user-supplied values.

  At runtime, your application retrieves preferences in the user defaults system using the NSUserDefaults or CFPreference APIs.

2.2 生词

Preference ['pref(ə)r(ə)ns]n. 偏爱,倾向;优先权

repository [rɪ'pɒzɪt(ə)rɪ]n. 贮藏室,仓库;知识库;智囊团

utility [juːˈtɪləti]n. 实用;效用;公共设施;功用

item ['aɪtəm]n. 条款,项目;一则

scope [skəʊp]n. 范围;余地;视野;眼界;导弹射程

persistent [pə'sɪst(ə)nt]adj. 固执的,坚持的;持久稳固的

exist [ɪg'zɪst; eg-]vi. 存在;生存;生活;继续存在

present ['prez(ə)nt]vt. 提出;介绍;呈现;赠送

entails [ɪn'teɪl; en-]vt. 使需要,必需;承担;遗传给;蕴含

responsible [rɪ'spɒnsɪb(ə)l]adj. 负责的,可靠的;有责任的

approach [ə'prəʊtʃ]n. 方法;途径;接近

nuanced ['njuːɑːnst]adj. 微妙的;具有细微差别的

few [fjuː]adj. 很少的;几乎没有的

mute [mjuːt]vt. 减弱……的声音;使……柔和

rarely ['reəlɪ]adv. 很少地;难得;罕有地

integrate ['ɪntɪgreɪt]vt. 使…完整;使…成整体;求…的积分;表示…的总和

retrieve [rɪ'triːv]vt. [计] 检索;恢复;重新得到

3 结语

  以上是所有内容,希望对大家有所帮助。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值