ArrayObject

public class ArrayObject : ArrayProtocol, Equatable, Hashable, Sequence

ArrayObject provides readonly access to array data.

  • Gets a number of the items in the array.

    Declaration

    Swift

    public var count: Int { get }
  • Gets the value at the given index. The value types are Blob, ArrayObject, DictionaryObject, Number, String, or NSNull based on the underlying data type.

    Declaration

    Swift

    public func value(at index: Int) -> Any?

    Parameters

    index

    The index.

    Return Value

    The value located at the index.

  • Gets the 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 object.

  • Gets value at the given index as a Number value.

    Declaration

    Swift

    public func number(at index: Int) -> NSNumber?

    Parameters

    index

    The index.

    Return Value

    The number value located at the index.

  • Gets value at the given index as an int value. 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 located at the index.

  • Gets value at the given index as an int64 value. 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 int64(at index: Int) -> Int64

    Parameters

    index

    The index.

    Return Value

    The int64 value located at the index.

  • Gets the value at the given index 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 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 located at the index.

  • Gets the value at the given index 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

    Swift

    public func double(at index: Int) -> Double

    Parameters

    index

    The index.

    Return Value

    The Double value located at the index.

  • Gets the value at the given index as a boolean value. 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 located at the index.

  • 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 value at the given index.

  • Get the Blob value at the given index. 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 value located at the index.

  • Gets the value at the given index as a ArrayObject value, 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) -> ArrayObject?

    Parameters

    index

    The index.

    Return Value

    The ArrayObject at the given index.

  • Get the value at the given index as a DictionaryObject value, 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) -> DictionaryObject?

    Parameters

    index

    The index.

    Return Value

    The DictionaryObject

  • Gets content of the current object as an Array. The value types of the values contained in the returned Array object are Array, Blob, Dictionary, Number types, NSNull, and String.

    Declaration

    Swift

    public func toArray() -> Array<Any>

    Return Value

    The Array representing the content of the current object.

Edit

  • Returns a mutable copy of the array object.

    Declaration

    Swift

    public func toMutable() -> MutableArrayObject

    Return Value

    The MutableDocument object.

Sequence

  • Gets an iterator over items in the array.

    Declaration

    Swift

    public func makeIterator() -> AnyIterator<Any>

    Return Value

    The array item iterator.

Subscript

  • Subscript access to a Fragment object by index

    Declaration

    Swift

    public subscript(index: Int) -> Fragment { get }

    Parameters

    index

    The Index.

Equality

  • Equal to operator for comparing two Array objects.

    Declaration

    Swift

    public static func == (array1: ArrayObject, array2: ArrayObject) -> Bool

Hashable

  • Declaration

    Swift

    public func hash(into hasher: inout Hasher)
  • Return array data as JSON String

    Declaration

    Swift

    public func toJSON() -> String