TWSDocument Class Reference

Inherits from NSObject
Declared in TWSDocument.h

Overview

A document is the simplest Sync primitive that encapsulates a single JSON encoded object.

– sid

The unique identifier for this document.

- (nonnull NSString *)sid

Return Value

The identifier.

Discussion

The unique identifier for this document.

Declared In

TWSDocument.h

– uniqueName

The unique name for this document.

- (nullable NSString *)uniqueName

Return Value

The unique name.

Discussion

The unique name for this document.

Declared In

TWSDocument.h

– getData

Obtain a snapshot of the document’s current data.

- (nonnull TWSData *)getData

Return Value

NSDictionary containing the data.

Discussion

Obtain a snapshot of the document’s current data.

Declared In

TWSDocument.h

– setData:metadata:completion:

Update the value of the document’s data.

- (void)setData:(nonnull TWSData *)data metadata:(nullable TWSDocumentMetadata *)objectMetadata completion:(nullable TWSDataCompletion)completion

Parameters

data

The new data.

objectMetadata

Optional metadata for the updated document, currently only ttl.

completion

Completion block that will specify the result of the operation and the updated value of the data.

Discussion

Update the value of the document’s data.

Declared In

TWSDocument.h

– mutateDataWith:metadata:completion:

Modify the Document’s data in a conflict-friendly way.

- (void)mutateDataWith:(nonnull TWSDataMutator)mutator metadata:(nullable TWSDocumentMetadata *)objectMetadata completion:(nullable TWSDataCompletion)completion

Parameters

mutator

The mutator that you provide to modify the data passed in.

objectMetadata

Optional metadata for the updated document, currently only ttl.

completion

Completion block that will specify the result of the operation and the updated value of the data.

Discussion

Modify the Document’s data in a conflict-friendly way.

Declared In

TWSDocument.h

– setTtl:completion:

Update the document’s time to live.

- (void)setTtl:(TWSDuration)ttl completion:(nullable TWSCompletion)completion

Parameters

ttl

The new time to live for this document in seconds from now or TWSDurationInfinity to indicate no expiry.

completion

Completion block that will specify the result of the operation.

Discussion

Update the document’s time to live.

Declared In

TWSDocument.h

– removeDocumentWithCompletion:

Remove the document from the system, deleting it.

- (void)removeDocumentWithCompletion:(nullable TWSCompletion)completion

Parameters

completion

Completion block that will specify the result of the operation.

Discussion

Remove the document from the system, deleting it.

Declared In

TWSDocument.h