CBLReadOnlyDictionary
@protocol CBLReadOnlyDictionary <NSObject, CBLReadOnlyDictionaryFragment,
NSFastEnumeration>
CBLReadOnlyDictionary protocol defines a set of methods for readonly accessing dictionary data.
-
The number of entries in the dictionary.
Declaration
Objective-C
@property (readonly, nonatomic) NSUInteger count;
-
An array containing all keys, or an empty array if the dictionary has no entries.
Declaration
Objective-C
@property (readonly, copy, nonatomic) NSArray<NSString *> *_Nonnull keys;
-
Get a property’s value as a CBLReadOnlyArray, which is a mapping object of an array value. Returns nil if the property doesn’t exists, or its value is not an array.
Declaration
Objective-C
- (nullable CBLReadOnlyArray *)arrayForKey:(nonnull NSString *)key;
Parameters
key
The key.
Return Value
The CBLReadOnlyArray object or nil.
-
Get a property’s value as a CBLBlob. Returns nil if the property doesn’t exist, or its value is not a CBLBlob.
Declaration
Objective-C
- (nullable CBLBlob *)blobForKey:(nonnull NSString *)key;
Parameters
key
The key.
Return Value
The CBLBlob object or nil.
-
Gets a property’s value as a boolean. Returns YES if the value exists, and is either
true
or a nonzero number.Declaration
Objective-C
- (BOOL)booleanForKey:(nonnull NSString *)key;
Parameters
key
The key.
Return Value
The boolean value.
-
Gets a property’s value as an NSDate. JSON does not directly support dates, so the actual property value must be a string, which is then parsed according to the ISO-8601 date format (the default used in JSON.) Returns nil if the value doesn’t exist, is not a string, or is not parseable as a date. NOTE: This is not a generic date parser! It only recognizes the ISO-8601 format, with or without milliseconds.
Declaration
Objective-C
- (nullable NSDate *)dateForKey:(nonnull NSString *)key;
Parameters
key
The key.
Return Value
The NSDate object or nil.
-
Get a property’s value as a CBLReadOnlyDictionary, which is a mapping object of a dictionary value. Returns nil if the property doesn’t exists, or its value is not a dictionary.
Declaration
Objective-C
- (nullable CBLReadOnlyDictionary *)dictionaryForKey:(nonnull NSString *)key;
Parameters
key
The key.
Return Value
The CBLReadOnlyDictionary object or nil.
-
Gets a property’s value as a double value. Integers will be converted to double. The value
true
is returned as 1.0,false
as 0.0. Returns 0.0 if the property doesn’t exist or does not have a numeric value.Declaration
Objective-C
- (double)doubleForKey:(nonnull NSString *)key;
Parameters
key
The key.
Return Value
The double value.
-
Gets a property’s value as a float value. Integers will be converted to float. The value
true
is returned as 1.0,false
as 0.0. Returns 0.0 if the property doesn’t exist or does not have a numeric value.Declaration
Objective-C
- (float)floatForKey:(nonnull NSString *)key;
Parameters
key
The key.
Return Value
The float value.
-
Gets a property’s value as an integer value. Floating point values will be rounded. The value
true
is returned as 1,false
as 0. Returns 0 if the property doesn’t exist or does not have a numeric value.Declaration
Objective-C
- (NSInteger)integerForKey:(nonnull NSString *)key;
Parameters
key
The key.
Return Value
The integer value.
-
Gets a property’s value as a long long value. Floating point values will be rounded. The value
true
is returned as 1,false
as 0. Returns 0 if the property doesn’t exist or does not have a numeric value.Declaration
Objective-C
- (long long)longLongForKey:(nonnull NSString *)key;
Parameters
key
The key.
Return Value
The long long value.
-
Gets a property’s value as a number. Returns nil if the property doesn’t exist, or its value is not a number.
Declaration
Objective-C
- (nullable NSNumber *)numberForKey:(nonnull NSString *)key;
Parameters
key
The key.
Return Value
The NSNumber object or nil.
-
Gets a property’s value as an object. The object types are CBLBlob, CBLReadOnlyArray, CBLReadOnlyDictionary, NSNumber, or NSString based on the underlying data type; or nil if the property value is NSNull or the property doesn’t exist.
Declaration
Objective-C
- (nullable id)objectForKey:(nonnull NSString *)key;
Parameters
key
The key.
Return Value
The object value or nil.
-
Gets a property’s value as a string. Returns nil if the property doesn’t exist, or its value is not a string.
Declaration
Objective-C
- (nullable NSString *)stringForKey:(nonnull NSString *)key;
Parameters
key
The key.
Return Value
The NSString object or nil.
-
Tests whether a property exists or not. This can be less expensive than -objectForKey:, because it does not have to allocate an NSObject for the property value.
Declaration
Objective-C
- (BOOL)containsObjectForKey:(nonnull NSString *)key;
Parameters
key
The key.
Return Value
The boolean value representing whether a property exists or not.
-
Gets content of the current object as an NSDictionary. The values contained in the returned NSDictionary object are JSON based values.
Declaration
Objective-C
- (nonnull NSDictionary<NSString *, id> *)toDictionary;
Return Value
The NSDictionary object representing the content of the current object in the JSON format.