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.
-
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.
-
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 isfalse
. -
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()
-
Replace a value at the document’s key defined by the preceding subscripting with a counter.
Declaration
Swift
public func replaceWithCounter(isDefault: Bool = false)
Parameters
isDefault
Represents whether or not the value is being replaced with a counter that should serve 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 isfalse
. -
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.
Declaration
Swift
public func increment(amount: Double)
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.
Declaration
Swift
public func push(_ value: Any?)
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.
Declaration
Swift
@discardableResult public func pop() -> Any?
Return Value
The value popped off from the end of the array.
-
Inserts a value into an array at the index defined by the preceding subscripting. This will only succeed if the value at the subscripting-defined key is an index into an array.
Declaration
Swift
public func insert(_ value: Any?)
Parameters
value
The value to insert into the array.
-
Returns the value at the previously specified key in the document as an
Any?
. It will benil
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 benil
.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 benil
.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 }
-
Returns the value at the previously specified key in the document as an
Int
if possible, otherwise the return value will benil
.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 benil
.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 benil
.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 benil
.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 benil
.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 benil
.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 benil
.Declaration
Swift
public var attachmentToken: DittoAttachmentToken? { get }
-
Declaration
Swift
public required init(stringLiteral value: StringLiteralType)
-
Declaration
Swift
public required init(extendedGraphemeClusterLiteral value: StringLiteralType)
-
Declaration
Swift
public required init(unicodeScalarLiteral value: StringLiteralType)
-
Declaration
Swift
public required init(integerLiteral value: IntegerLiteralType)
-
Declaration
Swift
public required init(booleanLiteral value: BooleanLiteralType)
-
Declaration
Swift
public required init(floatLiteral value: FloatLiteralType)
-
Declaration
Swift
public required init(dictionaryLiteral elements: (String, Any)...)
-
Declaration
Swift
public required init(arrayLiteral elements: Any...)
-
Declaration
Swift
public required init(nilLiteral: ())