ReadOnlyArrayObject
public class ReadOnlyArrayObject: ReadOnlyArrayProtocol
ReadOnlyArrayObject provides readonly access to array data.
-
Gets a number of the items in the array.
Declaration
Swift
public var count: Int
-
Gets value at the given index. The value types are Blob, ReadOnlyArrayObject, ReadOnlyDictionaryObject, Number, or String based on the underlying data type; or nil if the value is nil.
Declaration
Swift
public func value(at index: Int) -> Any?
Parameters
index
the index.
Return Value
the value 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
Swift
public func string(at index: Int) -> String?
Parameters
index
the index.
Return Value
the String value or nil.
-
Gets value at the given index as an integer. Floating point values will be rounded. The value
true
is returned as 1,false
as 0. Returns 0 if the value doesn’t exist or does not have a numeric value.Declaration
Swift
public func int(at index: Int) -> Int
Parameters
index
the index.
Return Value
the Int value.
-
Gets value at the given index 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 value doesn’t exist or does not have a numeric value.Declaration
Swift
public func float(at index: Int) -> Float
Parameters
index
the index.
Return Value
the Float value.
-
Gets value at the given index 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.Declaration
Swift
public func double(at index: Int) -> Double
Parameters
index
the index.
Return Value
the Double value.
-
Gets value at the given index as a boolean. Returns true if the value exists, and is either
true
or a nonzero number.Declaration
Swift
public func boolean(at index: Int) -> Bool
Parameters
index
the index.
Return Value
the Bool value.
-
Get value at the given index as a blob. Returns nil if the value doesn’t exist, or its value is not a blob.
Declaration
Swift
public func blob(at index: Int) -> Blob?
Parameters
index
the index.
Return Value
the Blob object or nil.
-
Gets value at the given index as an Date. 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
Swift
public func date(at index: Int) -> Date?
Parameters
index
the index.
Return Value
the Date object or nil.
-
Gets value as a ReadOnlyArrayObject, 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
Swift
public func array(at index: Int) -> ReadOnlyArrayObject?
Parameters
index
the index.
Return Value
the ReadOnlyArrayObject object or nil.
-
Get value at the given index as a ReadOnlyDictionaryObject, 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
Swift
public func dictionary(at index: Int) -> ReadOnlyDictionaryObject?
Parameters
index
the index.
Return Value
the ReadOnlyDictionaryObject object or nil.
-
Gets content of the current object as an Array object. The values contained in the returned Array object are all JSON based values.
Declaration
Swift
public func toArray() -> Array<Any>
Return Value
the Array object representing the content of the current object in the JSON format.
-
Gets an iterator over items in the array.
Declaration
Swift
public func makeIterator() -> AnyIterator<Any>
Return Value
an array item iterator.
-
Subscript access to a ReadOnlyFragment object by index.
Declaration
Swift
public subscript(index: Int) -> ReadOnlyFragment
Parameters
index
the index.
Return Value
the ReadOnlyFragment object.