The iOS framework that grows only as fast as its documentation
NIOperation Class Reference

Overview

A base implementation of an NSOperation that supports traditional delegation and blocks.

Subclassing

A subclass should call the operationDid* methods to notify the delegate on the main thread of changes in the operation's state. Calling these methods will notify the delegate and the blocks if provided.

Tasks

Delegation
id< NIOperationDelegatedelegate property
 
Post-Operation Properties
NSError * lastError property
 
Identification
NSInteger tag property
 
Blocks
NIOperationBlock didStartBlock property
 
NIOperationBlock didFinishBlock property
 
NIOperationDidFailBlock didFailWithErrorBlock property
 
NIOperationBlock willFinishBlock property
 
Subclassing

The following methods are provided to aid in subclassing and are not meant to be used externally.

(void) - didStart
 
(void) - didFinish
 
(void) - didFailWithError:
 
(void) - willFinish
 

Method Documentation

delegate

The delegate through which changes are notified for this operation.

@property (weak) id<NIOperationDelegate> delegate;
Discussion

All delegate methods are performed on the main thread.

lastError

The error last passed to the didFailWithError notification.

@property (readonly, strong) NSError* lastError;

tag

A simple tagging mechanism for identifying operations.

@property () NSInteger tag;

didStartBlock

The operation has started executing.

@property (copy) NIOperationBlock didStartBlock;
Discussion

Performed on the main thread.

didFinishBlock

The operation has completed successfully.

@property (copy) NIOperationBlock didFinishBlock;
Discussion

This will not be called if the operation fails.

Performed on the main thread.

didFailWithErrorBlock

The operation failed in some way and has completed.

@property (copy) NIOperationDidFailBlock didFailWithErrorBlock;
Discussion

didFinishBlock will not be executed.

Performed on the main thread.

willFinishBlock

The operation is about to complete successfully.

@property (copy) NIOperationBlock willFinishBlock;
Discussion

This will not be called if the operation fails.

Performed in the operation's thread.

didStart

On the main thread, notify the delegate that the operation has begun.

- (void)didStart;

didFinish

On the main thread, notify the delegate that the operation has finished.

- (void)didFinish;

didFailWithError:

On the main thread, notify the delegate that the operation has failed.

- (void)didFailWithError:(NSError *)error;

willFinish

In the operation's thread, notify the delegate that the operation will finish successfully.

- (void)willFinish;