The iOS framework that grows only as fast as its documentation
NIOperations.h
1 //
2 // Copyright 2011-2014 NimbusKit
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 #import <Foundation/Foundation.h>
18 #import <UIKit/UIKit.h>
19 
20 #import "NIPreprocessorMacros.h" /* for weak */
21 
22 @class NIOperation;
23 
24 typedef void (^NIOperationBlock)(NIOperation* operation);
25 typedef void (^NIOperationDidFailBlock)(NIOperation* operation, NSError* error);
26 
38 @protocol NIOperationDelegate;
39 
51 @interface NIOperation : NSOperation
52 
53 @property (weak) id<NIOperationDelegate> delegate;
54 @property (readonly, strong) NSError* lastError;
55 @property (assign) NSInteger tag;
56 
57 @property (copy) NIOperationBlock didStartBlock;
58 @property (copy) NIOperationBlock didFinishBlock;
59 @property (copy) NIOperationDidFailBlock didFailWithErrorBlock;
60 @property (copy) NIOperationBlock willFinishBlock;
61 
62 - (void)didStart;
63 - (void)didFinish;
64 - (void)didFailWithError:(NSError *)error;
65 - (void)willFinish;
66 
67 @end
68 
74 @protocol NIOperationDelegate <NSObject>
75 @optional
76 
80 - (void)nimbusOperationDidStart:(NIOperation *)operation;
81 
89 - (void)nimbusOperationWillFinish:(NIOperation *)operation;
90 
96 - (void)nimbusOperationDidFinish:(NIOperation *)operation;
97 
103 - (void)nimbusOperationDidFail:(NIOperation *)operation withError:(NSError *)error;
104 
105 @end
106 
107 
108 // NIOperation
109 
NIOperationDidFailBlock didFailWithErrorBlock
The operation failed in some way and has completed.
Definition: NIOperations.h:59
void willFinish()
In the operation's thread, notify the delegate that the operation will finish successfully.
Definition: NIOperations.m:60
The delegate protocol for an NIOperation.
Definition: NIOperations.h:74
NSInteger tag
A simple tagging mechanism for identifying operations.
Definition: NIOperations.h:55
NIOperationBlock didStartBlock
The operation has started executing.
Definition: NIOperations.h:57
void didFinish()
On the main thread, notify the delegate that the operation has finished.
Definition: NIOperations.m:46
NIOperationBlock willFinishBlock
The operation is about to complete successfully.
Definition: NIOperations.h:60
A base implementation of an NSOperation that supports traditional delegation and blocks.
Definition: NIOperations.h:51
id< NIOperationDelegate > delegate
The delegate through which changes are notified for this operation.
Definition: NIOperations.h:53
void didStart()
On the main thread, notify the delegate that the operation has begun.
Definition: NIOperations.m:40
NIOperationBlock didFinishBlock
The operation has completed successfully.
Definition: NIOperations.h:58