afmotion 0.6 → 0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +8 -8
  2. data/.gitignore +1 -1
  3. data/Gemfile.lock +21 -28
  4. data/lib/afmotion/patch/NSURLRequest_params.rb +4 -2
  5. data/lib/afmotion/version.rb +1 -1
  6. metadata +2 -53
  7. data/vendor/Pods/AFNetworking/AFNetworking.podspec +0 -28
  8. data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.h +0 -574
  9. data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.m +0 -1187
  10. data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.h +0 -133
  11. data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.m +0 -341
  12. data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.h +0 -108
  13. data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.m +0 -237
  14. data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.h +0 -71
  15. data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.m +0 -136
  16. data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.h +0 -75
  17. data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.m +0 -131
  18. data/vendor/Pods/AFNetworking/AFNetworking/AFNetworking.h +0 -44
  19. data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.h +0 -68
  20. data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.m +0 -145
  21. data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.h +0 -295
  22. data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.m +0 -652
  23. data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.h +0 -89
  24. data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.m +0 -169
  25. data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.h +0 -78
  26. data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.m +0 -180
  27. data/vendor/Pods/AFNetworking/LICENSE +0 -19
  28. data/vendor/Pods/AFNetworking/README.md +0 -179
  29. data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPClient.h +0 -574
  30. data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPRequestOperation.h +0 -133
  31. data/vendor/Pods/BuildHeaders/AFNetworking/AFImageRequestOperation.h +0 -108
  32. data/vendor/Pods/BuildHeaders/AFNetworking/AFJSONRequestOperation.h +0 -71
  33. data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworkActivityIndicatorManager.h +0 -75
  34. data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworking.h +0 -44
  35. data/vendor/Pods/BuildHeaders/AFNetworking/AFPropertyListRequestOperation.h +0 -68
  36. data/vendor/Pods/BuildHeaders/AFNetworking/AFURLConnectionOperation.h +0 -295
  37. data/vendor/Pods/BuildHeaders/AFNetworking/AFXMLRequestOperation.h +0 -89
  38. data/vendor/Pods/BuildHeaders/AFNetworking/UIImageView+AFNetworking.h +0 -78
  39. data/vendor/Pods/Headers/AFNetworking/AFHTTPClient.h +0 -574
  40. data/vendor/Pods/Headers/AFNetworking/AFHTTPRequestOperation.h +0 -133
  41. data/vendor/Pods/Headers/AFNetworking/AFImageRequestOperation.h +0 -108
  42. data/vendor/Pods/Headers/AFNetworking/AFJSONRequestOperation.h +0 -71
  43. data/vendor/Pods/Headers/AFNetworking/AFNetworkActivityIndicatorManager.h +0 -75
  44. data/vendor/Pods/Headers/AFNetworking/AFNetworking.h +0 -44
  45. data/vendor/Pods/Headers/AFNetworking/AFPropertyListRequestOperation.h +0 -68
  46. data/vendor/Pods/Headers/AFNetworking/AFURLConnectionOperation.h +0 -295
  47. data/vendor/Pods/Headers/AFNetworking/AFXMLRequestOperation.h +0 -89
  48. data/vendor/Pods/Headers/AFNetworking/UIImageView+AFNetworking.h +0 -78
  49. data/vendor/Pods/Pods-Acknowledgements.markdown +0 -26
  50. data/vendor/Pods/Pods-Acknowledgements.plist +0 -56
  51. data/vendor/Pods/Pods-prefix.pch +0 -14
  52. data/vendor/Pods/Pods-resources.sh +0 -19
  53. data/vendor/Pods/Pods.bridgesupport +0 -617
  54. data/vendor/Pods/Pods.xcconfig +0 -7
  55. data/vendor/Pods/PodsDummy_Pods.m +0 -4
