Platforms to show: All Mac Windows Linux Cross-Platform
Back to NSUserDefaultsMBS class.
NSUserDefaultsMBS.addSuiteNamed(suiteName as string)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
suiteName: The domain name to insert. This domain is inserted after the application domain.
The suiteName domain is similar to a bundle identifier string, but is not tied to a particular application or bundle. A suite can be used to hold preferences that are shared between multiple applications.
Some examples using this method:
NSUserDefaultsMBS.arrayForKey(key as string) as Variant()
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
The array associated with the specified key, or an empty array if the key does not exist or its value is not an array.
NSUserDefaultsMBS.boolForKey(key as string) as boolean
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
property | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
If a boolean value is associated with defaultName in the user defaults, that value is returned. Otherwise, false is returned.
(Read and Write computed property)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
This method does not put anything in the search list.
See also:
NSUserDefaultsMBS.Constructor(username as string)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
username: The name of the user account.
Returns an initialized NSUserDefaultsMBS object whose argument and registration domains are already set up. If the current user does not have access to the specified user account, the object is invalid.
This method does not put anything in the search list. Invoke it only if you've allocated your own NSUserDefaults instance instead of using the shared one.
You do not normally use this method to initialize an instance of NSUserDefaults. Applications used by a superuser might use this method to update the defaults databases for a number of users. The user who started the application must have appropriate access (read, write, or both) to the defaults database of the new user, or this method returns nil.
See also:
NSUserDefaultsMBS.dataForKey(key as string) as memoryblock
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
property | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Returns the memoryblock or nil if there is no value for this key.
dataForKey is for any string and does not store encoding. stringForKey does store encoding and works only for text strings.
(Read and Write computed property)
NSUserDefaultsMBS.dictionaryForKey(key as string) as dictionary
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
property | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Returns dictionary object associated with the specified key, or nil if the key does not exist or its value is not an dictionary.
(Read and Write computed property)
NSUserDefaultsMBS.dictionaryRepresentation as dictionary
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Returns a dictionary containing the keys. The keys are names of defaults and the value corresponding to each key is a property list object as Variant.
As with variantForKey, key-value pairs in domains that are earlier in the search list take precedence. The combined result does not preserve information about which domain each entry came from.
NSUserDefaultsMBS.doubleForKey(key as string) as Double
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
property | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Returns the double value associated with the specified key. If the key does not exist, this method returns 0.
Available in Mac OS X v10.5 and later. On Mac OS X 10.4 the plugin will call floatForKey for you to avoid an exception.
(Read and Write computed property)
NSUserDefaultsMBS.fileForKey(key as string) as folderitem
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
property | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Available in Mac OS X v10.6 and later.
(Read and Write computed property)
NSUserDefaultsMBS.floatForKey(key as string) as single
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
property | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Returns the floating-point value associated with the specified key. If the key does not exist, this method returns 0.
(Read and Write computed property)
NSUserDefaultsMBS.integerForKey(key as string) as Integer
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
property | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
The integer value associated with the specified key. If the specified key does not exist, this method returns 0.
(Read and Write computed property)
Some examples using this property:
NSUserDefaultsMBS.objectIsForcedForKey(key as string) as boolean
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
key: The key whose status you want to check.
Returns true if the value of the specified key is managed by an administrator, otherwise false.
This method assumes that the key is a preference associated with the current user and application. For managed keys, the application should disable any user interface that allows the user to modify the value of key.
Available in Mac OS X v10.2 and later.
See also:
NSUserDefaultsMBS.objectIsForcedForKey(key as string, domain as string) as boolean
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
key: The key whose status you want to check.
domain: The domain of the key.
Returns true if the key is managed by an administrator in the specified domain, otherwise false.
This method assumes that the key is a preference associated with the current user. For managed keys, the application should disable any user interface that allows the user to modify the value of key.
Available in Mac OS X v10.2 and later.
See also:
NSUserDefaultsMBS.persistentDomainForName(domainName as string) as dictionary
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Returns a dictionary containing the keys. The keys are names of defaults and the value corresponding to each key is a property list object (NSData, NSString, NSNumber, NSDate, NSArray, or NSDictionary).
NSUserDefaultsMBS.persistentDomainNames as string()
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
You can get the keys and values for each domain by passing the returned domain names to the persistentDomainForName method.
NSUserDefaultsMBS.registerDefaults(dic as dictionary)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
dic: The dictionary of keys and values you want to register.
If there is no registration domain, one is created using the specified dictionary, and NSRegistrationDomain is added to the end of the search list.
The contents of the registration domain are not written to disk; you need to call this method each time your application starts. You can place a plist file in the application's Resources directory and call registerDefaults with the contents that you read in from that file.
Some examples using this method:
NSUserDefaultsMBS.removeObjectForKey(defaultName as string)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
defaultName: The key whose value you want to remove.
Removing a default has no effect on the value returned by the variantForKey method if the same key exists in a domain that precedes the standard application domain in the search list.
NSUserDefaultsMBS.removePersistentDomainForName(domainName as string)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
domainName: The domain whose keys and values you want. This value should be equal to your application's bundle identifier.
When a persistent domain is changed, an NSUserDefaultsDidChangeNotification is posted.
NSUserDefaultsMBS.removeSuiteNamed(suiteName as string)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
suiteName: The domain name to remove.
NSUserDefaultsMBS.removeVolatileDomainForName(domainName as string)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
domainName: The volatile domain you want to remove.
NSUserDefaultsMBS.setArrayValue(key as string, values() as Variant)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
NSUserDefaultsMBS.setBoolValue(key as string, value as boolean)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Some examples using this method:
NSUserDefaultsMBS.setDataValue(key as string, value as memoryblock)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
setStringValue is for text with encoding and setDataValue is for strings containing binary data.
NSUserDefaultsMBS.setDictionaryValue(key as string, value as dictionary)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
NSUserDefaultsMBS.setDoubleValue(key as string, value as Double)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Available in Mac OS X v10.5 and later. On Mac OS X 10.4 the plugin will call setFloatValue for you to avoid an exception.
NSUserDefaultsMBS.setFileValue(key as string, value as folderitem)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Available in Mac OS X v10.6 and later.
NSUserDefaultsMBS.setFloatValue(key as string, value as single)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
NSUserDefaultsMBS.setIntegerValue(key as string, value as Integer)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Some examples using this method:
NSUserDefaultsMBS.setPersistentDomain(domain as dictionary, domainName as string)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
domain: The dictionary of keys and values you want to assign to the domain.
domainName: The domain whose keys and values you want to set. This value should be equal to your application's bundle identifier.
When a persistent domain is changed, an NSUserDefaultsDidChangeNotification is posted.
NSUserDefaultsMBS.setStringArrayValue(key as string, values() as string)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
NSUserDefaultsMBS.setStringValue(key as string, value as string)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
setStringValue is for text with encoding and setDataValue is for strings containing binary data.
NSUserDefaultsMBS.setURLValue(key as string, value as string)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Available in Mac OS X v10.6 and later.
NSUserDefaultsMBS.setVariantValue(key as string, value as Variant)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
The value parameter can be only property list objects: String, Number, Date, an Array of variant, or Dictionary. For Arrays and Dictionaries, their contents must be property list objects.
Setting a default has no effect on the value returned by the objectForKey: method if the same key exists in a domain that precedes the application domain in the search list.
NSUserDefaultsMBS.setVolatileDomain(domain as dictionary, domainName as string)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
domain: The dictionary of keys and values you want to assign to the domain.
domainName: The domain whose keys and values you want to set.
This method raises an NSInvalidArgumentException if a volatile domain with the specified name already exists.
NSUserDefaultsMBS.stringArrayForKey(key as string) as string()
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Returns an array with strings. The array is empty if the value for the key is not an array.
NSUserDefaultsMBS.stringForKey(key as string) as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
property | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Returns the string or "" if there is no value for this key.
dataForKey is for any string and does not store encoding. stringForKey does store encoding and works only for text strings.
(Read and Write computed property)
NSUserDefaultsMBS.synchronize as boolean
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Returns true if the data was saved successfully to disk, otherwise false.
Because this method is automatically invoked at periodic intervals, use this method only if you cannot wait for the automatic synchronization (for example, if your application is about to exit) or if you want to update the user defaults to what is on disk even though you have not made any changes.
NSUserDefaultsMBS.URLForKey(key as string) as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
property | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Available in Mac OS X v10.6 and later.
(Read and Write computed property)
NSUserDefaultsMBS.variantForKey(key as string) as Variant
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
property | Cocoa | MBS MacBase Plugin | 10.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
This method searches the domains included in the search list in the order they are listed.
(Read and Write computed property)
The items on this page are in the following plugins: MBS MacBase Plugin.