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;
-
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. - parameter: key the key. @result the object value or nil.
Declaration
Objective-C
- (nullable id)objectForKey:(nonnull NSString *)key;
Parameters
key
-
Gets a property’s value as a boolean. Returns YES if the value exists, and is either
true
or a nonzero number. - parameter: key the key. @result the boolean value.Declaration
Objective-C
- (BOOL)booleanForKey:(nonnull NSString *)key;
Parameters
key
-
Gets a property’s value as an integer. 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. - parameter: key the key. @result the integer value.Declaration
Objective-C
- (NSInteger)integerForKey:(nonnull NSString *)key;
Parameters
key
-
Gets a property’s value as a float. 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. - parameter: key the key. @result the float value.Declaration
Objective-C
- (float)floatForKey:(nonnull NSString *)key;
Parameters
key
-
Gets a property’s value as a double. 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. - parameter: key the key. @result the double value.Declaration
Objective-C
- (double)doubleForKey:(nonnull NSString *)key;
Parameters
key
-
Gets a property’s value as a string. Returns nil if the property doesn’t exist, or its value is not a string. - parameter: key the key. @result the NSString object or nil.
Declaration
Objective-C
- (nullable NSString *)stringForKey:(nonnull NSString *)key;
Parameters
key
-
Gets a property’s value as a number. Returns nil if the property doesn’t exist, or its value is not a number. - parameter: key the key. @result the NSNumber object or nil.
Declaration
Objective-C
- (nullable NSNumber *)numberForKey:(nonnull NSString *)key;
Parameters
key
-
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. - parameter: key the key. @result the NSDate object or nil.
Declaration
Objective-C
- (nullable NSDate *)dateForKey:(nonnull NSString *)key;
Parameters
key
-
Get a property’s value as a CBLBlob. Returns nil if the property doesn’t exist, or its value is not a CBLBlob. - parameter: key the key. @result the CBLBlob object or nil.
Declaration
Objective-C
- (nullable CBLBlob *)blobForKey:(nonnull NSString *)key;
Parameters
key
-
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. - parameter: key the key. @result the CBLReadOnlyDictionary object or nil.
Declaration
Objective-C
- (nullable CBLReadOnlyDictionary *)dictionaryForKey:(nonnull NSString *)key;
Parameters
key
-
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. - parameter: key the key. @result the CBLReadOnlyArray object or nil.
Declaration
Objective-C
- (nullable CBLReadOnlyArray *)arrayForKey:(nonnull NSString *)key;
Parameters
key
-
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. - parameter: key the key. @result the boolean value representing whether a property exists or not.
Declaration
Objective-C
- (BOOL)containsObjectForKey:(nonnull NSString *)key;
Parameters
key
-
Gets content of the current object as an NSDictionary. The values contained in the returned NSDictionary object are JSON based values. @result the NSDictionary object representing the content of the current object in the JSON format.
Declaration
Objective-C
- (nonnull NSDictionary<NSString *, id> *)toDictionary;