Provides access to application preferences, typically stored via NSUserDefaults
or CFProperties
. To access the preferences, simply pass in the Bundle ID (eg. "com.apple.Preview") and it will return a table whose keys can be accessed or updated, or iterated via ipairs
.
For example:
local previewPrefs = require("cp.app.prefs").new("com.apple.Preview")previewPrefs.MyCustomPreference = "Hello world"print(previewPrefs.MyCustomPreference) --> "Hello world"​for k,v in pairs(previewPrefs) doprint(k .. " = " .. tostring(v))end
Constructors - API calls which return an object, typically one that offers API methods
​new​
Signature |
|
Type | Function |
Description | Retrieves the |
Parameters | prefs - the |
Returns | The Bundle ID string, or |
Signature |
|
Type | Function |
Description | Retrieves the specifed |
Parameters | prefs - The |
Returns | The current value, or |
Signature |
|
Type | Function |
Description | Checks if the |
Parameters | thing - The value to check |
Returns |
|
Signature |
|
Type | Function |
Description | Retrieves the |
Parameters | prefs - The |
Returns | The |
Signature |
|
Type | Function |
Description | Sets the key/value for the specified |
Parameters | prefs - The |
Returns | Nothing. |
Signature |
|
Type | Function |
Description | Adds a watch function which will be notified when the preferences change. |
Parameters | prefs - The |
Returns | Nothing |
Signature |
|
Type | Constructor |
Description | Creates a new |
Parameters | bundleID The Bundle ID to access preferences for. |
Returns | A new |