DittoMutableDocumentPath

public class DittoMutableDocumentPath: Swift.ExpressibleByStringLiteral,
    Swift.ExpressibleByIntegerLiteral, Swift.ExpressibleByBooleanLiteral,
    Swift.ExpressibleByFloatLiteral, Swift.ExpressibleByDictionaryLiteral,
    Swift.ExpressibleByArrayLiteral, Swift.ExpressibleByNilLiteral

Provides an interface to specify a path to a key in a document that you can then call various update functions on. You obtain a DittoMutableDocumentPath by subscripting a DittoMutableDocument and you can then further subscript a DittoMutbaleDocumentPath to further specify the key of the document that you want to update.

Initialization

  • Used to specify a path to a key in the document that you can subscript further to access a nested key in the document and eventually perform an update operation on.

    Declaration

    Swift

    public subscript(key: String) -> DittoMutableDocumentPath { get set }

    Parameters

    key

    The next part of the path needed to get to the key in the document you wish to update.

    Return Value

    A DittoMutableDocumentPath with the provided key incorporated into the path.

  • Used to specify an index in the array at the preceding key-path specified through the subscripting defined previously. You can subscript the return value further to access a further nested key in the document and eventually perform an update operation.

    Declaration

    Swift

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

    Parameters

    index

    The index of the array that you wish to access in the key previously specified with the preceding subscripting.

    Return Value

    A DittoMutableDocumentPath with the provided index incorporated into the path.

Mutating Functions

  • Set a value at the document’s key defined by the preceding subscripting.

    Declaration

    Swift

    public func set(_ value: Any?, isDefault: Bool = false)

    Parameters

    value

    The value to set at the subscripting-defined document key.

    isDefault

    Represents whether or not the value should be set as a default value. Set this to true if you want to set a default value that you expect to be overwritten by other devices in the network. The default value is false.

  • Remove a value at the document’s key defined by the preceding subscripting. If removing an index from an array, any subsequent indexes will be shifted left to fill the gap.

    Declaration

    Swift

    public func remove()

ExpressibleBy* Conformances

Value accessors

  • Returns the value at the previously specified key in the document as an Any?. It will be nil if no value exists.

    Declaration

    Swift

    public var value: Any? { get }
  • Returns the value at the previously specified key in the document as a String if possible, otherwise the return value will be nil.

    Declaration

    Swift

    public var string: String? { get }
  • Returns the value at the previously specified key in the document as a String. If the key was invalid the return value will be an empty string.

    Declaration

    Swift

    public var stringValue: String { get }
  • Returns the value at the previously specified key in the document as a Bool if possible, otherwise the return value will be nil.

    Declaration

    Swift

    public var bool: Bool? { get }
  • Returns the value at the previously specified key in the document as a String. If the key was invalid the return value will be an empty string.

    Declaration

    Swift

    public var boolValue: Bool { get }
  • int

    Returns the value at the previously specified key in the document as an Int if possible, otherwise the return value will be nil.

    Declaration

    Swift

    public var int: Int? { get }
  • Returns the value at the previously specified key in the document as an Int. If the key was invalid the return value will be 0.

    Declaration

    Swift

    public var intValue: Int { get }
  • Returns the value at the previously specified key in the document as a UInt if possible, otherwise the return value will be nil.

    Declaration

    Swift

    public var uint: UInt? { get }
  • Returns the value at the previously specified key in the document as a UInt. If the key was invalid the return value will be 0.

    Declaration

    Swift

    public var uintValue: UInt { get }
  • Returns the value at the previously specified key in the document as a Float if possible, otherwise the return value will be nil.

    Declaration

    Swift

    public var float: Float? { get }
  • Returns the value at the previously specified key in the document as a Float. If the key was invalid the return value will be 0.

    Declaration

    Swift

    public var floatValue: Float { get }
  • Returns the value at the previously specified key in the document as a Double if possible, otherwise the return value will be nil.

    Declaration

    Swift

    public var double: Double? { get }
  • Returns the value at the previously specified key in the document as a Double. If the key was invalid the return value will be 0.

    Declaration

    Swift

    public var doubleValue: Double { get }
  • Returns the value at the previously specified key in the document as an Array<Any?> if possible, otherwise the return value will be nil.

    Declaration

    Swift

    public var array: [Any?]? { get }
  • Returns the value at the previously specified key in the document as an Array<Any?>. If the key was invalid the return value will be an empty array.

    Declaration

    Swift

    public var arrayValue: [Any?] { get }
  • Returns the value at the previously specified key in the document as a Dictionary<String, Any?> if possible, otherwise the return value will be nil.

    Declaration

    Swift

    public var dictionary: [String : Any?]? { get }
  • Returns the value at the previously specified key in the document as a Dictionary<String, Any?>. If the key was invalid the return value will be an empty dictionary.

    Declaration

    Swift

    public var dictionaryValue: [String : Any?] { get }
  • Returns the value at the previously specified key in the document as a DittoAttachmentToken if possible, otherwise the return value will be nil.

    Declaration

    Swift

    public var attachmentToken: DittoAttachmentToken? { get }
  • Returns the value at the previously specified key in the document as a DittoMutableCounter if possible, otherwise returns nil.

    Declaration

    Swift

    public var counter: DittoMutableCounter? { get }
  • Returns the value at the previously specified key in the document as a DittoMutableRegister if possible, otherwise the return value will be nil.

    Declaration

    Swift

    public var register: DittoMutableRegister? { get }
  • rga

    Returns the value at the previously specified key in the document as a DittoRGA if possible, otherwise the return value will be nil.

    Note that the returned type, DittoRGA, is deprecated and does not allow any mutation. RGAs cannot be created or mutated with this version of the SDK; they can only be read and this is for backwards compatibility reasons.

    Declaration

    Swift

    @available(*, deprecated, message: "DittoRGA usage should be replaced. Use arrays inside DittoRegisters instead")
    public var rga: DittoRGA? { get }