DittoMutableDocumentPath

@objcMembers
@objc
public class DittoMutableDocumentPath : NSObject

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.

  • 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

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

    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

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

    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.

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

    Throws

    DittoKitError

    Declaration

    Swift

    @objc
    public func set(_ value: Any, isDefault: Bool = false) throws

    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.

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

    Throws

    DittoKitError

    Declaration

    Swift

    @objc
    public func remove() throws
  • Replace a value at the document’s key defined by the preceding subscripting with a counter.

    Throws

    DittoKitError

    Declaration

    Swift

    @objc
    public func replaceWithCounter(isDefault: Bool = false) throws

    Parameters

    isDefault

    Represents whether or not the value is being replaced with a counter that should serve as a default value.

  • Increment a counter at the document’s key defined by the preceding subscripting. This will only succeed if the value at the subscripting-defined key is a counter.

    Throws

    DittoKitError

    Declaration

    Swift

    @objc
    public func increment(amount: Double) throws

    Parameters

    amount

    The amount to increment the counter by. This can be a positive or a negative value.

  • Push a value on to the end of an array at the document’s key defined by the preceding subscripting. This will only succeed if the value at the subscripting-defined key is an array.

    Throws

    DittoKitError

    Declaration

    Swift

    @objc
    public func push(_ value: Any) throws

    Parameters

    value

    The value to push on to the array.

  • Pop a value off the end of an array at the document’s key defined by the preceding subscripting. This will only succeed if the value at the subscripting-defined key is an array.

    Throws

    DittoKitError

    Declaration

    Swift

    @discardableResult
    public func pop() throws -> Any?

    Return Value

    The value popped off from the end of the array.

  • Replace the text at the document’s key defined by the preceding subscripting. This will only succeed if the value at the subscripting-defined key is a string value.

    Throws

    DittoKitError

    Declaration

    Swift

    @objc
    public func replaceText(index: UInt, length: UInt, newText: String) throws

    Parameters

    index

    The character index in the existing string that you want the update to start from.

    length

    The number of characters that you want to replace as part of the operation.

    newText

    The new text to be added to the existing string.

  • 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

    @objc
    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

    @objc
    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

    @objc
    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

    @objc
    public var intValue: Int { 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

    @objc
    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

    @objc
    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 an Array<Any> if possible, otherwise the return value will be nil.

    Declaration

    Swift

    @objc
    public var arrayObjC: [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

    @objc
    public var dictionaryObjC: [String : Any]? { get }