Inherits from TICDSOperation : NSOperation
Declared in TICDSSynchronizationOperation.h

Overview

The TICDSSynchronizationOperation class describes a generic operation used by the TICoreDataSync framework to synchronize changes made to a document.

In brief, a synchronization operation pulls down remote sync commands and changes, applies them locally (fixing any conflicts if necessary), and then pushes out the local set of unsynchronized sync changes.

In full, the operation carries out the following tasks: (Sync Command tasks are included below, although not yet implemented)

  1. Fetch an array containing UUID strings for each client device that has synchronized this document.
  2. For each client device that isn’t the current device:
    1. Fetch an array containing UUID strings for each available SyncCommandSet.
  3. Determine which SyncCommandSets haven’t yet been applied locally.
  4. If any SyncCommandSets haven’t yet been applied, fetch them to the UnappliedSyncCommandSets helper file directory.
  5. Go through each SyncCommandSet and:
    1. Carry out the command, determining whether synchronization can continue, or whether e.g. the entire store needs to be downloaded.
    2. Add the UUID of the set to the list of AppliedSyncCommands.ticdsync.
  6. If synchronization can continue, then for each client device that isn’t the current device:
    1. Fetch an array containing UUID strings for each available SyncChangeSet.
    2. Determine which SyncChangeSets haven’t yet been applied locally.
    3. If any SyncChangeSets haven’t yet been applied, fetch them to the UnappliedSyncChangeSets helper file directory.
  7. Go through each SyncChangeSet and:
    1. Check for conflicts against local changes made since the last synchronization.
    2. Fix any conflicts, and build an array of conflict warnings for issues that cannot be resolved.
    3. Apply each SyncChange in the set to the local WholeStore.
    4. Add the UUID of the set to the list of AppliedSyncChangeSets.ticdsync.
  8. If there are local SyncCommands, rename UnsynchronizedSyncCommands.ticdsync to UUID.synccmd and push the file to the remote.
  9. If there are local SyncChanges, rename UnsynchronizedSyncChanges.syncchg to UUID.syncchd and push the file to the remote.
  10. Save this client’s file in the RecentSyncs directory for this document.

Operations are typically created automatically by the relevant sync manager.

You must use one of the subclasses of TICDSSynchronizationOperation.

Tasks

Designated Initializer

Methods Overridden by Subclasses

Callbacks

Properties

File Locations

Managed Object Contexts and Factories

Completion

Properties

appliedSyncChangeSetsContext

The managed object context for the AppliedSyncChangeSets.ticdsync file.

@property (nonatomic, retain) NSManagedObjectContext *appliedSyncChangeSetsContext

Declared In

TICDSSynchronizationOperation.h

appliedSyncChangeSetsCoreDataFactory

A TICoreDataFactory to access the contents of the AppliedSyncChangeSets.ticdsync file.

@property (nonatomic, retain) TICoreDataFactory *appliedSyncChangeSetsCoreDataFactory

Declared In

TICDSSynchronizationOperation.h

appliedSyncChangeSetsFileLocation

The location of this document’s AppliedSyncChangeSets.ticdsync file.

@property (retain) NSURL *appliedSyncChangeSetsFileLocation

Declared In

TICDSSynchronizationOperation.h

backgroundApplicationContext

The managed object context (tied to the application’s persistent store coordinator) in which SyncChanges are applied.

@property (nonatomic, retain) NSManagedObjectContext *backgroundApplicationContext

Declared In

TICDSSynchronizationOperation.h

integrityKey

The integrity key provided either by the client to check existing data matches integrity, or set during registration for new documents.

@property (retain) NSString *integrityKey

Declared In

TICDSSynchronizationOperation.h

localRecentSyncFileLocation

The location of the local RecentSync file to upload at the end of the synchronization process.

@property (retain) NSURL *localRecentSyncFileLocation

Declared In

TICDSSynchronizationOperation.h

localSyncChangesToMergeContext

The managed object context for the local, unsynchronized set of SyncChanges.

@property (nonatomic, retain) NSManagedObjectContext *localSyncChangesToMergeContext

Declared In

TICDSSynchronizationOperation.h

localSyncChangesToMergeCoreDataFactory

