Skip to main content
Version: 8.6.x

bfgSettings Class

Stores settings to disk automatically so that other libraries can use keys to retrieve them. More...#import <bfgsettings.h>

Class Methods

(BOOL) + canUseStorageType:
 
(BOOL) + write
 
(BOOL) + writeStorageType:
 
(void) + set:value:
 
(void) + set:value:storageType:
 
(id _Nullable) + get:
 
(id _Nullable) + get:storageType:
 
(id _Nullable) + get:withDefault:
 
(id _Nullable) + get:withDefault:storageType:
 
(BOOL) + isPersistable:storageType:
 
(id _Nullable) + get:ofType:
 
(id _Nullable) + get:ofType:withDefault:
 
(id _Nullable) + get:ofType:withDefault:storageType:
 
(id _Nullable) + get:ofType:storageType:
 
(id _Nullable) + get:ofType:withDefault:storageType:error:
 
(NSString *_Nullable) + filePathforDiskMappedResource:
 

Detailed Description

Stores settings to disk automatically so that other libraries can use keys to retrieve them. Developers can use this class to store settings used in their own libraries.

Method Documentation

◆ canUseStorageType:

+ (BOOL) canUseStorageType: (bfgSettingsStorageType) storageType
Returns
Is this storage type available for use?
Return values
YESStorage type is available for use.
NOStorage type is not available for use.
Since
4.7

◆ filePathforDiskMappedResource:

+ (NSString *_Nullable) filePathforDiskMappedResource: (NSString *_Nonnull) key
Gets the file path for a resource persisted through bfgDiskMappedPersister
Parameters
keyThe key used to write and retreive the value from the persisted store.
Returns
The file path for the resource or nil if the resouce cannot be found.
Since
6.6

◆ get:

+ (id _Nullable) get: (NSString *_Nonnull) key
Gets a setting value for a key from the settings plist.
Parameters
keyThe key for the value to be retrieved.
Returns
The value from the settings.
Since
2.2

◆ get:ofType:

+ (id _Nullable) get:(NSString *_Nonnull) key
ofType:(Class _Nonnull) type 
Gets a settings value for a key and checks the type of the retrieved value against the passed in type parameter.
Parameters
keyThe key for the value to be retrieved.
typeThe desired object type of the retrieved value.
Returns
The value from settings, or nil if the object type of the value and passed in type parameter do not match.

◆ get:ofType:storageType:

+ (id _Nullable) get:(NSString *_Nonnull) key
ofType:(Class _Nonnull) type
storageType:(bfgSettingsStorageType) storageType 
Gets a settings value for a key from the requested store and checks the type of the retrieved value against the passed in type parameter.
Parameters
keyThe key for the value to be retrieved.
typeThe desired object type of the retrieved value.
storageTypeThe medium on which to persist the values (plist, local keychain, etc.).
Returns
The value from settings, or nil if the object type of the retrieved value and the passed in type parameter do not match.
Since
6.0

◆ get:ofType:withDefault:

+ (id _Nullable) get:(NSString *_Nonnull) key
ofType:(Class _Nonnull) type
withDefault:(id _Nullable) defaultValue 
Gets a settings value for a key and checks the type of the retrieved value against the passed in type parameter. Allows for a default value if the key does not exist.
Parameters
keyThe key for the value to be retrieved.
typeThe desired object type of the retrieved value.
defaultValueThe default value to be returned when no value is set for the key or the retrieved values' object type does not match the passed in type parameter.
Returns
The value from settings, or defaultValue if either the object type of the retrieved value and type parameter do not match or if no value is set for the key.
Since
6.0

◆ get:ofType:withDefault:storageType:

+ (id _Nullable) get:(NSString *_Nonnull) key
ofType:(Class _Nonnull) type
withDefault:(id _Nullable) defaultValue
storageType:(bfgSettingsStorageType) storageType 
Gets a settings value for a key from the requested store and checks the type of the retrieved value against the passed in type parameter. Allows for a default value if the key does not exist.
Parameters
keyThe key for the value to be retrieved.
typeThe desired object type of the retrieved value.
defaultValueThe default value to be returned when no value is set for the key or the retrieved value's object type does not match the passed in type parameter.
storageTypeThe medium on which to persist the values (plist, local keychain, etc.).
Returns
The value from settings, or defaultValue if either the object type of the retrieved value and type parameter do not match or if no value is set for the key.
Since
6.0

