API  0.9.6
 All Classes Files Functions Variables Macros Modules Pages
CPUserDefaults Class Reference

#import <CPUserDefaults.h>

+ Inheritance diagram for CPUserDefaults:

Instance Methods

(CPArray- arrayForKey:
 
(BOOL) - boolForKey:
 
(CPData- dataForKey:
 
(CPDictionary- dictionaryForKey:
 
(void) - domainDidChange:
 
(double) - doubleForKey:
 
(float) - floatForKey:
 
(id) - init
 
(int) - integerForKey:
 
(id) - objectForKey:
 
(id) - objectForKey:inDomain:
 
(CPArray- persistentDomainNames
 
(CPUserDefaultsStore- persistentStoreForDomain:
 
(void) - registerDefaults:
 
(void) - registerDefaultsFromContentsOfFile:
 
(void) - reloadDataFromStoreForDomain:
 
(void) - removeObjectForKey:
 
(void) - removeObjectForKey:inDomain:
 
(void) - setBool:forKey:
 
(void) - setDouble:forKey:
 
(void) - setFloat:forKey:
 
(void) - setInteger:forKey:
 
(void) - setObject:forKey:
 
(void) - setObject:forKey:inDomain:
 
(CPUserDefaultsStore- setPersistentStoreClass:forDomain:reloadData:
 
(void) - setURL:forKey:
 
(CPArray- stringArrayForKey:
 
(CPString- stringForKey:
 
(void) - synchronize
 
(CPURL- URLForKey:
 
(CPArray- volatileDomainNames
 
- Instance Methods inherited from CPObject
(void) - addObserver:forKeyPath:options:context:
 
(void) - applyChange:toKeyPath:
 
(id) - autorelease
 
(id) - awakeAfterUsingCoder:
 
(void) - awakeFromCib
 
(void) - bind:toObject:withKeyPath:options:
 
(Class) - classForCoder
 
(Class) - classForKeyedArchiver
 
(CPString- className
 
(id) - copy
 
(void) - dealloc
 
(CPString- description
 
(CPDictionary- dictionaryWithValuesForKeys:
 
(void) - didChange:valuesAtIndexes:forKey:
 
(void) - didChangeValueForKey:
 
(void) - didChangeValueForKey:withSetMutation:usingObjects:
 
(void) - doesNotRecognizeSelector:
 
(CPArray- exposedBindings
 
(id) - forwardingTargetForSelector:
 
(void) - forwardInvocation:
 
(unsigned) - hash
 
(BOOL) - implementsSelector:
 
(CPDictionary- infoForBinding:
 
(BOOL) - isEqual:
 
(BOOL) - isKindOfClass:
 
(BOOL) - isMemberOfClass:
 
(BOOL) - isProxy
 
(IMP) - methodForSelector:
 
(CPMethodSignature) - methodSignatureForSelector:
 
(id) - mutableArrayValueForKey:
 
(id) - mutableArrayValueForKeyPath:
 
(id) - mutableCopy
 
(id) - mutableSetValueForKey:
 
(id) - mutableSetValueForKeyPath:
 
(id) - performSelector:
 
(id) - performSelector:withObject:
 
(id) - performSelector:withObject:withObject:
 
(id) - performSelector:withObjects:
 
(void) - release
 
(void) - removeObserver:forKeyPath:
 
(id) - replacementObjectForArchiver:
 
(id) - replacementObjectForCoder:
 
(id) - replacementObjectForKeyedArchiver:
 
(BOOL) - respondsToSelector:
 
(id) - retain
 
(id) - self
 
(void) - setValue:forKey:
 
(void) - setValue:forKeyPath:
 
(void) - setValue:forUndefinedKey:
 
(void) - setValuesForKeysWithDictionary:
 
(CPString- UID
 
(void) - unbind:
 
(Class) - valueClassForBinding:
 
(id) - valueForKey:
 
(id) - valueForKeyPath:
 
(id) - valueForUndefinedKey:
 
(void) - willChange:valuesAtIndexes:forKey:
 
(void) - willChangeValueForKey:
 
(void) - willChangeValueForKey:withSetMutation:usingObjects:
 

Class Methods

(void) + resetStandardUserDefaults
 
(id) + standardUserDefaults
 
- Class Methods inherited from CPObject
(BOOL) + accessInstanceVariablesDirectly
 
(id) + alloc
 
(id) + allocWithCoder:
 
(BOOL) + automaticallyNotifiesObserversForKey:
 
(Class) + class
 
(void) + exposeBinding:
 
(void) + initialize
 
(IMP) + instanceMethodForSelector:
 
(BOOL) + instancesRespondToSelector:
 
(BOOL) + isSubclassOfClass:
 
(CPSet+ keyPathsForValuesAffectingValueForKey:
 
(void) + load
 
(id) + new
 
(void) + setVersion:
 
(Class) + superclass
 
(int) + version
 

Additional Inherited Members

- Instance Variables inherited from CPObject
Class isa
 

Detailed Description

CPUserDefaults provides a way of storing a list of user preferences. Everything you store must be CPCoding compliant because it is stored as CPData.

Unlike in Cocoa, CPUserDefaults is per-host by default because of the method of storage. By default, the localStorage API will be used if the browser supports it. Otherwise a cookie fallback mechanism is utilized. Be aware that if the user erases the local database or clears their cookies, all the preferences will be lost. Also be aware that this is not a safe storage method; do not store sensitive data in the defaults database.

The storage method utilized is determined by matching the writing domain to a dictionary of stores, concrete subclasses of the CPUserDefaultsStore abstract class. This is a deviation from Cocoa. You can create a custom defaults store by subclassing the abstract class and implementing the protocol. Currently the protocol consists of only two methods: -data and -setData:. The latter needs to store the passed in CPData object in your storage mechanism and the former needs to return an equivalent CPData object synchronously. You can then configure CPUserDefaults to use your storage mechanism using -setPersistentStoreClass:forDomain:reloadData:

Definition at line 2 of file CPUserDefaults.h.

Method Documentation

- (CPArray) arrayForKey: (CPString aKey
implementation

Returns the array value associated with the specified key.

Definition at line 370 of file CPUserDefaults.j.

- (BOOL) boolForKey: (CPString aKey
implementation

Returns the Boolean value associated with the specified key.

Definition at line 382 of file CPUserDefaults.j.

- (CPData) dataForKey: (CPString aKey
implementation

Returns the data object associated with the specified key.

Definition at line 395 of file CPUserDefaults.j.

- (CPDictionary) dictionaryForKey: (CPString aKey
implementation

Returns the Boolean value associated with the specified key.

Definition at line 407 of file CPUserDefaults.j.

- (void) domainDidChange: (CPString aDomain
implementation

Definition at line 337 of file CPUserDefaults.j.

- (double) doubleForKey: (CPString aKey
implementation

Returns the double value associated with the specified key.

Definition at line 449 of file CPUserDefaults.j.

- (float) floatForKey: (CPString aKey
implementation

Returns the float value associated with the specified key.

Definition at line 419 of file CPUserDefaults.j.

- (id) init
implementation

Initializes the receiver

Returns
the initialized receiver

Reimplemented from CPObject.

Definition at line 86 of file CPUserDefaults.j.

- (int) integerForKey: (CPString aKey
implementation

Returns the integer value associated with the specified key.

Definition at line 434 of file CPUserDefaults.j.

- (id) objectForKey: (CPString aKey
implementation

Return a default value. The order of domains in the search list is: CPRegistrationDomain, CPGlobalDomain, CPApplicationDomain, CPArgumentDomain. Calling this method may cause the search list to be recreated if any new values have recently been set. Be aware of the performance ramifications.

Definition at line 126 of file CPUserDefaults.j.

- (id) objectForKey: (CPString aKey
inDomain: (CPString aDomain 
implementation

Return a default value from a specific domain. If you know which domain you'd like to use you should always use this method because it doesn't have to hit the search list.

Definition at line 147 of file CPUserDefaults.j.

- (CPArray) persistentDomainNames
implementation

Returns an array of currently persistent domain names.

Definition at line 284 of file CPUserDefaults.j.

- (CPUserDefaultsStore) persistentStoreForDomain: (CPString aDomain
implementation

Returns the currently used instance of CPUserDefaultStore concrete subclass for the given domain name.

Definition at line 292 of file CPUserDefaults.j.

- (void) registerDefaults: (CPDictionary aDictionary
implementation

Adds the contents the specified dictionary to the registration domain.

If there is no registration domain, one is created using the specified dictionary, and CPRegistrationDomain 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 registerDefaultsWithContentsOfFile:

Parameters
aDictionaryThe dictionary of keys and values you want to register.

Definition at line 212 of file CPUserDefaults.j.

- (void) registerDefaultsFromContentsOfFile: (CPURL aURL
implementation

This is just a convenience method to load a plist resource and register all the values it contains as defaults.

NOTE: This sends a synchronous request. If you don't want to do that, create a dictionary any way you want (including loading a plist) and pass it to -registerDefaults:

Definition at line 231 of file CPUserDefaults.j.

- (void) reloadDataFromStoreForDomain: (CPString aDomain
implementation

Definition at line 324 of file CPUserDefaults.j.

- (void) removeObjectForKey: (CPString aKey
implementation

Removes the value of the specified default key in the standard application domain. Removing a default has no effect on the value returned by the objectForKey: method if the same key exists in a domain that precedes the standard application domain in the search list.

Definition at line 182 of file CPUserDefaults.j.

- (void) removeObjectForKey: (CPString aKey
inDomain: (CPString aDomain 
implementation

Removes the value of the specified default key in the specified domain.

Definition at line 190 of file CPUserDefaults.j.

+ (void) resetStandardUserDefaults
implementation

Synchronizes any changes made to the shared user defaults object and releases it from memory. A subsequent invocation of standardUserDefaults creates a new shared user defaults object with the standard search list.

Definition at line 75 of file CPUserDefaults.j.

- (void) setBool: (BOOL)  aValue
forKey: (CPString aKey 
implementation

Sets the value of the specified default key to the specified Boolean value. A cast will be attempted with -boolValue.

Definition at line 507 of file CPUserDefaults.j.

- (void) setDouble: (double)  aValue
forKey: (CPString aKey 
implementation

Sets the value of the specified default key to the double value.

Definition at line 528 of file CPUserDefaults.j.

- (void) setFloat: (float)  aValue
forKey: (CPString aKey 
implementation

Sets the value of the specified default key to the specified float value. A cast will be attempted with -floatValue and parseFloat().

Definition at line 517 of file CPUserDefaults.j.

- (void) setInteger: (int)  aValue
forKey: (CPString aKey 
implementation

Sets the value of the specified default key to the specified integer value. A cast will be attempted with -intValue and parseInt().

Definition at line 537 of file CPUserDefaults.j.

- (void) setObject: (id)  anObject
forKey: (CPString aKey 
implementation

Set a default value in your application domain.

Definition at line 137 of file CPUserDefaults.j.

- (void) setObject: (id)  anObject
forKey: (CPString aKey
inDomain: (CPString aDomain 
implementation

Set a default value in the domain you pass in. If the domain is CPApplicationDomain or CPGlobalDomain, the defaults store will eventually be persisted. You can call -forceFlush to force a persist.

Definition at line 161 of file CPUserDefaults.j.

- (CPUserDefaultsStore) setPersistentStoreClass: (Class)  aStoreClass
forDomain: (CPString aDomain
reloadData: (BOOL)  aFlag 
implementation

Set the CPUserDefaultStore concrete subclass that should be instantiated for use in persisting the given domain name.

Parameters
aStoreClassThe concrete subclass of CPUserDefaultsStore to use to store the defaults database for this domain
aDomainThe name of the domain for which you want to change the storage mechanism
reloadDataEmpty the cached defaults for this domain and reload them from the new storage mechanism

Definition at line 305 of file CPUserDefaults.j.

- (void) setURL: (CPURL aValue
forKey: (CPString aKey 
implementation

Sets the value of the specified default key to the specified URL. The adjustments made in Cocoa are not present here.

Definition at line 549 of file CPUserDefaults.j.

+ (id) standardUserDefaults
implementation

Returns the shared defaults object.

Definition at line 63 of file CPUserDefaults.j.

- (CPArray) stringArrayForKey: (CPString aKey
implementation

Returns the string array value associated with the specified key.

Definition at line 473 of file CPUserDefaults.j.

- (CPString) stringForKey: (CPString aKey
implementation

Returns the string value associated with the specified key.

Definition at line 457 of file CPUserDefaults.j.

- (void) synchronize
implementation

Force write out of defaults database immediately.

Definition at line 348 of file CPUserDefaults.j.

- (CPURL) URLForKey: (CPString aKey
implementation

Returns the CPURL value associated with the specified key.

Definition at line 489 of file CPUserDefaults.j.

- (CPArray) volatileDomainNames
implementation

Returns an array of currently volatile domain names.

Definition at line 276 of file CPUserDefaults.j.


The documentation for this class was generated from the following files: