public class NSUserDefaults extends NSObject
Hierarchical: NSUserDefaults has a list of places to look for data called the "search list". A search list is referred to by an arbitrary string called the "suite identifier" or "domain identifier". When queried, NSUserDefaults checks each entry of its search list until it finds one that contains the key in question, or has searched the whole list. The list is (note: "current host + current user" preferences are unimplemented on iOS, watchOS, and tvOS, and "any user" preferences are not generally useful for applications on those operating systems): - Managed ("forced") preferences, set by a configuration profile or via mcx from a network administrator - Commandline arguments - Preferences for the current domain, in the cloud - Preferences for the current domain, the current user, in the current host - Preferences for the current domain, the current user, in any host - Preferences added via -addSuiteNamed: - Preferences global to all apps for the current user, in the current host - Preferences global to all apps for the current user, in any host - Preferences for the current domain, for all users, in the current host - Preferences global to all apps for all users, in the current host - Preferences registered with -registerDefaults:
Persistent: Preferences stored in NSUserDefaults persist across reboots and relaunches of apps unless otherwise specified.
Interprocess: Preferences may be accessible to and modified from multiple processes simultaneously (for example between an application and an extension).
Optionally distributed (Currently only supported in Shared iPad for Students mode): Data stored in user defaults can be made "ubiqitous", i.e. synchronized between devices via the cloud. Ubiquitous user defaults are automatically propagated to all devices logged into the same iCloud account. When reading defaults (via -*ForKey: methods on NSUserDefaults), ubiquitous defaults are searched before local defaults. All operations on ubiquitous defaults are asynchronous, so registered defaults may be returned in place of ubiquitous defaults if downloading from iCloud hasn't finished. Ubiquitous defaults are specified in the Defaults Configuration File for an application.
Key-Value Store: NSUserDefaults stores Property List objects (NSString, NSData, NSNumber, NSDate, NSArray, and NSDictionary) identified by NSString keys, similar to an NSMutableDictionary.
Optimized for storing user settings: NSUserDefaults is intended for relatively small amounts of data, queried very frequently, and modified occasionally. Using it in other ways may be slow or use more memory than solutions more suited to those uses.
The 'App' CFPreferences functions in CoreFoundation act on the same search lists that NSUserDefaults does.
NSUserDefaults can be observed using Key-Value Observing for any key stored in it. Using NSKeyValueObservingOptionPrior to observe changes from other processes or devices will behave as though NSKeyValueObservingOptionPrior was not specified.
NSObject.Function_instanceMethodForSelector_ret, NSObject.Function_methodForSelector_ret| Modifier | Constructor and Description |
|---|---|
protected |
NSUserDefaults(org.moe.natj.general.Pointer peer) |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
accessInstanceVariablesDirectly() |
void |
addSuiteNamed(java.lang.String suiteName)
-addSuiteNamed: adds the full search list for 'suiteName' as a sub-search-list of the receiver's.
|
static NSUserDefaults |
alloc() |
static NSUserDefaults |
allocWithZone(org.moe.natj.general.ptr.VoidPtr zone) |
NSArray<?> |
arrayForKey(java.lang.String defaultName)
-arrayForKey: is equivalent to -objectForKey:, except that it will return nil if the value is not an NSArray.
|
static boolean |
automaticallyNotifiesObserversForKey(java.lang.String key) |
boolean |
boolForKey(java.lang.String defaultName)
-boolForKey: is equivalent to -objectForKey:, except that it converts the returned value to a BOOL.
|
static void |
cancelPreviousPerformRequestsWithTarget(java.lang.Object aTarget) |
static void |
cancelPreviousPerformRequestsWithTargetSelectorObject(java.lang.Object aTarget,
org.moe.natj.objc.SEL aSelector,
java.lang.Object anArgument) |
static NSArray<java.lang.String> |
classFallbacksForKeyedArchiver() |
static org.moe.natj.objc.Class |
classForKeyedUnarchiver() |
NSData |
dataForKey(java.lang.String defaultName)
-dataForKey: is equivalent to -objectForKey:, except that it will return nil if the value is not an NSData.
|
static java.lang.String |
debugDescription_static() |
static java.lang.String |
description_static() |
NSDictionary<java.lang.String,?> |
dictionaryForKey(java.lang.String defaultName)
-dictionaryForKey: is equivalent to -objectForKey:, except that it will return nil if the value is not an NSDictionary.
|
NSDictionary<java.lang.String,?> |
dictionaryRepresentation()
-dictionaryRepresentation returns a composite snapshot of the values in the receiver's search list, such that [[receiver dictionaryRepresentation] objectForKey:x] will return the same thing as [receiver objectForKey:x].
|
double |
doubleForKey(java.lang.String defaultName)
-doubleForKey: is similar to -integerForKey:, except that it returns a double, and boolean values will not be converted.
|
float |
floatForKey(java.lang.String defaultName)
-floatForKey: is similar to -integerForKey:, except that it returns a float, and boolean values will not be converted.
|
static long |
hash_static() |
NSUserDefaults |
init()
-init is equivalent to -initWithSuiteName:nil
|
NSUserDefaults |
initWithSuiteName(java.lang.String suitename)
-initWithSuiteName: initializes an instance of NSUserDefaults that searches the shared preferences search list for the domain 'suitename'.
|
NSUserDefaults |
initWithUser(java.lang.String username)
Deprecated.
|
static NSObject.Function_instanceMethodForSelector_ret |
instanceMethodForSelector(org.moe.natj.objc.SEL aSelector) |
static NSMethodSignature |
instanceMethodSignatureForSelector(org.moe.natj.objc.SEL aSelector) |
static boolean |
instancesRespondToSelector(org.moe.natj.objc.SEL aSelector) |
long |
integerForKey(java.lang.String defaultName)
-integerForKey: is equivalent to -objectForKey:, except that it converts the returned value to an NSInteger.
|
static boolean |
isSubclassOfClass(org.moe.natj.objc.Class aClass) |
static NSSet<java.lang.String> |
keyPathsForValuesAffectingValueForKey(java.lang.String key) |
static NSUserDefaults |
new_objc() |
java.lang.Object |
objectForKey(java.lang.String defaultName)
-objectForKey: will search the receiver's search list for a default with the key 'defaultName' and return it.
|
boolean |
objectIsForcedForKey(java.lang.String key)
-objectIsForcedForKey: returns YES if the value for 'key' is provided by managed preferences (a configuration profile or mcx)
|
boolean |
objectIsForcedForKeyInDomain(java.lang.String key,
java.lang.String domain)
-objectIsForcedForKey:inDomain: returns YES if the value for 'key' is provided by managed preferences (a configuration profile or mcx) for the search list named by 'domain'
|
NSDictionary<java.lang.String,?> |
persistentDomainForName(java.lang.String domainName)
-persistentDomainForName: returns a dictionary representation of the search list entry specified by 'domainName', the current user, and any host.
|
NSArray<?> |
persistentDomainNames()
Deprecated.
|
void |
registerDefaults(NSDictionary<java.lang.String,?> registrationDictionary)
-registerDefaults: adds the registrationDictionary to the last item in every search list.
|
void |
removeObjectForKey(java.lang.String defaultName)
-removeObjectForKey: is equivalent to -[...
|
void |
removePersistentDomainForName(java.lang.String domainName)
-removePersistentDomainForName: removes all values from the search list entry specified by 'domainName', the current user, and any host.
|
void |
removeSuiteNamed(java.lang.String suiteName)
-removeSuiteNamed: removes a sub-searchlist added via -addSuiteNamed:.
|
void |
removeVolatileDomainForName(java.lang.String domainName) |
static void |
resetStandardUserDefaults()
+resetStandardUserDefaults releases the standardUserDefaults and sets it to nil.
|
static boolean |
resolveClassMethod(org.moe.natj.objc.SEL sel) |
static boolean |
resolveInstanceMethod(org.moe.natj.objc.SEL sel) |
void |
setBoolForKey(boolean value,
java.lang.String defaultName)
-setBool:forKey: is equivalent to -setObject:forKey: except that the value is converted from a BOOL to an NSNumber.
|
void |
setDoubleForKey(double value,
java.lang.String defaultName)
-setDouble:forKey: is equivalent to -setObject:forKey: except that the value is converted from a double to an NSNumber.
|
void |
setFloatForKey(float value,
java.lang.String defaultName)
-setFloat:forKey: is equivalent to -setObject:forKey: except that the value is converted from a float to an NSNumber.
|
void |
setIntegerForKey(long value,
java.lang.String defaultName)
-setInteger:forKey: is equivalent to -setObject:forKey: except that the value is converted from an NSInteger to an NSNumber.
|
void |
setObjectForKey(java.lang.Object value,
java.lang.String defaultName)
-setObject:forKey: immediately stores a value (or removes the value if nil is passed as the value) for the provided key in the search list entry for the receiver's suite name in the current user and any host, then asynchronously stores the value persistently, where it is made available to other processes.
|
void |
setPersistentDomainForName(NSDictionary<java.lang.String,?> domain,
java.lang.String domainName)
-setPersistentDomain:forName: replaces all values in the search list entry specified by 'domainName', the current user, and any host, with the values in 'domain'.
|
void |
setURLForKey(NSURL url,
java.lang.String defaultName)
-setURL:forKey is equivalent to -setObject:forKey: except that the value is archived to an NSData.
|
static void |
setVersion_static(long aVersion) |
void |
setVolatileDomainForName(NSDictionary<java.lang.String,?> domain,
java.lang.String domainName) |
static NSUserDefaults |
standardUserDefaults()
+standardUserDefaults returns a global instance of NSUserDefaults configured to search the current application's search list.
|
NSArray<java.lang.String> |
stringArrayForKey(java.lang.String defaultName)
-stringForKey: is equivalent to -objectForKey:, except that it will return nil if the value is not an NSArray
|
java.lang.String |
stringForKey(java.lang.String defaultName)
-stringForKey: is equivalent to -objectForKey:, except that it will convert NSNumber values to their NSString representation.
|
static org.moe.natj.objc.Class |
superclass_static() |
boolean |
synchronize()
-synchronize is deprecated and will be marked with the API_DEPRECATED macro in a future release.
|
NSURL |
URLForKey(java.lang.String defaultName)
-URLForKey: is equivalent to -objectForKey: except that it converts the returned value to an NSURL.
|
static long |
version_static() |
NSDictionary<java.lang.String,?> |
volatileDomainForName(java.lang.String domainName) |
NSArray<java.lang.String> |
volatileDomainNames()
Volatile domains are not added to any search list, are not persisted, and are not visible to other applications.
|
accessibilityActivate, accessibilityActivationPoint, accessibilityAssistiveTechnologyFocusedIdentifiers, accessibilityAttributedHint, accessibilityAttributedLabel, accessibilityAttributedUserInputLabels, accessibilityAttributedValue, accessibilityContainerType, accessibilityCustomActions, accessibilityCustomRotors, accessibilityDecrement, accessibilityDragSourceDescriptors, accessibilityDropPointDescriptors, accessibilityElementAtIndex, accessibilityElementCount, accessibilityElementDidBecomeFocused, accessibilityElementDidLoseFocus, accessibilityElementIsFocused, accessibilityElements, accessibilityElementsHidden, accessibilityFrame, accessibilityHint, accessibilityIncrement, accessibilityLabel, accessibilityLanguage, accessibilityNavigationStyle, accessibilityPath, accessibilityPerformEscape, accessibilityPerformMagicTap, accessibilityRespondsToUserInteraction, accessibilityScroll, accessibilityTextualContext, accessibilityTraits, accessibilityUserInputLabels, accessibilityValue, accessibilityViewIsModal, addObserverForKeyPathOptionsContext, attemptRecoveryFromErrorOptionIndex, attemptRecoveryFromErrorOptionIndexDelegateDidRecoverSelectorContextInfo, autoContentAccessingProxy, awakeAfterUsingCoder, awakeFromNib, class_objc, classForCoder, classForKeyedArchiver, copy, dealloc, debugDescription, description, dictionaryWithValuesForKeys, didChangeValueForKey, didChangeValueForKeyWithSetMutationUsingObjects, didChangeValuesAtIndexesForKey, doesNotRecognizeSelector, fileManagerShouldProceedAfterError, fileManagerWillProcessPath, finalize_objc, forwardingTargetForSelector, forwardInvocation, hash, indexOfAccessibilityElement, isAccessibilityElement, isEqual, isKindOfClass, isMemberOfClass, isProxy, methodForSelector, methodSignatureForSelector, mutableArrayValueForKey, mutableArrayValueForKeyPath, mutableCopy, mutableOrderedSetValueForKey, mutableOrderedSetValueForKeyPath, mutableSetValueForKey, mutableSetValueForKeyPath, observationInfo, observeValueForKeyPathOfObjectChangeContext, performSelector, performSelectorInBackgroundWithObject, performSelectorOnMainThreadWithObjectWaitUntilDone, performSelectorOnMainThreadWithObjectWaitUntilDoneModes, performSelectorOnThreadWithObjectWaitUntilDone, performSelectorOnThreadWithObjectWaitUntilDoneModes, performSelectorWithObject, performSelectorWithObjectAfterDelay, performSelectorWithObjectAfterDelayInModes, performSelectorWithObjectWithObject, prepareForInterfaceBuilder, provideImageDataBytesPerRowOrigin_Size_UserInfo, removeObserverForKeyPath, removeObserverForKeyPathContext, replacementObjectForCoder, replacementObjectForKeyedArchiver, respondsToSelector, self, setAccessibilityActivationPoint, setAccessibilityAttributedHint, setAccessibilityAttributedLabel, setAccessibilityAttributedUserInputLabels, setAccessibilityAttributedValue, setAccessibilityContainerType, setAccessibilityCustomActions, setAccessibilityCustomRotors, setAccessibilityDragSourceDescriptors, setAccessibilityDropPointDescriptors, setAccessibilityElements, setAccessibilityElementsHidden, setAccessibilityFrame, setAccessibilityHint, setAccessibilityLabel, setAccessibilityLanguage, setAccessibilityNavigationStyle, setAccessibilityPath, setAccessibilityRespondsToUserInteraction, setAccessibilityTextualContext, setAccessibilityTraits, setAccessibilityUserInputLabels, setAccessibilityValue, setAccessibilityViewIsModal, setIsAccessibilityElement, setNilValueForKey, setObservationInfo, setShouldGroupAccessibilityChildren, setValueForKey, setValueForKeyPath, setValueForUndefinedKey, setValuesForKeysWithDictionary, shouldGroupAccessibilityChildren, superclass, validateValueForKeyError, validateValueForKeyPathError, valueForKey, valueForKeyPath, valueForUndefinedKey, willChangeValueForKey, willChangeValueForKeyWithSetMutationUsingObjects, willChangeValuesAtIndexesForKeypublic static boolean accessInstanceVariablesDirectly()
public static NSUserDefaults alloc()
public static NSUserDefaults allocWithZone(org.moe.natj.general.ptr.VoidPtr zone)
public static boolean automaticallyNotifiesObserversForKey(java.lang.String key)
public static void cancelPreviousPerformRequestsWithTarget(java.lang.Object aTarget)
public static void cancelPreviousPerformRequestsWithTargetSelectorObject(java.lang.Object aTarget,
org.moe.natj.objc.SEL aSelector,
java.lang.Object anArgument)
public static NSArray<java.lang.String> classFallbacksForKeyedArchiver()
public static org.moe.natj.objc.Class classForKeyedUnarchiver()
public static java.lang.String debugDescription_static()
public static java.lang.String description_static()
public static long hash_static()
public static NSObject.Function_instanceMethodForSelector_ret instanceMethodForSelector(org.moe.natj.objc.SEL aSelector)
public static NSMethodSignature instanceMethodSignatureForSelector(org.moe.natj.objc.SEL aSelector)
public static boolean instancesRespondToSelector(org.moe.natj.objc.SEL aSelector)
public static boolean isSubclassOfClass(org.moe.natj.objc.Class aClass)
public static NSSet<java.lang.String> keyPathsForValuesAffectingValueForKey(java.lang.String key)
public static NSUserDefaults new_objc()
public static void resetStandardUserDefaults()
public static boolean resolveClassMethod(org.moe.natj.objc.SEL sel)
public static boolean resolveInstanceMethod(org.moe.natj.objc.SEL sel)
public static void setVersion_static(long aVersion)
public static NSUserDefaults standardUserDefaults()
public static org.moe.natj.objc.Class superclass_static()
public static long version_static()
public NSURL URLForKey(java.lang.String defaultName)
public void addSuiteNamed(java.lang.String suiteName)
public NSArray<?> arrayForKey(java.lang.String defaultName)
public boolean boolForKey(java.lang.String defaultName)
public NSData dataForKey(java.lang.String defaultName)
public NSDictionary<java.lang.String,?> dictionaryForKey(java.lang.String defaultName)
public NSDictionary<java.lang.String,?> dictionaryRepresentation()
public double doubleForKey(java.lang.String defaultName)
public float floatForKey(java.lang.String defaultName)
public NSUserDefaults init()
public NSUserDefaults initWithSuiteName(java.lang.String suitename)
@Deprecated public NSUserDefaults initWithUser(java.lang.String username)
public long integerForKey(java.lang.String defaultName)
public java.lang.Object objectForKey(java.lang.String defaultName)
public boolean objectIsForcedForKey(java.lang.String key)
public boolean objectIsForcedForKeyInDomain(java.lang.String key,
java.lang.String domain)
public NSDictionary<java.lang.String,?> persistentDomainForName(java.lang.String domainName)
@Deprecated public NSArray<?> persistentDomainNames()
public void registerDefaults(NSDictionary<java.lang.String,?> registrationDictionary)
Default values from Defaults Configuration Files will automatically be registered.
public void removeObjectForKey(java.lang.String defaultName)
public void removePersistentDomainForName(java.lang.String domainName)
public void removeSuiteNamed(java.lang.String suiteName)
public void removeVolatileDomainForName(java.lang.String domainName)
public void setBoolForKey(boolean value,
java.lang.String defaultName)
public void setDoubleForKey(double value,
java.lang.String defaultName)
public void setFloatForKey(float value,
java.lang.String defaultName)
public void setIntegerForKey(long value,
java.lang.String defaultName)
public void setObjectForKey(java.lang.Object value,
java.lang.String defaultName)
public void setPersistentDomainForName(NSDictionary<java.lang.String,?> domain, java.lang.String domainName)
public void setURLForKey(NSURL url, java.lang.String defaultName)
public void setVolatileDomainForName(NSDictionary<java.lang.String,?> domain, java.lang.String domainName)
public NSArray<java.lang.String> stringArrayForKey(java.lang.String defaultName)
public java.lang.String stringForKey(java.lang.String defaultName)
public boolean synchronize()
-synchronize blocks the calling thread until all in-progress set operations have completed. This is no longer necessary. Replacements for previous uses of -synchronize depend on what the intent of calling synchronize was. If you synchronized... - ...before reading in order to fetch updated values: remove the synchronize call - ...after writing in order to notify another program to read: the other program can use KVO to observe the default without needing to notify - ...before exiting in a non-app (command line tool, agent, or daemon) process: call CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication) - ...for any other reason: remove the synchronize call
public NSDictionary<java.lang.String,?> volatileDomainForName(java.lang.String domainName)
public NSArray<java.lang.String> volatileDomainNames()