A TICoreDataFactory to access the contents of the local, unsynchronized set of SyncChanges.

@property (nonatomic, retain) TICoreDataFactory *localSyncChangesToMergeCoreDataFactory

Declared In

TICDSSynchronizationOperation.h

localSyncChangesToMergeLocation

The location of the SyncChangesBeingSynchronized.syncchg file for this synchronization operation.

@property (retain) NSURL *localSyncChangesToMergeLocation

Declared In

TICDSSynchronizationOperation.h

mostRecentConflictResolutionType

The resolution type for the most recent conflict, set before resuming the operation after a conflict is detected.

@property (assign) TICDSSyncConflictResolutionType mostRecentConflictResolutionType

Declared In

TICDSSynchronizationOperation.h

numberOfSyncChangeSetIDArraysFetched

The number of arrays of SyncChangeSet identifiers that have already been fetched.

@property (nonatomic, assign) NSUInteger numberOfSyncChangeSetIDArraysFetched

Declared In

TICDSSynchronizationOperation.h

numberOfSyncChangeSetIDArraysThatFailedToFetch

The number of arrays of SyncChangeSet identifiers that failed to fetch because of an error.

@property (nonatomic, assign) NSUInteger numberOfSyncChangeSetIDArraysThatFailedToFetch

Declared In

TICDSSynchronizationOperation.h

numberOfSyncChangeSetIDArraysToFetch

The total number of arrays of SyncChangeSet identifiers that need to be fetched.

@property (nonatomic, assign) NSUInteger numberOfSyncChangeSetIDArraysToFetch

Declared In

TICDSSynchronizationOperation.h

numberOfUnappliedSyncChangeSetsFetched

The number of unapplied sync change sets that have already been fetched.

@property (nonatomic, assign) NSUInteger numberOfUnappliedSyncChangeSetsFetched

Declared In

TICDSSynchronizationOperation.h

numberOfUnappliedSyncChangeSetsThatFailedToFetch

The number of unapplied sync change sets that failed to fetch because of an error.

@property (nonatomic, assign) NSUInteger numberOfUnappliedSyncChangeSetsThatFailedToFetch

Declared In

TICDSSynchronizationOperation.h

numberOfUnappliedSyncChangeSetsToFetch

The number of unapplied sync change sets that need to be fetched.

@property (nonatomic, assign) NSUInteger numberOfUnappliedSyncChangeSetsToFetch

Declared In

TICDSSynchronizationOperation.h

otherSynchronizedClientDeviceIdentifiers

An array of client identifiers for clients that synchronize with this document, excluding this client.

@property (nonatomic, retain) NSArray *otherSynchronizedClientDeviceIdentifiers

Declared In

TICDSSynchronizationOperation.h

otherSynchronizedClientDeviceSyncChangeSetIdentifiers

A dictionary of arrays; keys are client identifiers, values are sync change set identifiers for each of those clients.

@property (retain) NSMutableDictionary *otherSynchronizedClientDeviceSyncChangeSetIdentifiers

Declared In

TICDSSynchronizationOperation.h

paused

A boolean indicating whether the operation is currently paused awaiting an instruction to continue, e.g. for conflict resolution.

@property (assign, getter=isPaused) BOOL paused

Declared In

TICDSSynchronizationOperation.h

primaryPersistentStoreCoordinator

The persistent store coordinator for the application – used to create a background application context, when needed.

@property (retain) NSPersistentStoreCoordinator *primaryPersistentStoreCoordinator

Declared In

TICDSSynchronizationOperation.h

syncChangeSortDescriptors

The sort descriptors used to sort sync change objects in a SyncChangeSet before being applied.

@property (nonatomic, retain) NSArray *syncChangeSortDescriptors

Declared In

TICDSSynchronizationOperation.h

synchronizationWarnings

The warnings generated during this synchronization.

@property (retain) NSMutableArray *synchronizationWarnings

Declared In

TICDSSynchronizationOperation.h

unappliedSyncChangeSetsContext

The managed object context for the UnappliedSyncChangeSets.ticdsync file.

@property (nonatomic, retain) NSManagedObjectContext *unappliedSyncChangeSetsContext

Declared In

TICDSSynchronizationOperation.h