@@ -1,75 +0,0 @@
1
- // AFNetworkActivityIndicatorManager.h
2
- //
3
- // Copyright (c) 2011 Gowalla (http://gowalla.com/)
4
- //
5
- // Permission is hereby granted, free of charge, to any person obtaining a copy
6
- // of this software and associated documentation files (the "Software"), to deal
7
- // in the Software without restriction, including without limitation the rights
8
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- // copies of the Software, and to permit persons to whom the Software is
10
- // furnished to do so, subject to the following conditions:
11
- //
12
- // The above copyright notice and this permission notice shall be included in
13
- // all copies or substantial portions of the Software.
14
- //
15
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- // THE SOFTWARE.
22
-
23
- #import <Foundation/Foundation.h>
24
-
25
- #import <Availability.h>
26
-
27
- #if __IPHONE_OS_VERSION_MIN_REQUIRED
28
- #import <UIKit/UIKit.h>
29
-
30
- /**
31
- `AFNetworkActivityIndicatorManager` manages the state of the network activity indicator in the status bar. When enabled, it will listen for notifications indicating that a network request operation has started or finished, and start or stop animating the indicator accordingly. The number of active requests is incremented and decremented much like a stack or a semaphore, and the activity indicator will animate so long as that number is greater than zero.
32
-
33
- You should enable the shared instance of `AFNetworkActivityIndicatorManager` when your application finishes launching. In `AppDelegate application:didFinishLaunchingWithOptions:` you can do so with the following code:
34
-
35
- [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES];
36
-
37
- By setting `isNetworkActivityIndicatorVisible` to `YES` for `sharedManager`, the network activity indicator will show and hide automatically as requests start and finish. You should not ever need to call `incrementActivityCount` or `decrementActivityCount` yourself.
38
-
39
- See the Apple Human Interface Guidelines section about the Network Activity Indicator for more information:
40
- http://developer.apple.com/library/iOS/#documentation/UserExperience/Conceptual/MobileHIG/UIElementGuidelines/UIElementGuidelines.html#//apple_ref/doc/uid/TP40006556-CH13-SW44
41
- */
42
- @interface AFNetworkActivityIndicatorManager : NSObject
43
-
44
- /**
45
- A Boolean value indicating whether the manager is enabled.
46
-
47
- @discussion If YES, the manager will change status bar network activity indicator according to network operation notifications it receives. The default value is NO.
48
- */
49
- @property (nonatomic, assign, getter = isEnabled) BOOL enabled;
50
-
51
- /**
52
- A Boolean value indicating whether the network activity indicator is currently displayed in the status bar.
53
- */
54
- @property (readonly, nonatomic, assign) BOOL isNetworkActivityIndicatorVisible;
55
-
56
- /**
57
- Returns the shared network activity indicator manager object for the system.
58
-
59
- @return The systemwide network activity indicator manager.
60
- */
61
- + (AFNetworkActivityIndicatorManager *)sharedManager;
62
-
63
- /**
64
- Increments the number of active network requests. If this number was zero before incrementing, this will start animating the status bar network activity indicator.
65
- */
66
- - (void)incrementActivityCount;
67
-
68
- /**
69
- Decrements the number of active network requests. If this number becomes zero before decrementing, this will stop animating the status bar network activity indicator.
70
- */
71
- - (void)decrementActivityCount;
72
-
73
- @end
74
-
75
- #endif
@@ -1,131 +0,0 @@
1
- // AFNetworkActivityIndicatorManager.m
2
- //
3
- // Copyright (c) 2011 Gowalla (http://gowalla.com/)
4
- //
5
- // Permission is hereby granted, free of charge, to any person obtaining a copy
6
- // of this software and associated documentation files (the "Software"), to deal
7
- // in the Software without restriction, including without limitation the rights
8
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- // copies of the Software, and to permit persons to whom the Software is
10
- // furnished to do so, subject to the following conditions:
11
- //
12
- // The above copyright notice and this permission notice shall be included in
13
- // all copies or substantial portions of the Software.
14
- //
15
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- // THE SOFTWARE.
22
-
23
- #import "AFNetworkActivityIndicatorManager.h"
24
-
25
- #import "AFHTTPRequestOperation.h"
26
-
27
- #if __IPHONE_OS_VERSION_MIN_REQUIRED
28
- static NSTimeInterval const kAFNetworkActivityIndicatorInvisibilityDelay = 0.17;
29
-
30
- @interface AFNetworkActivityIndicatorManager ()
31
- @property (readwrite, assign) NSInteger activityCount;
32
- @property (readwrite, nonatomic, strong) NSTimer *activityIndicatorVisibilityTimer;
33
- @property (readonly, getter = isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible;
34
-
35
- - (void)updateNetworkActivityIndicatorVisibility;
36
- - (void)updateNetworkActivityIndicatorVisibilityDelayed;
37
- @end
38
-
39
- @implementation AFNetworkActivityIndicatorManager
40
- @synthesize activityCount = _activityCount;
41
- @synthesize activityIndicatorVisibilityTimer = _activityIndicatorVisibilityTimer;
42
- @synthesize enabled = _enabled;
43
- @dynamic networkActivityIndicatorVisible;
44
-
45
- + (AFNetworkActivityIndicatorManager *)sharedManager {
46
- static AFNetworkActivityIndicatorManager *_sharedManager = nil;
47
- static dispatch_once_t oncePredicate;
48
- dispatch_once(&oncePredicate, ^{
49
- _sharedManager = [[self alloc] init];
50
- });
51
-
52
- return _sharedManager;
53
- }
54
-
55
- + (NSSet *)keyPathsForValuesAffectingIsNetworkActivityIndicatorVisible {
56
- return [NSSet setWithObject:@"activityCount"];
57
- }
58
-
59
- - (id)init {
60
- self = [super init];
61
- if (!self) {
62
- return nil;
63
- }
64
-
65
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(incrementActivityCount) name:AFNetworkingOperationDidStartNotification object:nil];
66
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(decrementActivityCount) name:AFNetworkingOperationDidFinishNotification object:nil];
67
-
68
- return self;
69
- }
70
-
71
- - (void)dealloc {
72
- [[NSNotificationCenter defaultCenter] removeObserver:self];
73
-
74
- [_activityIndicatorVisibilityTimer invalidate];
75
-
76
- }
77
-
78
- - (void)updateNetworkActivityIndicatorVisibilityDelayed {
79
- if (self.enabled) {
80
- // Delay hiding of activity indicator for a short interval, to avoid flickering
81
- if (![self isNetworkActivityIndicatorVisible]) {
82
- [self.activityIndicatorVisibilityTimer invalidate];
83
- self.activityIndicatorVisibilityTimer = [NSTimer timerWithTimeInterval:kAFNetworkActivityIndicatorInvisibilityDelay target:self selector:@selector(updateNetworkActivityIndicatorVisibility) userInfo:nil repeats:NO];
84
- [[NSRunLoop mainRunLoop] addTimer:self.activityIndicatorVisibilityTimer forMode:NSRunLoopCommonModes];
85
- } else {
86
- [self performSelectorOnMainThread:@selector(updateNetworkActivityIndicatorVisibility) withObject:nil waitUntilDone:NO modes:[NSArray arrayWithObject:NSRunLoopCommonModes]];
87
- }
88
- }
89
- }
90
-
91
- - (BOOL)isNetworkActivityIndicatorVisible {
92
- return _activityCount > 0;
93
- }
94
-
95
- - (void)updateNetworkActivityIndicatorVisibility {
96
- [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:[self isNetworkActivityIndicatorVisible]];
97
- }
98
-
99
- // Not exposed, but used if activityCount is set via KVC.
100
- - (NSInteger)activityCount {
101
- return _activityCount;
102
- }
103
-
104
- - (void)setActivityCount:(NSInteger)activityCount {
105
- @synchronized(self) {
106
- _activityCount = activityCount;
107
- }
108
- [self updateNetworkActivityIndicatorVisibilityDelayed];
109
- }
110
-
111
- - (void)incrementActivityCount {
112
- [self willChangeValueForKey:@"activityCount"];
113
- @synchronized(self) {
114
- _activityCount++;
115
- }
116
- [self didChangeValueForKey:@"activityCount"];
117
- [self updateNetworkActivityIndicatorVisibilityDelayed];
118
- }
119
-
120
- - (void)decrementActivityCount {
121
- [self willChangeValueForKey:@"activityCount"];
122
- @synchronized(self) {
123
- _activityCount = MAX(_activityCount - 1, 0);
124
- }
125
- [self didChangeValueForKey:@"activityCount"];
126
- [self updateNetworkActivityIndicatorVisibilityDelayed];
127
- }
128
-
129
- @end
130
-
131
- #endif
@@ -1,44 +0,0 @@
1
- // AFNetworking.h
2
- //
3
- // Copyright (c) 2011 Gowalla (http://gowalla.com/)
4
- //
5
- // Permission is hereby granted, free of charge, to any person obtaining a copy
6
- // of this software and associated documentation files (the "Software"), to deal
7
- // in the Software without restriction, including without limitation the rights
8
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- // copies of the Software, and to permit persons to whom the Software is
10
- // furnished to do so, subject to the following conditions:
11
- //
12
- // The above copyright notice and this permission notice shall be included in
13
- // all copies or substantial portions of the Software.
14
- //
15
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- // THE SOFTWARE.
22
-
23
- #import <Foundation/Foundation.h>
24
- #import <Availability.h>
25
-
26
- #ifndef _AFNETWORKING_
27
- #define _AFNETWORKING_
28
-
29
- #import "AFURLConnectionOperation.h"
30
-
31
- #import "AFHTTPRequestOperation.h"
32
- #import "AFJSONRequestOperation.h"
33
- #import "AFXMLRequestOperation.h"
34
- #import "AFPropertyListRequestOperation.h"
35
- #import "AFHTTPClient.h"
36
-
37
- #import "AFImageRequestOperation.h"
38
-
39
- #if __IPHONE_OS_VERSION_MIN_REQUIRED
40
- #import "AFNetworkActivityIndicatorManager.h"
41
- #import "UIImageView+AFNetworking.h"
42
- #endif
43
-
44
- #endif /* _AFNETWORKING_ */
@@ -1,68 +0,0 @@
1
- // AFPropertyListRequestOperation.h
2
- //
3
- // Copyright (c) 2011 Gowalla (http://gowalla.com/)
4
- //
5
- // Permission is hereby granted, free of charge, to any person obtaining a copy
6
- // of this software and associated documentation files (the "Software"), to deal
7
- // in the Software without restriction, including without limitation the rights
8
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- // copies of the Software, and to permit persons to whom the Software is
10
- // furnished to do so, subject to the following conditions:
11
- //
12
- // The above copyright notice and this permission notice shall be included in
13
- // all copies or substantial portions of the Software.
14
- //
15
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- // THE SOFTWARE.
22
-
23
- #import <Foundation/Foundation.h>
24
- #import "AFHTTPRequestOperation.h"
25
-
26
- /**
27
- `AFPropertyListRequestOperation` is a subclass of `AFHTTPRequestOperation` for downloading and deserializing objects with property list (plist) response data.
28
-
29
- ## Acceptable Content Types
30
-
31
- By default, `AFPropertyListRequestOperation` accepts the following MIME types:
32
-
33
- - `application/x-plist`
34
- */
35
- @interface AFPropertyListRequestOperation : AFHTTPRequestOperation
36
-
37
- ///----------------------------
38
- /// @name Getting Response Data
39
- ///----------------------------
40
-
41
- /**
42
- An object deserialized from a plist constructed using the response data.
43
- */
44
- @property (readonly, nonatomic) id responsePropertyList;
45
-
46
- ///--------------------------------------
47
- /// @name Managing Property List Behavior
48
- ///--------------------------------------
49
-
50
- /**
51
- One of the `NSPropertyListMutabilityOptions` options, specifying the mutability of objects deserialized from the property list. By default, this is `NSPropertyListImmutable`.
52
- */
53
- @property (nonatomic, assign) NSPropertyListReadOptions propertyListReadOptions;
54
-
55
- /**
56
- Creates and returns an `AFPropertyListRequestOperation` object and sets the specified success and failure callbacks.
57
-
58
- @param urlRequest The request object to be loaded asynchronously during execution of the operation
59
- @param success A block object to be executed when the operation finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the object deserialized from a plist constructed using the response data.
60
- @param failure A block object to be executed when the operation finishes unsuccessfully, or that finishes successfully, but encountered an error while deserializing the object from a property list. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error describing the network or parsing error that occurred.
61
-
62
- @return A new property list request operation
63
- */
64
- + (AFPropertyListRequestOperation *)propertyListRequestOperationWithRequest:(NSURLRequest *)urlRequest
65
- success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id propertyList))success
66
- failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id propertyList))failure;
67
-
68
- @end
@@ -1,145 +0,0 @@
1
- // AFPropertyListRequestOperation.m
2
- //
3
- // Copyright (c) 2011 Gowalla (http://gowalla.com/)
4
- //
5
- // Permission is hereby granted, free of charge, to any person obtaining a copy
6
- // of this software and associated documentation files (the "Software"), to deal
7
- // in the Software without restriction, including without limitation the rights
8
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- // copies of the Software, and to permit persons to whom the Software is
10
- // furnished to do so, subject to the following conditions:
11
- //
12
- // The above copyright notice and this permission notice shall be included in
13
- // all copies or substantial portions of the Software.
14
- //
15
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- // THE SOFTWARE.
22
-
23
- #import "AFPropertyListRequestOperation.h"
24
-
25
- static dispatch_queue_t af_property_list_request_operation_processing_queue;
26
- static dispatch_queue_t property_list_request_operation_processing_queue() {
27
- if (af_property_list_request_operation_processing_queue == NULL) {
28
- af_property_list_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.property-list-request.processing", 0);
29
- }
30
-
31
- return af_property_list_request_operation_processing_queue;
32
- }
33
-
34
- @interface AFPropertyListRequestOperation ()
35
- @property (readwrite, nonatomic) id responsePropertyList;
36
- @property (readwrite, nonatomic, assign) NSPropertyListFormat propertyListFormat;
37
- @property (readwrite, nonatomic) NSError *propertyListError;
38
- @end
39
-
40
- @implementation AFPropertyListRequestOperation
41
- @synthesize responsePropertyList = _responsePropertyList;
42
- @synthesize propertyListReadOptions = _propertyListReadOptions;
43
- @synthesize propertyListFormat = _propertyListFormat;
44
- @synthesize propertyListError = _propertyListError;
45
-
46
- + (AFPropertyListRequestOperation *)propertyListRequestOperationWithRequest:(NSURLRequest *)request
47
- success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id propertyList))success
48
- failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id propertyList))failure
49
- {
50
- AFPropertyListRequestOperation *requestOperation = [[self alloc] initWithRequest:request];
51
- [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
52
- if (success) {
53
- success(operation.request, operation.response, responseObject);
54
- }
55
- } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
56
- if (failure) {
57
- failure(operation.request, operation.response, error, [(AFPropertyListRequestOperation *)operation responsePropertyList]);
58
- }
59
- }];
60
-
61
- return requestOperation;
62
- }
63
-
64
- - (id)initWithRequest:(NSURLRequest *)urlRequest {
65
- self = [super initWithRequest:urlRequest];
66
- if (!self) {
67
- return nil;
68
- }
69
-
70
- self.propertyListReadOptions = NSPropertyListImmutable;
71
-
72
- return self;
73
- }
74
-
75
-
76
- - (id)responsePropertyList {
77
- if (!_responsePropertyList && [self.responseData length] > 0 && [self isFinished]) {
78
- NSPropertyListFormat format;
79
- NSError *error = nil;
80
- self.responsePropertyList = [NSPropertyListSerialization propertyListWithData:self.responseData options:self.propertyListReadOptions format:&format error:&error];
81
- self.propertyListFormat = format;
82
- self.propertyListError = error;
83
- }
84
-
85
- return _responsePropertyList;
86
- }
87
-
88
- - (NSError *)error {
89
- if (_propertyListError) {
90
- return _propertyListError;
91
- } else {
92
- return [super error];
93
- }
94
- }
95
-
96
- #pragma mark - AFHTTPRequestOperation
97
-
98
- + (NSSet *)acceptableContentTypes {
99
- return [NSSet setWithObjects:@"application/x-plist", nil];
100
- }
101
-
102
- + (BOOL)canProcessRequest:(NSURLRequest *)request {
103
- return [[[request URL] pathExtension] isEqualToString:@"plist"] || [super canProcessRequest:request];
104
- }
105
-
106
- - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
107
- failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
108
- {
109
- #pragma clang diagnostic push
110
- #pragma clang diagnostic ignored "-Warc-retain-cycles"
111
- self.completionBlock = ^ {
112
- if ([self isCancelled]) {
113
- return;
114
- }
115
-
116
- if (self.error) {
117
- if (failure) {
118
- dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{
119
- failure(self, self.error);
120
- });
121
- }
122
- } else {
123
- dispatch_async(property_list_request_operation_processing_queue(), ^(void) {
124
- id propertyList = self.responsePropertyList;
125
-
126
- if (self.propertyListError) {
127
- if (failure) {
128
- dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{
129
- failure(self, self.error);
130
- });
131
- }
132
- } else {
133
- if (success) {
134
- dispatch_async(self.successCallbackQueue ?: dispatch_get_main_queue(), ^{
135
- success(self, propertyList);
136
- });
137
- }
138
- }
139
- });
140
- }
141
- };
142
- #pragma clang diagnostic pop
143
- }
144
-
145
- @end