Stores settings to disk automatically so that other libraries can use keys to retrieve them.
More...#import <bfgsettings.h>
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.
◆ canUseStorageType:
+ (BOOL) canUseStorageType: | | (bfgSettingsStorageType) | storageType | |
- Returns
- Is this storage type available for use?
- Return values
YES | Storage type is available for use. |
NO | Storage 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
key | The 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
key | The 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
key | The key for the value to be retrieved. |
type | The 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
key | The key for the value to be retrieved. |
type | The desired object type of the retrieved value. |
storageType | The 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
key | The key for the value to be retrieved. |
type | The desired object type of the retrieved value. |
defaultValue | The 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
key | The key for the value to be retrieved. |
type | The desired object type of the retrieved value. |
defaultValue | The 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. |
storageType | The 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
key | The key for the value to be retrieved. |
type | The desired object type of the retrieved value. |
defaultValue | The 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. |
storageType | The medium on which to persist the value. |
error | The 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
key | The key for the value to be retrieved. |
storageType | The 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
key | The key for the value to be retrieved. |
defaultValue | The 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
key | The key for the value to be retrieved. |
defaultValue | The default value to be returned when no value is set for the key. |
storageType | The 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
value | A value we wish to write to the storage medium. |
storageType | The medium on which to persist the values (plist, local keychain, etc.). |
- Return values
YES | value can be written to specified storage type. |
NO | value 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
key | The key to write the value to. |
value | The 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
key | The key to write the value to. |
value | The value to write. |
storageType | The medium on which to persist the values (plist, local keychain, etc.). |
- Since
- 4.7
◆ write
Serializes the settings plist to disk.
- Returns
- Return values
YES | if serialization completed successfully. |
NO | if serialization did not complete. |
- Since
- 2.2
◆ writeStorageType:
+ (BOOL) writeStorageType: | | (bfgSettingsStorageType) | storageType | |
Persists the relevant settings to the requested storage type.
- Returns
- Return values
YES | if serialization completed successfully. |
NO | if serialization did not complete. |
- Since
- 4.7