unappliedSyncChangeSetsCoreDataFactory

A TICoreDataFactory to access the contents of the UnappliedSyncChangeSets.ticdsync file.

@property (nonatomic, retain) TICoreDataFactory *unappliedSyncChangeSetsCoreDataFactory

Declared In

TICDSSynchronizationOperation.h

unappliedSyncChangeSetsFileLocation

The location of this document’s UnappliedSyncChangeSets.ticdsync file.

@property (retain) NSURL *unappliedSyncChangeSetsFileLocation

Declared In

TICDSSynchronizationOperation.h

unappliedSyncChangesContext

The managed object context for the changes in a single, unapplied SyncChangeSet file.

@property (nonatomic, retain) NSManagedObjectContext *unappliedSyncChangesContext

Declared In

TICDSSynchronizationOperation.h

unappliedSyncChangesCoreDataFactory

A TICoreDataFactory to access the contents of a single, unapplied SyncChangeSet file.

@property (nonatomic, retain) TICoreDataFactory *unappliedSyncChangesCoreDataFactory

Declared In

TICDSSynchronizationOperation.h

unappliedSyncChangesDirectoryLocation

The location of the UnappliedSyncChanges directory for this synchronization operation.

@property (retain) NSURL *unappliedSyncChangesDirectoryLocation

Declared In

TICDSSynchronizationOperation.h

Instance Methods

buildArrayOfClientDeviceIdentifiers

Build an array of NSString identifiers for all clients that have synchronized with this document.

- (void)buildArrayOfClientDeviceIdentifiers

Discussion

Call builtArrayOfClientDeviceIdentifiers: when the array is built.

Declared In

TICDSSynchronizationOperation.h

buildArrayOfSyncChangeSetIdentifiersForClientIdentifier:

Build an array of NSString identifiers for each SyncChangeSet for the given client device.

- (void)buildArrayOfSyncChangeSetIdentifiersForClientIdentifier:(NSString *)anIdentifier

Parameters

anIdentifier

The unique identifier of the client.

Discussion

Call builtArrayOfClientSyncChangeSetIdentifiers:forClientIdentifier: when the array is built.

Declared In

TICDSSynchronizationOperation.h

builtArrayOfClientDeviceIdentifiers:

Pass back the assembled NSArray of NSString ClientDevice identifiers.

- (void)builtArrayOfClientDeviceIdentifiers:(NSArray *)anArray

Parameters

anArray

The array of identifiers. Pass nil if an error occurred.

Discussion

If an error occurred, call setError: first, then specify nil for anArray.

Declared In

TICDSSynchronizationOperation.h

builtArrayOfClientSyncChangeSetIdentifiers:forClientIdentifier:

Pass back the assembled NSArray of NSString SyncChangeSet identifiers.

- (void)builtArrayOfClientSyncChangeSetIdentifiers:(NSArray *)anArray forClientIdentifier:(NSString *)anIdentifier

Parameters

anArray

The array of identifiers. Pass nil if an error occurred.

anIdentifier

The client identifier for this array of SyncChangeSet identifiers.

Discussion

If an error occured, call setError: first, then specify nil for anArray.

Declared In

TICDSSynchronizationOperation.h

configureBackgroundApplicationContextForPersistentStoreCoordinator:

Configure a background context (for applying sync changes) using the same persistent store coordinator as the main application context.

- (void)configureBackgroundApplicationContextForPersistentStoreCoordinator:(NSPersistentStoreCoordinator *)aPersistentStoreCoordinator

Parameters

aPersistentStoreCoordinator

The persistent store coordinator to use for the background context.

Declared In

TICDSSynchronizationOperation.h

contextForSyncChangesInUnappliedSyncChangeSet:

Releases any existing unappliedSyncChangesContext and unappliedSyncChangesCoreDataFactory and sets new ones, linked to the set of sync changes specified in the given sync change set.

- (NSManagedObjectContext *)contextForSyncChangesInUnappliedSyncChangeSet:(TICDSSyncChangeSet *)aChangeSet

Parameters

aChangeSet

The TICDSSyncChangeSet object specifying the set of changes to use.

Return Value

A managed object context to access the sync changes.

Declared In

TICDSSynchronizationOperation.h