◆ get:ofType:withDefault:storageType:error:

+ (id _Nullable) get:(NSString *_Nonnull) key
ofType:(Class _Nonnull) type
withDefault:(id _Nullable) defaultValue
storageType:(bfgSettingsStorageType) storageType
error:(NSError *_Nullable __autoreleasing *_Nullable) error 
Gets a settings value for a key from the requested store, checks the type of the retrieved value against the passed in type parameter, and allows for a default value if the key does not exist in the store. In addition, this method sets the passed in NSError** when there is a type mismatch.
Parameters
keyThe key for the value to be retrieved.
typeThe desired object type of the retrieved value.
defaultValueThe default value to be returned when no value is set for the key, or the retrieved value's object type does not match the passed in type parameter.
storageTypeThe medium on which to persist the value.
errorThe NSError object that will be populated if the a type mismatch is detected.

◆ get:storageType:

+ (id _Nullable) get:(NSString *_Nonnull) key
storageType:(bfgSettingsStorageType) storageType 
Gets a setting value for a key from the requested storage type.
Parameters
keyThe key for the value to be retrieved.
storageTypeThe medium on which to persist the values (plist, local keychain, etc.).
Returns
The value from the settings.
Since
4.7

◆ get:withDefault:

+ (id _Nullable) get:(NSString *_Nonnull) key
withDefault:(id _Nullable) defaultValue 
Gets a setting value for a key from the settings plist, and allows for default if the key does not exist.
Parameters
keyThe key for the value to be retrieved.
defaultValueThe default value to be returned when no value is set for the key.
Returns
The value from settings, or withDefault if nil.
Since
2.2

◆ get:withDefault:storageType:

+ (id _Nullable) get:(NSString *_Nonnull) key
withDefault:(id _Nullable) defaultValue
storageType:(bfgSettingsStorageType) storageType 
Gets a settings value for a key from the requested storage type, and allows for default if the key does not exist.
Parameters
keyThe key for the value to be retrieved.
defaultValueThe default value to be returned when no value is set for the key.
storageTypeThe medium on which to persist the values (plist, local keychain, etc.).
Returns
The value from settings, or withDefault if nil.
Since
4.7

◆ isPersistable:storageType:

+ (BOOL) isPersistable: (id _Nullable) value
storageType:(bfgSettingsStorageType) storageType 
Not all objects are serializable. Perform a quick check on a value to determine its eligibility.
Parameters
valueA value we wish to write to the storage medium.
storageTypeThe medium on which to persist the values (plist, local keychain, etc.).
Return values
YESvalue can be written to specified storage type.
NOvalue cannot be written to specified storage type.
Since
4.7

◆ set:value:

+ (void) set: (NSString *_Nonnull) key
value:(id _Nullable) value 
Sets a settings value for a key for the settings plist.
Parameters
keyThe key to write the value to.
valueThe value to write.
Since
2.2

◆ set:value:storageType:

+ (void) set: (NSString *_Nonnull) key
value:(id _Nullable) value
storageType:(bfgSettingsStorageType) storageType 
Sets a settings value for a key for the requested storage type.
Parameters
keyThe key to write the value to.
valueThe value to write.
storageTypeThe medium on which to persist the values (plist, local keychain, etc.).
Since
4.7

◆ write

+ (BOOL) write
Serializes the settings plist to disk.
Returns
Return values
YESif serialization completed successfully.
NOif serialization did not complete.
Since
2.2

◆ writeStorageType:

+ (BOOL) writeStorageType: (bfgSettingsStorageType) storageType
Persists the relevant settings to the requested storage type.
Returns
Return values
YESif serialization completed successfully.
NOif serialization did not complete.
Since
4.7