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.

@property (readonly, nonnull) NSString *sid

Discussion

The unique identifier for this document.

Declared In

TWSDocument.h

  uniqueName

The unique name for this document.

@property (readonly, nullable) NSString *uniqueName

Discussion

The unique name for this document.

Declared In

TWSDocument.h

  dateUpdated

The date when this document was last updated.

@property (readonly, nullable) NSDate *dateUpdated

Discussion

The date when this document was last updated.

Declared In

TWSDocument.h

  data

Obtain a snapshot of the document’s current data.

@property (readonly, nonnull) TWSData *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:

Set time to live for document object in seconds.

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

Parameters

ttl

Time to live in seconds from now or TWSDurationInfinity to indicate no expiry.

completion

Completion block that will specify the result of the operation.

Discussion

Set time to live for document object in seconds.

This TTL specifies the minimum time the Document will live, sometime soon after this time the object will be deleted.

If time to live is not specified, object lives infinitely long.

TTL could be used in order to auto-recycle old unused objects, but it is not recommended to build some app logic like timers using ttl.

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