TICDSSynchronizationOperation Class Reference
| 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)
- Fetch an array containing UUID strings for each client device that has synchronized this document.
- For each client device that isn’t the current device:
- Fetch an array containing UUID strings for each available
SyncCommandSet.
- Fetch an array containing UUID strings for each available
- Determine which
SyncCommandSets haven’t yet been applied locally. - If any
SyncCommandSets haven’t yet been applied, fetch them to theUnappliedSyncCommandSetshelper file directory. - Go through each
SyncCommandSetand:- Carry out the command, determining whether synchronization can continue, or whether e.g. the entire store needs to be downloaded.
- Add the UUID of the set to the list of
AppliedSyncCommands.ticdsync.
- If synchronization can continue, then for each client device that isn’t the current device:
- Fetch an array containing UUID strings for each available
SyncChangeSet. - Determine which
SyncChangeSets haven’t yet been applied locally. - If any
SyncChangeSets haven’t yet been applied, fetch them to theUnappliedSyncChangeSetshelper file directory.
- Fetch an array containing UUID strings for each available
- Go through each
SyncChangeSetand:- Check for conflicts against local changes made since the last synchronization.
- Fix any conflicts, and build an array of conflict warnings for issues that cannot be resolved.
- Apply each
SyncChangein the set to the localWholeStore. - Add the UUID of the set to the list of
AppliedSyncChangeSets.ticdsync.
- If there are local
SyncCommands, renameUnsynchronizedSyncCommands.ticdsynctoUUID.synccmdand push the file to the remote. - If there are local
SyncChanges, renameUnsynchronizedSyncChanges.syncchgtoUUID.syncchdand push the file to the remote. - Save this client’s file in the
RecentSyncsdirectory 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
-
– initWithDelegate:Initialize a synchronization operation using a delegate that supports the
TICDSSynchronizationOperationDelegateprotocol.
Methods Overridden by Subclasses
-
– fetchRemoteIntegrityKeyFetch the integrity key for this document.
-
– buildArrayOfClientDeviceIdentifiersBuild an array of
NSStringidentifiers for all clients that have synchronized with this document. -
– buildArrayOfSyncChangeSetIdentifiersForClientIdentifier:Build an array of
NSStringidentifiers for eachSyncChangeSetfor the given client device. -
– fetchSyncChangeSetWithIdentifier:forClientIdentifier:toLocation:Fetch a
SyncChangeSetwith a given identifier from a client’sSyncChangesdirectory. -
– uploadLocalSyncChangeSetFileAtLocation:Upload the specified sync changes file to the client device’s directory inside the document’s
SyncChangesdirectory. -
– uploadRecentSyncFileAtLocation:Upload the specified RecentSync file to the document’s
RecentSyncdirectory.
Callbacks
-
– fetchedRemoteIntegrityKey:Pass back the remote integrity key for this document.
-
– builtArrayOfClientDeviceIdentifiers:Pass back the assembled
NSArrayofNSStringClientDeviceidentifiers. -
– builtArrayOfClientSyncChangeSetIdentifiers:forClientIdentifier:Pass back the assembled
NSArrayofNSStringSyncChangeSetidentifiers. -
– fetchedSyncChangeSetWithIdentifier:forClientIdentifier:modificationDate:withSuccess:Indicate whether the download of the specified
SyncChangeSetwas successful. -
– uploadedLocalSyncChangeSetFileSuccessfully:Indicate whether the upload of the sync change set file was successful.
-
– uploadedRecentSyncFileSuccessfully:Indicate whether the upload of the RecentSync file was successful.
-
– contextForSyncChangesInUnappliedSyncChangeSet:Releases any existing
unappliedSyncChangesContextandunappliedSyncChangesCoreDataFactoryand sets new ones, linked to the set of sync changes specified in the given sync change set. -
– configureBackgroundApplicationContextForPersistentStoreCoordinator:Configure a background context (for applying sync changes) using the same persistent store coordinator as the main application context.
Properties
-
pausedA boolean indicating whether the operation is currently paused awaiting an instruction to continue, e.g. for conflict resolution.
property -
mostRecentConflictResolutionTypeThe resolution type for the most recent conflict, set before resuming the operation after a conflict is detected.
property -
otherSynchronizedClientDeviceIdentifiersAn array of client identifiers for clients that synchronize with this document, excluding this client.
property -
otherSynchronizedClientDeviceSyncChangeSetIdentifiersA dictionary of arrays; keys are client identifiers, values are sync change set identifiers for each of those clients.
property -
syncChangeSortDescriptorsThe sort descriptors used to sort sync change objects in a
propertySyncChangeSetbefore being applied. -
synchronizationWarningsThe warnings generated during this synchronization.
property -
integrityKeyThe integrity key provided either by the client to check existing data matches integrity, or set during registration for new documents.
property
File Locations
-
localSyncChangesToMergeLocationThe location of the
propertySyncChangesBeingSynchronized.syncchgfile for this synchronization operation. -
appliedSyncChangeSetsFileLocationThe location of this document’s
propertyAppliedSyncChangeSets.ticdsyncfile. -
unappliedSyncChangesDirectoryLocationThe location of the
propertyUnappliedSyncChangesdirectory for this synchronization operation. -
unappliedSyncChangeSetsFileLocationThe location of this document’s
propertyUnappliedSyncChangeSets.ticdsyncfile. -
localRecentSyncFileLocationThe location of the local RecentSync file to upload at the end of the synchronization process.
property
Managed Object Contexts and Factories
-
appliedSyncChangeSetsCoreDataFactoryA
propertyTICoreDataFactoryto access the contents of theAppliedSyncChangeSets.ticdsyncfile. -
appliedSyncChangeSetsContextThe managed object context for the
propertyAppliedSyncChangeSets.ticdsyncfile. -
unappliedSyncChangeSetsCoreDataFactoryA
propertyTICoreDataFactoryto access the contents of theUnappliedSyncChangeSets.ticdsyncfile. -
unappliedSyncChangeSetsContextThe managed object context for the
propertyUnappliedSyncChangeSets.ticdsyncfile. -
unappliedSyncChangesCoreDataFactoryA
propertyTICoreDataFactoryto access the contents of a single, unappliedSyncChangeSetfile. -
unappliedSyncChangesContextThe managed object context for the changes in a single, unapplied
propertySyncChangeSetfile. -
localSyncChangesToMergeCoreDataFactoryA
propertyTICoreDataFactoryto access the contents of the local, unsynchronized set ofSyncChanges. -
localSyncChangesToMergeContextThe managed object context for the local, unsynchronized set of
propertySyncChanges. -
primaryPersistentStoreCoordinatorThe persistent store coordinator for the application – used to create a background application context, when needed.
property -
backgroundApplicationContextThe managed object context (tied to the application’s persistent store coordinator) in which
propertySyncChangesare applied.
Completion
-
numberOfSyncChangeSetIDArraysToFetchThe total number of arrays of
propertySyncChangeSetidentifiers that need to be fetched. -
numberOfSyncChangeSetIDArraysFetchedThe number of arrays of
propertySyncChangeSetidentifiers that have already been fetched. -
numberOfSyncChangeSetIDArraysThatFailedToFetchThe number of arrays of
propertySyncChangeSetidentifiers that failed to fetch because of an error. -
numberOfUnappliedSyncChangeSetsToFetchThe number of unapplied sync change sets that need to be fetched.
property -
numberOfUnappliedSyncChangeSetsFetchedThe number of unapplied sync change sets that have already been fetched.
property -
numberOfUnappliedSyncChangeSetsThatFailedToFetchThe number of unapplied sync change sets that failed to fetch because of an error.
property
Properties
appliedSyncChangeSetsContext
The managed object context for the AppliedSyncChangeSets.ticdsync file.
@property (nonatomic, retain) NSManagedObjectContext *appliedSyncChangeSetsContextDeclared In
TICDSSynchronizationOperation.happliedSyncChangeSetsCoreDataFactory
A TICoreDataFactory to access the contents of the AppliedSyncChangeSets.ticdsync file.
@property (nonatomic, retain) TICoreDataFactory *appliedSyncChangeSetsCoreDataFactoryDeclared In
TICDSSynchronizationOperation.happliedSyncChangeSetsFileLocation
The location of this document’s AppliedSyncChangeSets.ticdsync file.
@property (retain) NSURL *appliedSyncChangeSetsFileLocationDeclared In
TICDSSynchronizationOperation.hbackgroundApplicationContext
The managed object context (tied to the application’s persistent store coordinator) in which SyncChanges are applied.
@property (nonatomic, retain) NSManagedObjectContext *backgroundApplicationContextDeclared In
TICDSSynchronizationOperation.hintegrityKey
The integrity key provided either by the client to check existing data matches integrity, or set during registration for new documents.
@property (retain) NSString *integrityKeyDeclared In
TICDSSynchronizationOperation.hlocalRecentSyncFileLocation
The location of the local RecentSync file to upload at the end of the synchronization process.
@property (retain) NSURL *localRecentSyncFileLocationDeclared In
TICDSSynchronizationOperation.hlocalSyncChangesToMergeContext
The managed object context for the local, unsynchronized set of SyncChanges.
@property (nonatomic, retain) NSManagedObjectContext *localSyncChangesToMergeContextDeclared In
TICDSSynchronizationOperation.hlocalSyncChangesToMergeCoreDataFactory
A TICoreDataFactory to access the contents of the local, unsynchronized set of SyncChanges.
@property (nonatomic, retain) TICoreDataFactory *localSyncChangesToMergeCoreDataFactoryDeclared In
TICDSSynchronizationOperation.hlocalSyncChangesToMergeLocation
The location of the SyncChangesBeingSynchronized.syncchg file for this synchronization operation.
@property (retain) NSURL *localSyncChangesToMergeLocationDeclared In
TICDSSynchronizationOperation.hmostRecentConflictResolutionType
The resolution type for the most recent conflict, set before resuming the operation after a conflict is detected.
@property (assign) TICDSSyncConflictResolutionType mostRecentConflictResolutionTypeDeclared In
TICDSSynchronizationOperation.hnumberOfSyncChangeSetIDArraysFetched
The number of arrays of SyncChangeSet identifiers that have already been fetched.
@property (nonatomic, assign) NSUInteger numberOfSyncChangeSetIDArraysFetchedDeclared In
TICDSSynchronizationOperation.hnumberOfSyncChangeSetIDArraysThatFailedToFetch
The number of arrays of SyncChangeSet identifiers that failed to fetch because of an error.
@property (nonatomic, assign) NSUInteger numberOfSyncChangeSetIDArraysThatFailedToFetchDeclared In
TICDSSynchronizationOperation.hnumberOfSyncChangeSetIDArraysToFetch
The total number of arrays of SyncChangeSet identifiers that need to be fetched.
@property (nonatomic, assign) NSUInteger numberOfSyncChangeSetIDArraysToFetchDeclared In
TICDSSynchronizationOperation.hnumberOfUnappliedSyncChangeSetsFetched
The number of unapplied sync change sets that have already been fetched.
@property (nonatomic, assign) NSUInteger numberOfUnappliedSyncChangeSetsFetchedDeclared In
TICDSSynchronizationOperation.hnumberOfUnappliedSyncChangeSetsThatFailedToFetch
The number of unapplied sync change sets that failed to fetch because of an error.
@property (nonatomic, assign) NSUInteger numberOfUnappliedSyncChangeSetsThatFailedToFetchDeclared In
TICDSSynchronizationOperation.hnumberOfUnappliedSyncChangeSetsToFetch
The number of unapplied sync change sets that need to be fetched.
@property (nonatomic, assign) NSUInteger numberOfUnappliedSyncChangeSetsToFetchDeclared In
TICDSSynchronizationOperation.hotherSynchronizedClientDeviceIdentifiers
An array of client identifiers for clients that synchronize with this document, excluding this client.
@property (nonatomic, retain) NSArray *otherSynchronizedClientDeviceIdentifiersDeclared In
TICDSSynchronizationOperation.hotherSynchronizedClientDeviceSyncChangeSetIdentifiers
A dictionary of arrays; keys are client identifiers, values are sync change set identifiers for each of those clients.
@property (retain) NSMutableDictionary *otherSynchronizedClientDeviceSyncChangeSetIdentifiersDeclared In
TICDSSynchronizationOperation.hpaused
A boolean indicating whether the operation is currently paused awaiting an instruction to continue, e.g. for conflict resolution.
@property (assign, getter=isPaused) BOOL pausedDeclared In
TICDSSynchronizationOperation.hprimaryPersistentStoreCoordinator
The persistent store coordinator for the application – used to create a background application context, when needed.
@property (retain) NSPersistentStoreCoordinator *primaryPersistentStoreCoordinatorDeclared In
TICDSSynchronizationOperation.hsyncChangeSortDescriptors
The sort descriptors used to sort sync change objects in a SyncChangeSet before being applied.
@property (nonatomic, retain) NSArray *syncChangeSortDescriptorsDeclared In
TICDSSynchronizationOperation.hsynchronizationWarnings
The warnings generated during this synchronization.
@property (retain) NSMutableArray *synchronizationWarningsDeclared In
TICDSSynchronizationOperation.hunappliedSyncChangeSetsContext
The managed object context for the UnappliedSyncChangeSets.ticdsync file.
@property (nonatomic, retain) NSManagedObjectContext *unappliedSyncChangeSetsContextDeclared In
TICDSSynchronizationOperation.hunappliedSyncChangeSetsCoreDataFactory
A TICoreDataFactory to access the contents of the UnappliedSyncChangeSets.ticdsync file.
@property (nonatomic, retain) TICoreDataFactory *unappliedSyncChangeSetsCoreDataFactoryDeclared In
TICDSSynchronizationOperation.hunappliedSyncChangeSetsFileLocation
The location of this document’s UnappliedSyncChangeSets.ticdsync file.
@property (retain) NSURL *unappliedSyncChangeSetsFileLocationDeclared In
TICDSSynchronizationOperation.hunappliedSyncChangesContext
The managed object context for the changes in a single, unapplied SyncChangeSet file.
@property (nonatomic, retain) NSManagedObjectContext *unappliedSyncChangesContextDeclared In
TICDSSynchronizationOperation.hInstance Methods
buildArrayOfClientDeviceIdentifiers
Build an array of NSString identifiers for all clients that have synchronized with this document.
- (void)buildArrayOfClientDeviceIdentifiersDiscussion
Call builtArrayOfClientDeviceIdentifiers: when the array is built.
Declared In
TICDSSynchronizationOperation.hbuildArrayOfSyncChangeSetIdentifiersForClientIdentifier:
Build an array of NSString identifiers for each SyncChangeSet for the given client device.
- (void)buildArrayOfSyncChangeSetIdentifiersForClientIdentifier:(NSString *)anIdentifierParameters
- anIdentifier
The unique identifier of the client.
Discussion
Call builtArrayOfClientSyncChangeSetIdentifiers:forClientIdentifier: when the array is built.
Declared In
TICDSSynchronizationOperation.hbuiltArrayOfClientDeviceIdentifiers:
Pass back the assembled NSArray of NSString ClientDevice identifiers.
- (void)builtArrayOfClientDeviceIdentifiers:(NSArray *)anArrayParameters
- anArray
The array of identifiers. Pass
nilif an error occurred.
Discussion
If an error occurred, call setError: first, then specify nil for anArray.
Declared In
TICDSSynchronizationOperation.hbuiltArrayOfClientSyncChangeSetIdentifiers:forClientIdentifier:
Pass back the assembled NSArray of NSString SyncChangeSet identifiers.
- (void)builtArrayOfClientSyncChangeSetIdentifiers:(NSArray *)anArray forClientIdentifier:(NSString *)anIdentifierParameters
- anArray
The array of identifiers. Pass
nilif an error occurred.
- anIdentifier
The client identifier for this array of
SyncChangeSetidentifiers.
Discussion
If an error occured, call setError: first, then specify nil for anArray.
Declared In
TICDSSynchronizationOperation.hconfigureBackgroundApplicationContextForPersistentStoreCoordinator:
Configure a background context (for applying sync changes) using the same persistent store coordinator as the main application context.
- (void)configureBackgroundApplicationContextForPersistentStoreCoordinator:(NSPersistentStoreCoordinator *)aPersistentStoreCoordinatorParameters
- aPersistentStoreCoordinator
The persistent store coordinator to use for the background context.
Declared In
TICDSSynchronizationOperation.hcontextForSyncChangesInUnappliedSyncChangeSet:
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 *)aChangeSetParameters
- aChangeSet
The
TICDSSyncChangeSetobject specifying the set of changes to use.
Return Value
A managed object context to access the sync changes.
Declared In
TICDSSynchronizationOperation.hfetchRemoteIntegrityKey
Fetch the integrity key for this document.
- (void)fetchRemoteIntegrityKeyDiscussion
This method must call fetchedRemoteIntegrityKey: to provide the key.
Declared In
TICDSSynchronizationOperation.hfetchSyncChangeSetWithIdentifier:forClientIdentifier:toLocation:
Fetch a SyncChangeSet with a given identifier from a client’s SyncChanges directory.
- (void)fetchSyncChangeSetWithIdentifier:(NSString *)aChangeSetIdentifier forClientIdentifier:(NSString *)aClientIdentifier toLocation:(NSURL *)aLocationParameters
- 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.hfetchedRemoteIntegrityKey:
Pass back the remote integrity key for this document.
- (void)fetchedRemoteIntegrityKey:(NSString *)aKeyParameters
- aKey
The remote integrity key, or
nilif an error occurred.
Discussion
If an error occurred, call setError: first, then specify nil for aKey.
Declared In
TICDSSynchronizationOperation.hfetchedSyncChangeSetWithIdentifier: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)successParameters
- 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.hinitWithDelegate:
Initialize a synchronization operation using a delegate that supports the TICDSSynchronizationOperationDelegate protocol.
- (id)initWithDelegate:(NSObject<TICDSSynchronizationOperationDelegate> *)aDelegateParameters
- aDelegate
The delegate to use for this operation.
Return Value
An initialized synchronization operation.
Declared In
TICDSSynchronizationOperation.huploadLocalSyncChangeSetFileAtLocation:
Upload the specified sync changes file to the client device’s directory inside the document’s SyncChanges directory.
- (void)uploadLocalSyncChangeSetFileAtLocation:(NSURL *)aLocationParameters
- aLocation
The location of the file to upload.
Discussion
This method must call uploadedLocalSyncChangeSetFileSuccessfully: to indicate whether the creation was successful.
Declared In
TICDSSynchronizationOperation.huploadRecentSyncFileAtLocation:
Upload the specified RecentSync file to the document’s RecentSync directory.
- (void)uploadRecentSyncFileAtLocation:(NSURL *)aLocationParameters
- aLocation
The location of the file to upload.
Discussion
This method must call uploadedRecentSyncFileSuccessfully: to indicate whether the creation was successful.
Declared In
TICDSSynchronizationOperation.huploadedLocalSyncChangeSetFileSuccessfully:
Indicate whether the upload of the sync change set file was successful.
- (void)uploadedLocalSyncChangeSetFileSuccessfully:(BOOL)successParameters
- success
YESif the sync change set file was uploaded, otherwiseNO.
Discussion
If not, call setError: first, then specify NO for success.
Declared In
TICDSSynchronizationOperation.huploadedRecentSyncFileSuccessfully:
Indicate whether the upload of the RecentSync file was successful.
- (void)uploadedRecentSyncFileSuccessfully:(BOOL)successParameters
- success
YESif the RecentSync file was uploaded, otherwiseNO.
Discussion
If not, call setError: first, then specify NO for success.
Declared In
TICDSSynchronizationOperation.h