TICDSOperation Class Reference
| 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.
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
-
– initWithDelegate:Initialize the operation with a provided delegate, notified when the operation starts, ends, fails, or is cancelled using methods defined in the
TICDSOperationDelegateprotocol.
Operation Phase Updates
-
– operationDidStartNotify the delegate when the operation starts, and set the necessary values for
isExecutingandisFinished. -
– operationDidCompleteSuccessfullyNotify the delegate when the operation completes, and set the necessary values for
isExecutingandisFinished. -
– operationDidFailToCompleteNotify the delegate if the operation has failed for some reason. Set the relevant
errorproperty before calling this method. This will set the required values forisExecutingandisFinished. -
– operationWasCancelledCall this method if the operation is cancelled midway through its work. This will set the required values for
isExecutingandisFinished.
Properties
-
shouldUseEncryptionUsed to indicate whether the operation should encrypt files stored on the remote.
property -
cryptorThe
propertyFZACryptorobject used to encrypt and decrypt files used by this operation, ifshouldUseEncryptionisYES. -
delegateThe operation delegate.
property -
userInfoA user info dictionary for sync managers to keep task-specific information.
property -
needsMainThreadBy default returns
propertyNO, but override if your operation needs its code to execute on the main thread, such as for anNSURLConnection. -
isExecutingIndicates the operation is currently executing; this is set automatically through the operation phase methods.
property -
isFinishedIndicates the operation has completed; this is set automatically through the operation phase methods.
property -
errorThe most recent error; set this before calling
propertyoperationDidFailToComplete. -
fileManagerAn
propertyNSFileManagerobject suitable for use by this operation. -
tempFileDirectoryPathThe path to a directory inside
propertyNSTemporaryDirectory()guaranteed to be unique to this operation, created when path first requested and removed when operation finishes. -
clientIdentifierThe identifier of the client application (not set automatically, but may be used whenever necessary by subclasses).
property
Properties
clientIdentifier
The identifier of the client application (not set automatically, but may be used whenever necessary by subclasses).
@property (retain) NSString *clientIdentifierDeclared In
TICDSOperation.hcryptor
The FZACryptor object used to encrypt and decrypt files used by this operation, if shouldUseEncryption is YES.
@property (nonatomic, retain) FZACryptor *cryptorDeclared In
TICDSOperation.hdelegate
The operation delegate.
@property (nonatomic, assign) NSObject<TICDSOperationDelegate> *delegateDeclared In
TICDSOperation.herror
The most recent error; set this before calling operationDidFailToComplete.
@property (retain) NSError *errorDeclared In
TICDSOperation.hfileManager
An NSFileManager object suitable for use by this operation.
@property (nonatomic, readonly, retain) NSFileManager *fileManagerDeclared In
TICDSOperation.hisExecuting
Indicates the operation is currently executing; this is set automatically through the operation phase methods.
@property (readonly) BOOL isExecutingDeclared In
TICDSOperation.hisFinished
Indicates the operation has completed; this is set automatically through the operation phase methods.
@property (readonly) BOOL isFinishedDeclared In
TICDSOperation.hneedsMainThread
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 needsMainThreadDeclared In
TICDSOperation.hshouldUseEncryption
Used to indicate whether the operation should encrypt files stored on the remote.
@property (assign) BOOL shouldUseEncryptionDeclared In
TICDSOperation.hInstance 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> *)aDelegateParameters
- aDelegate
The delegate object for the operation.
Return Value
A properly-initialized operation.
Declared In
TICDSOperation.hoperationDidCompleteSuccessfully
Notify the delegate when the operation completes, and set the necessary values for isExecuting and isFinished.
- (void)operationDidCompleteSuccessfullyDeclared In
TICDSOperation.hoperationDidFailToComplete
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)operationDidFailToCompleteDeclared In
TICDSOperation.hoperationDidStart
Notify the delegate when the operation starts, and set the necessary values for isExecuting and isFinished.
- (void)operationDidStartDiscussion
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.hoperationWasCancelled
Call this method if the operation is cancelled midway through its work. This will set the required values for isExecuting and isFinished.
- (void)operationWasCancelledDeclared In
TICDSOperation.h