fetchRemoteIntegrityKey

Fetch the integrity key for this document.

- (void)fetchRemoteIntegrityKey

Discussion

This method must call fetchedRemoteIntegrityKey: to provide the key.

Declared In

TICDSSynchronizationOperation.h

fetchSyncChangeSetWithIdentifier:forClientIdentifier:toLocation:

Fetch a SyncChangeSet with a given identifier from a client’s SyncChanges directory.

- (void)fetchSyncChangeSetWithIdentifier:(NSString *)aChangeSetIdentifier forClientIdentifier:(NSString *)aClientIdentifier toLocation:(NSURL *)aLocation

Parameters

aChangeSetIdentifier

The identifier of the sync change set to fetch.

aClientIdentifier

The identifier of the client who created the sync change set.

aLocation

The location of the file to upload.

Discussion

This method must call fetchedSyncChangeSetsWithIdentifier:forClientIdentifier:withSuccess: when finished.

Declared In

TICDSSynchronizationOperation.h

fetchedRemoteIntegrityKey:

Pass back the remote integrity key for this document.

- (void)fetchedRemoteIntegrityKey:(NSString *)aKey

Parameters

aKey

The remote integrity key, or nil if an error occurred.

Discussion

If an error occurred, call setError: first, then specify nil for aKey.

Declared In

TICDSSynchronizationOperation.h

fetchedSyncChangeSetWithIdentifier:forClientIdentifier:modificationDate:withSuccess:

Indicate whether the download of the specified SyncChangeSet was successful.

- (void)fetchedSyncChangeSetWithIdentifier:(NSString *)aChangeSetIdentifier forClientIdentifier:(NSString *)aClientIdentifier modificationDate:(NSDate *)aDate withSuccess:(BOOL)success

Parameters

aChangeSetIdentifier

The identifier for the change set to fetch.

aClientIdentifier

The identifier of the client who uploaded the change set.

aDate

The modification date of the change set.

success

A Boolean indicating whether the sync change set file was downloaded or not.

Discussion

If not, call setError: first, then specify NO for success.

If it was successful, you should supply the original modification date of the file.

Declared In

TICDSSynchronizationOperation.h

initWithDelegate:

Initialize a synchronization operation using a delegate that supports the TICDSSynchronizationOperationDelegate protocol.

- (id)initWithDelegate:(NSObject<TICDSSynchronizationOperationDelegate> *)aDelegate

Parameters

aDelegate

The delegate to use for this operation.

Return Value

An initialized synchronization operation.

Declared In

TICDSSynchronizationOperation.h

uploadLocalSyncChangeSetFileAtLocation:

Upload the specified sync changes file to the client device’s directory inside the document’s SyncChanges directory.

- (void)uploadLocalSyncChangeSetFileAtLocation:(NSURL *)aLocation

Parameters

aLocation

The location of the file to upload.

Discussion

This method must call uploadedLocalSyncChangeSetFileSuccessfully: to indicate whether the creation was successful.

Declared In

TICDSSynchronizationOperation.h

uploadRecentSyncFileAtLocation:

Upload the specified RecentSync file to the document’s RecentSync directory.

- (void)uploadRecentSyncFileAtLocation:(NSURL *)aLocation

Parameters

aLocation

The location of the file to upload.

Discussion

This method must call uploadedRecentSyncFileSuccessfully: to indicate whether the creation was successful.

Declared In

TICDSSynchronizationOperation.h

uploadedLocalSyncChangeSetFileSuccessfully:

Indicate whether the upload of the sync change set file was successful.

- (void)uploadedLocalSyncChangeSetFileSuccessfully:(BOOL)success

Parameters

success

YES if the sync change set file was uploaded, otherwise NO.

Discussion

If not, call setError: first, then specify NO for success.

Declared In

TICDSSynchronizationOperation.h

uploadedRecentSyncFileSuccessfully:

Indicate whether the upload of the RecentSync file was successful.

- (void)uploadedRecentSyncFileSuccessfully:(BOOL)success

Parameters

success

YES if the RecentSync file was uploaded, otherwise NO.

Discussion

If not, call setError: first, then specify NO for success.

Declared In

TICDSSynchronizationOperation.h