![]() |
Couchbase Lite
Objective-C API for iOS and Mac OS
|
CBLProperties defines a JSON-compatible object, much like an NSMutableDictionary but with type-safe accessors.
It is implemented by classes CBLDocument and (soon) CBLSubdocument.
Instance Methods | |
(nullable id) | - objectForKey: |
Gets an property's value as an object. More... | |
(BOOL) | - booleanForKey: |
Gets a property's value as a boolean. More... | |
(NSInteger) | - integerForKey: |
Gets a property's value as an integer. More... | |
(float) | - floatForKey: |
Gets a property's value as a float. More... | |
(double) | - doubleForKey: |
Gets a property's value as a double. More... | |
(nullable NSString *) | - stringForKey: |
Gets a property's value as a string. More... | |
(nullable NSDate *) | - dateForKey: |
Gets a property's value as an NSDate. More... | |
(void) | - setObject:forKey: |
Sets a property value by key. More... | |
(void) | - setBoolean:forKey: |
Sets a boolean value by key. More... | |
(void) | - setInteger:forKey: |
Sets an integer value by key. More... | |
(void) | - setFloat:forKey: |
Sets a float value by key. More... | |
(void) | - setDouble:forKey: |
Sets a double value by key. More... | |
(nullable id) | - objectForKeyedSubscript: |
Same as objectForKey:. More... | |
(void) | - setObject:forKeyedSubscript: |
Same as setObject:forKey:. More... | |
(void) | - removeObjectForKey: |
Removes a property by key. More... | |
(BOOL) | - containsObjectForKey: |
Tests whether a property exists or not. More... | |
Properties | |
NSDictionary * | properties |
All of the properties contained in this object. More... | |
- (nullable id) objectForKey: | (NSString *) | key |
Gets an property's value as an object.
Returns types NSNull, NSNumber, NSString, NSArray, NSDictionary, and CBLBlob, based on the underlying data type; or nil if the property doesn't exist.
- (BOOL) booleanForKey: | (NSString *) | key |
Gets a property's value as a boolean.
Returns YES if the value exists, and is either true
or a nonzero number.
- (NSInteger) integerForKey: | (NSString *) | 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.
- (float) floatForKey: | (NSString *) | 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.
- (double) doubleForKey: | (NSString *) | 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.
- (nullable NSString*) stringForKey: | (NSString *) | key |
Gets a property's value as a string.
Returns nil if the property doesn't exist, or its value is not a string.
- (nullable NSDate*) dateForKey: | (NSString *) | 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.
- (void) setObject: | (nullable id) | value | |
forKey: | (NSString *) | key | |
Sets a property value by key.
Allowed value types are NSNull, NSNumber, NSString, NSArray, NSDictionary, NSDate, and CBLBlob. (An NSDate object will be converted to an ISO-8601 format string.) NSArrays and NSDictionaries must contain only the above types. Setting a nil value will remove the property.
- (void) setBoolean: | (BOOL) | value | |
forKey: | (NSString *) | key | |
Sets a boolean value by key.
- (void) setInteger: | (NSInteger) | value | |
forKey: | (NSString *) | key | |
Sets an integer value by key.
- (void) setFloat: | (float) | value | |
forKey: | (NSString *) | key | |
Sets a float value by key.
- (void) setDouble: | (double) | value | |
forKey: | (NSString *) | key | |
Sets a double value by key.
- (nullable id) objectForKeyedSubscript: | (NSString *) | key |
- (void) setObject: | (nullable id) | value | |
forKeyedSubscript: | (NSString *) | key | |
- (void) removeObjectForKey: | (NSString *) | key |
Removes a property by key.
This is the same as setting its value to nil.
- (BOOL) containsObjectForKey: | (NSString *) | 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.
|
readwritenonatomicassign |
All of the properties contained in this object.