DictionaryObject

public class DictionaryObject: ReadOnlyDictionaryObject, DictionaryProtocol

DictionaryObject provides access to dictionary data.

  • Initialize a new empty CBLDictionary object.

    Declaration

    Swift

    public init()
  • Initialzes a new DictionaryObject object with dictionary content. Allowed value types are Array, Date, Dictionary, Number, NSNull, String, ArrayObject, Blob, DictionaryObject. The Arrays and Dictionaries must contain only the above types.

    Declaration

    Swift

    public init(dictionary: Dictionary<String, Any>?)

    Parameters

    dictionary

    the dictionary object.

  • Set a value for the given key. Allowed value types are Array, Date, Dictionary, Number types, NSNull, String, ArrayObject, Blob, DictionaryObject and nil. The Arrays and Dictionaries must contain only the above types. A nil value will be converted to an NSNull. An Date object will be converted to an ISO-8601 format string.

    Declaration

    Swift

    @discardableResult public func setValue(_ value: Any?, forKey key: String) -> Self

    Parameters

    value

    The value.

    key

    The key.

    Return Value

    The DictionaryObject object.

  • Set a dictionary as a content. Allowed value types are Array, Date, Dictionary, Number types, NSNull, String, ArrayObject, Blob, DictionaryObject. The Arrays and Dictionaries must contain only the above types. Setting the new dictionary content will replace the current data including the existing ArrayObject and DictionaryObject objects.

    Declaration

    Swift

    @discardableResult public func setDictionary(_ dictionary: Dictionary<String, Any>?) -> Self

    Parameters

    dictionary

    The dictionary.

    Return Value

    The DictionaryObject object.

  • Removes a given key and its value from the dictionary.

    Declaration

    Swift

    @discardableResult public func remove(forKey key: String) -> Self

    Parameters

    key

    The key.

    Return Value

    The DictionaryObject object.

  • Get a property’s value as an ArrayObject, which is a mapping object of an array value. Returns nil if the property doesn’t exists, or its value is not an array.

    Declaration

    Swift

    public override func array(forKey key: String) -> ArrayObject?

    Parameters

    key

    The key.

    Return Value

    The ArrayObject object or nil if the property doesn’t exist.

  • Get a property’s value as a DictionaryObject, which is a mapping object of a dictionary value. Returns nil if the property doesn’t exists, or its value is not a dictionary.

    Declaration

    Swift

    public override func dictionary(forKey key: String) -> DictionaryObject?

    Parameters

    key

    The key.

    Return Value

    The DictionaryObject object.

  • Subscripting access to a Fragment object that represents the value of the dictionary by key.

    Declaration

    Swift

    public override subscript(key: String) -> Fragment

    Parameters

    key

    The key.

    Return Value

    The Fragment object.