Inherits from NSOperation
Declared in TICDSOperation.h

Overview

The TICDSOperation class provides the abstract behavior typical of any operation used by the TICoreDataSync framework.

All TICoreDataSync operations are (in Apple terms) concurrent, which means that they return YES for isConcurrent. This means they may be used by classes using e.g. NSURLConnection or custom rest clients to fetch information in the background.

Subclasses should make use of the operation phase methods listed below to update the values of isExecuting and isFinished so that operation queues can keep track of them. The operationDidStart method is called automatically when the operation begins to execute.

Subclasses of TICDSOperation should override needsMainThread to return YES if they require their tasks to be implemented on the main thread.

The start method automatically sets up the operation and notifies its delegate that it started. Subclasses should override main to do their work.

If an operation needs to create temporary files on disk during execution, it can call tempFileDirectoryPath to get access to a directory created specifically for the operation. This directory (and its contents) will automatically be removed from disk once the operation calls one of the completion methods.

%warning%
Warning: Subclasses must call one of the operationDidCompleteSuccessfully, operationDidFailToComplete or operationWasCancelled to update the delegate and set the necessary values such that the operation be removed from the operation queue.

Tasks

Designated Initializer

Operation Phase Updates

Properties

  •   shouldUseEncryption

    Used to indicate whether the operation should encrypt files stored on the remote.

    property
  •   cryptor

    The FZACryptor object used to encrypt and decrypt files used by this operation, if shouldUseEncryption is YES.

    property
  •   shouldUseCompressionForWholeStoreMoves

    Used to indicate whether the operation should use compression when moving the whole store.

    property
  •   delegate

    The operation delegate.

    property
  •   userInfo

    A user info dictionary for sync managers to keep task-specific information.

    property
  •   needsMainThread

    By default returns NO, but override if your operation needs its code to execute on the main thread, such as for an NSURLConnection.

    property
  •   isExecuting

    Indicates the operation is currently executing; this is set automatically through the operation phase methods.

    property
  •   isFinished

    Indicates the operation has completed; this is set automatically through the operation phase methods.

    property
  •   error

    The most recent error; set this before calling operationDidFailToComplete.

    property
  •   fileManager

    An NSFileManager object suitable for use by this operation.

    property
  •   tempFileDirectoryPath

    The path to a directory inside NSTemporaryDirectory() guaranteed to be unique to this operation, created when path first requested and removed when operation finishes.

    property
  •   clientIdentifier

    The identifier of the client application (not set automatically, but may be used whenever necessary by subclasses).

    property
  •   progress

    Used to report the completion progress of the operation (eg. during device to cloud file transfers).

    property
  •   backgroundTaskID

    Unique task identifier used when this operation must complete as a background operation

    property
  •   shouldContinueProcessingInBackgroundState

    Indicates whether the operation should be setup to continue processing after the app has been moved from the Active to Background state

    property

Properties

backgroundTaskID

Unique task identifier used when this operation must complete as a background operation

@property (nonatomic, assign) UIBackgroundTaskIdentifier backgroundTaskID

Declared In

TICDSOperation.h

clientIdentifier

The identifier of the client application (not set automatically, but may be used whenever necessary by subclasses).

@property (copy) NSString *clientIdentifier

Declared In

TICDSOperation.h

cryptor

The FZACryptor object used to encrypt and decrypt files used by this operation, if shouldUseEncryption is YES.

@property (nonatomic, strong) FZACryptor *cryptor

Declared In

TICDSOperation.h

delegate

The operation delegate.

@property (nonatomic, weak) NSObject<TICDSOperationDelegate> *delegate

Declared In

TICDSOperation.h

error

The most recent error; set this before calling operationDidFailToComplete.

@property (strong) NSError *error

Declared In

TICDSOperation.h

fileManager

An NSFileManager object suitable for use by this operation.

@property (nonatomic, readonly, strong) NSFileManager *fileManager

Declared In

TICDSOperation.h

isExecuting

Indicates the operation is currently executing; this is set automatically through the operation phase methods.

@property (readonly) BOOL isExecuting

Declared In

TICDSOperation.h

isFinished

Indicates the operation has completed; this is set automatically through the operation phase methods.

@property (readonly) BOOL isFinished

Declared In

TICDSOperation.h

needsMainThread

By default returns NO, but override if your operation needs its code to execute on the main thread, such as for an NSURLConnection.

@property (readonly) BOOL needsMainThread

Declared In

TICDSOperation.h

progress

Used to report the completion progress of the operation (eg. during device to cloud file transfers).

@property (nonatomic, assign) CGFloat progress

Declared In

TICDSOperation.h

shouldContinueProcessingInBackgroundState

Indicates whether the operation should be setup to continue processing after the app has been moved from the Active to Background state

@property (nonatomic, assign) BOOL shouldContinueProcessingInBackgroundState

Declared In

TICDSOperation.h

shouldUseCompressionForWholeStoreMoves

Used to indicate whether the operation should use compression when moving the whole store.

@property (assign) BOOL shouldUseCompressionForWholeStoreMoves

Declared In

TICDSOperation.h

shouldUseEncryption

Used to indicate whether the operation should encrypt files stored on the remote.

@property (assign) BOOL shouldUseEncryption

Declared In

TICDSOperation.h

tempFileDirectoryPath

The path to a directory inside NSTemporaryDirectory() guaranteed to be unique to this operation, created when path first requested and removed when operation finishes.

@property (nonatomic, copy) NSString *tempFileDirectoryPath

Declared In

TICDSOperation.h

userInfo

A user info dictionary for sync managers to keep task-specific information.

@property (strong) NSDictionary *userInfo

Declared In

TICDSOperation.h

Instance Methods

initWithDelegate:

Initialize the operation with a provided delegate, notified when the operation starts, ends, fails, or is cancelled using methods defined in the TICDSOperationDelegate protocol.

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

Parameters

aDelegate

The delegate object for the operation.

Return Value

A properly-initialized operation.

Declared In

TICDSOperation.h

operationDidCompleteSuccessfully

Notify the delegate when the operation completes, and set the necessary values for isExecuting and isFinished.

- (void)operationDidCompleteSuccessfully

Declared In

TICDSOperation.h

operationDidFailToComplete

Notify the delegate if the operation has failed for some reason. Set the relevant error property before calling this method. This will set the required values for isExecuting and isFinished.

- (void)operationDidFailToComplete

Declared In

TICDSOperation.h

operationDidMakeProgress

Call this method if the operation wants to announce an update in the task progress.

- (void)operationDidMakeProgress

Declared In

TICDSOperation.h

operationDidStart

Notify the delegate when the operation starts, and set the necessary values for isExecuting and isFinished.

- (void)operationDidStart

Discussion

%warning%
Warning: This method is called automatically by TICDSOperation when the operation starts to execute, so you should not call it from a TICDSOperation subclass.

Declared In

TICDSOperation.h

operationWasCancelled

Call this method if the operation is cancelled midway through its work. This will set the required values for isExecuting and isFinished.

- (void)operationWasCancelled

Declared In

TICDSOperation.h