-
Notifications
You must be signed in to change notification settings - Fork 0
/
AMDispatch.h
74 lines (53 loc) · 2.43 KB
/
AMDispatch.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//
// AMDispatch.h
// a2
//
// Created by ampatspell on 7/28/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import "AMDispatchConnection.h"
extern NSString *const AMDispatchDidBecomeBusyNotification;
extern NSString *const AMDispatchDidBecomeIdleNotification;
extern NSString *const AMDispatchErrorDomain;
extern NSInteger const AMDispatchConnectionFailedErrorCode;
extern NSInteger const AMDispatchInvalidJSONErrorCode;
extern NSInteger const AMDispatchResponseStatusErrorCode;
typedef NSString *AMDispatchOperationID;
@protocol AMDispatchDelegate;
@interface AMDispatch : NSObject <AMDispatchConnectionDelegate> {
id<AMDispatchDelegate> delegate;
NSURL *URL;
NSURL *baseURL;
NSString *URLPrefix;
NSDictionary *defaultParameters;
NSMutableDictionary *connections;
}
@property(nonatomic, readwrite, assign) id<AMDispatchDelegate> delegate;
@property(nonatomic, readonly, retain) NSURL *URL;
@property(nonatomic, readwrite, copy) NSURL *baseURL;
@property(nonatomic, readwrite, copy) NSString *URLPrefix;
@property(nonatomic, readwrite, retain) NSDictionary *defaultParameters;
// -(void)operationDidSucceedWithResult:(id)result userInfo:(id)userInfo;
// -(void)operationDidFailWithError:(NSError *)error userInfo(id)userInfo;
- (AMDispatchOperationID)performOperationNamed:(NSString *)name
withURL:(NSURL *)url
parameters:(NSDictionary *)parameters
target:(id)target
success:(SEL)success
failed:(SEL)failed
userInfo:(id)userInfo;
- (AMDispatchOperationID)performOperationNamed:(NSString *)name
withPath:(NSString *)relativePath
parameters:(NSDictionary *)parameters
target:(id)target
success:(SEL)success
failed:(SEL)failed
userInfo:(id)userInfo;
- (void)cancelOperation:(AMDispatchOperationID)operation;
- (void)cancelAllOperations;
@end
@protocol AMDispatchDelegate
// return modified dictionary if result is successful, otherwise nil and fill NSError
- (id)dispatch:(AMDispatch *)sender didReceiveResult:(id)result error:(NSError **)error;
@end