CBLArray
@protocol CBLArray <NSObject, CBLArrayFragment, NSFastEnumeration>
CBLArray protocol defines a set of methods for reading array data.
-
Gets a number of the items in the array.
Declaration
Objective-C
@property (readonly, atomic) NSUInteger count; -
Gets value as a CBLArray, which is a mapping object of an array value. Returns nil if the value doesn’t exists, or its value is not an array.
Declaration
Objective-C
- (nullable CBLArray *)arrayAtIndex:(NSUInteger)index;Parameters
indexThe index.
Return Value
The CBLArray object or nil.
-
Get value at the given index as a CBLBlob. Returns nil if the value doesn’t exist, or its value is not a CBLBlob.
Declaration
Objective-C
- (nullable CBLBlob *)blobAtIndex:(NSUInteger)index;Parameters
indexThe index.
Return Value
The CBLBlob object or nil.
-
Gets value at the given index as a boolean. Returns YES if the value exists, and is either
trueor a nonzero number.Declaration
Objective-C
- (BOOL)booleanAtIndex:(NSUInteger)index;Parameters
indexThe index.
Return Value
The boolean value.
-
Gets value at the given index 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 *)dateAtIndex:(NSUInteger)index;Parameters
indexThe index.
Return Value
The NSDate object or nil.
-
Get value at the given index as a CBLDictionary, which is a mapping object of a dictionary value. Returns nil if the value doesn’t exists, or its value is not a dictionary.
Declaration
Objective-C
- (nullable CBLDictionary *)dictionaryAtIndex:(NSUInteger)index;Parameters
indexThe index.
Return Value
The CBLDictionary object or nil.
-
Gets value at the given index as a float value. Integers will be converted to float. The value
trueis returned as 1.0,falseas 0.0. Returns 0.0 if the value doesn’t exist or does not have a numeric value.Declaration
Objective-C
- (float)floatAtIndex:(NSUInteger)index;Parameters
indexThe index.
Return Value
The float value.
-
Gets value at the given index as a double value. Integers will be converted to double. The value
trueis returned as 1.0,falseas 0.0. Returns 0.0 if the property doesn’t exist or does not have a numeric value.Declaration
Objective-C
- (double)doubleAtIndex:(NSUInteger)index;Parameters
indexThe index.
Return Value
The double value.
-
Gets value at the given index as an integer value. Floating point values will be rounded. The value
trueis returned as 1,falseas 0. Returns 0 if the value doesn’t exist or does not have a numeric value.Declaration
Objective-C
- (NSInteger)integerAtIndex:(NSUInteger)index;Parameters
indexThe index.
Return Value
The integer value.
-
Gets value at the given index as a long long value. Floating point values will be rounded. The value
trueis returned as 1,falseas 0. Returns 0 if the value doesn’t exist or does not have a numeric value.Declaration
Objective-C
- (long long)longLongAtIndex:(NSUInteger)index;Parameters
indexThe index.
Return Value
The long long value.
-
Gets value at the given index as a number. Returns nil if the value doesn’t exist, or its value is not a number.
Declaration
Objective-C
- (nullable NSNumber *)numberAtIndex:(NSUInteger)index;Parameters
indexThe index.
Return Value
The NSNumber object or nil.
-
Gets value at the given index as an object. The object types are CBLBlob, CBLArray, CBLDictionary, NSNumber, or NSString based on the underlying data type; or nil if the value is nil.
Declaration
Objective-C
- (nullable id)objectAtIndex:(NSUInteger)index;Parameters
indexThe index.
Return Value
The object or nil.
-
Gets value at the given index as a string. Returns nil if the value doesn’t exist, or its value is not a string.
Declaration
Objective-C
- (nullable NSString *)stringAtIndex:(NSUInteger)index;Parameters
indexThe index.
Return Value
The NSString object or nil.
-
Gets content of the current object as an NSArray. The values contained in the returned NSArray object are all JSON based values.
Declaration
Objective-C
- (nonnull NSArray *)toArray;Return Value
The NSArray object representing the content of the current object in the JSON format.
CBLArray Protocol Reference