appjam 0.1.8.6 → 0.1.8.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/appjam.rb +1 -1
- data/lib/appjam/generators/blank.rb +133 -0
- data/lib/appjam/generators/help.rb +5 -3
- data/lib/appjam/generators/templates/blank/EiffelApplication.xcodeproj/project.pbxproj +855 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication.xcodeproj/project.xcworkspace/xcuserdata/eiffel.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication.xcodeproj/xcuserdata/eiffel.xcuserdatad/xcschemes/EiffelApplication.xcscheme +96 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication.xcodeproj/xcuserdata/eiffel.xcuserdatad/xcschemes/xcschememanagement.plist +27 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/AppDelegate.h.tt +22 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/AppDelegate.m.tt +156 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/EiffelApplication-Info.plist +45 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/EiffelApplication-Prefix.pch.tt +30 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/en.lproj/InfoPlist.strings +2 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFHTTPClient.h +636 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFHTTPClient.m +1359 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFHTTPRequestOperation.h +133 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFHTTPRequestOperation.m +318 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFImageRequestOperation.h +108 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFImageRequestOperation.m +234 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFJSONRequestOperation.h +71 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFJSONRequestOperation.m +142 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFNetworkActivityIndicatorManager.h +75 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFNetworkActivityIndicatorManager.m +145 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFNetworking.h +43 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFPropertyListRequestOperation.h +68 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFPropertyListRequestOperation.m +142 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFURLConnectionOperation.h +379 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFURLConnectionOperation.m +818 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFXMLRequestOperation.h +89 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFXMLRequestOperation.m +166 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/UIImageView+AFNetworking.h +78 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/UIImageView+AFNetworking.m +184 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/JSONKit/JSONKit.h +251 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/JSONKit/JSONKit.m +3067 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/fmdb/FMDatabase.h +155 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/fmdb/FMDatabase.m +1162 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/fmdb/FMDatabaseAdditions.h +37 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/fmdb/FMDatabaseAdditions.m +163 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/fmdb/FMDatabasePool.h +75 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/fmdb/FMDatabasePool.m +244 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/fmdb/FMDatabaseQueue.h +38 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/fmdb/FMDatabaseQueue.m +176 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/fmdb/FMResultSet.h +104 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/fmdb/FMResultSet.m +413 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/EGOCache/EGOCache.h +78 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/EGOCache/EGOCache.m +370 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/DDASLLogger.h +41 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/DDASLLogger.m +99 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/DDAbstractDatabaseLogger.h +102 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/DDAbstractDatabaseLogger.m +727 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/DDFileLogger.h +334 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/DDFileLogger.m +1353 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/DDLog.h +601 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/DDLog.m +1083 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/DDTTYLogger.h +167 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/DDTTYLogger.m +1479 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/Extensions/ContextFilterLogFormatter.h +65 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/Extensions/ContextFilterLogFormatter.m +191 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/Extensions/DispatchQueueLogFormatter.h +116 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/Extensions/DispatchQueueLogFormatter.m +251 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/ObjectiveMixin/Mixin.h +33 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/ObjectiveMixin/Mixin.m +122 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Underscore/USArrayWrapper.h +72 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Underscore/USArrayWrapper.m +305 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Underscore/USConstants.h +38 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Underscore/USDictionaryWrapper.h +57 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Underscore/USDictionaryWrapper.m +188 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Underscore/Underscore+Functional.h +89 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Underscore/Underscore+Functional.m +261 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Underscore/Underscore-Prefix.pch +7 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Underscore/Underscore.h +50 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Underscore/Underscore.m +100 -0
- data/lib/appjam/generators/templates/blank/EiffelApplication/main.m.tt +18 -0
- data/lib/appjam/generators/templates/blank/EiffelApplicationTests/EiffelApplicationTests-Info.plist +22 -0
- data/lib/appjam/generators/templates/blank/EiffelApplicationTests/EiffelApplicationTests.h.tt +13 -0
- data/lib/appjam/generators/templates/blank/EiffelApplicationTests/EiffelApplicationTests.m.tt +32 -0
- data/lib/appjam/generators/templates/blank/EiffelApplicationTests/en.lproj/InfoPlist.strings +2 -0
- data/lib/appjam/generators/templates/resources/Default-568h@2x.png +0 -0
- data/lib/appjam/generators/templates/resources/Default.png +0 -0
- data/lib/appjam/generators/templates/resources/Default@2x.png +0 -0
- data/lib/appjam/generators/templates/resources/contents.tt +4 -0
- data/lib/appjam/version.rb +1 -1
- metadata +462 -326
- data/test/helper.rb +0 -132
- data/test/test_model_generator.rb +0 -28
- data/test/test_project_generator.rb +0 -38
@@ -0,0 +1,75 @@
|
|
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 defined(__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
|
+
+ (instancetype)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
|
@@ -0,0 +1,145 @@
|
|
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 defined(__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
|
+
+ (instancetype)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(networkingOperationDidStart:) name:AFNetworkingOperationDidStartNotification object:nil];
|
66
|
+
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkingOperationDidFinish:) 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
|
+
- (void)networkingOperationDidStart:(NSNotification *)notification {
|
130
|
+
AFURLConnectionOperation *connectionOperation = [notification object];
|
131
|
+
if (connectionOperation.request.URL) {
|
132
|
+
[self incrementActivityCount];
|
133
|
+
}
|
134
|
+
}
|
135
|
+
|
136
|
+
- (void)networkingOperationDidFinish:(NSNotification *)notification {
|
137
|
+
AFURLConnectionOperation *connectionOperation = [notification object];
|
138
|
+
if (connectionOperation.request.URL) {
|
139
|
+
[self decrementActivityCount];
|
140
|
+
}
|
141
|
+
}
|
142
|
+
|
143
|
+
@end
|
144
|
+
|
145
|
+
#endif
|
@@ -0,0 +1,43 @@
|
|
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 defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
|
40
|
+
#import "AFNetworkActivityIndicatorManager.h"
|
41
|
+
#import "UIImageView+AFNetworking.h"
|
42
|
+
#endif
|
43
|
+
#endif /* _AFNETWORKING_ */
|
@@ -0,0 +1,68 @@
|
|
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
|
+
+ (instancetype)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
|
@@ -0,0 +1,142 @@
|
|
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 property_list_request_operation_processing_queue() {
|
26
|
+
static dispatch_queue_t af_property_list_request_operation_processing_queue;
|
27
|
+
static dispatch_once_t onceToken;
|
28
|
+
dispatch_once(&onceToken, ^{
|
29
|
+
af_property_list_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.property-list-request.processing", DISPATCH_QUEUE_CONCURRENT);
|
30
|
+
});
|
31
|
+
|
32
|
+
return af_property_list_request_operation_processing_queue;
|
33
|
+
}
|
34
|
+
|
35
|
+
@interface AFPropertyListRequestOperation ()
|
36
|
+
@property (readwrite, nonatomic) id responsePropertyList;
|
37
|
+
@property (readwrite, nonatomic, assign) NSPropertyListFormat propertyListFormat;
|
38
|
+
@property (readwrite, nonatomic) NSError *propertyListError;
|
39
|
+
@end
|
40
|
+
|
41
|
+
@implementation AFPropertyListRequestOperation
|
42
|
+
@synthesize responsePropertyList = _responsePropertyList;
|
43
|
+
@synthesize propertyListReadOptions = _propertyListReadOptions;
|
44
|
+
@synthesize propertyListFormat = _propertyListFormat;
|
45
|
+
@synthesize propertyListError = _propertyListError;
|
46
|
+
|
47
|
+
+ (instancetype)propertyListRequestOperationWithRequest:(NSURLRequest *)request
|
48
|
+
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id propertyList))success
|
49
|
+
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id propertyList))failure
|
50
|
+
{
|
51
|
+
AFPropertyListRequestOperation *requestOperation = [(AFPropertyListRequestOperation *)[self alloc] initWithRequest:request];
|
52
|
+
[requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
|
53
|
+
if (success) {
|
54
|
+
success(operation.request, operation.response, responseObject);
|
55
|
+
}
|
56
|
+
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
|
57
|
+
if (failure) {
|
58
|
+
failure(operation.request, operation.response, error, [(AFPropertyListRequestOperation *)operation responsePropertyList]);
|
59
|
+
}
|
60
|
+
}];
|
61
|
+
|
62
|
+
return requestOperation;
|
63
|
+
}
|
64
|
+
|
65
|
+
- (id)initWithRequest:(NSURLRequest *)urlRequest {
|
66
|
+
self = [super initWithRequest:urlRequest];
|
67
|
+
if (!self) {
|
68
|
+
return nil;
|
69
|
+
}
|
70
|
+
|
71
|
+
self.propertyListReadOptions = NSPropertyListImmutable;
|
72
|
+
|
73
|
+
return self;
|
74
|
+
}
|
75
|
+
|
76
|
+
|
77
|
+
- (id)responsePropertyList {
|
78
|
+
if (!_responsePropertyList && [self.responseData length] > 0 && [self isFinished]) {
|
79
|
+
NSPropertyListFormat format;
|
80
|
+
NSError *error = nil;
|
81
|
+
self.responsePropertyList = [NSPropertyListSerialization propertyListWithData:self.responseData options:self.propertyListReadOptions format:&format error:&error];
|
82
|
+
self.propertyListFormat = format;
|
83
|
+
self.propertyListError = error;
|
84
|
+
}
|
85
|
+
|
86
|
+
return _responsePropertyList;
|
87
|
+
}
|
88
|
+
|
89
|
+
- (NSError *)error {
|
90
|
+
if (_propertyListError) {
|
91
|
+
return _propertyListError;
|
92
|
+
} else {
|
93
|
+
return [super error];
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
#pragma mark - AFHTTPRequestOperation
|
98
|
+
|
99
|
+
+ (NSSet *)acceptableContentTypes {
|
100
|
+
return [NSSet setWithObjects:@"application/x-plist", nil];
|
101
|
+
}
|
102
|
+
|
103
|
+
+ (BOOL)canProcessRequest:(NSURLRequest *)request {
|
104
|
+
return [[[request URL] pathExtension] isEqualToString:@"plist"] || [super canProcessRequest:request];
|
105
|
+
}
|
106
|
+
|
107
|
+
- (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
|
108
|
+
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
|
109
|
+
{
|
110
|
+
#pragma clang diagnostic push
|
111
|
+
#pragma clang diagnostic ignored "-Warc-retain-cycles"
|
112
|
+
self.completionBlock = ^ {
|
113
|
+
if (self.error) {
|
114
|
+
if (failure) {
|
115
|
+
dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{
|
116
|
+
failure(self, self.error);
|
117
|
+
});
|
118
|
+
}
|
119
|
+
} else {
|
120
|
+
dispatch_async(property_list_request_operation_processing_queue(), ^(void) {
|
121
|
+
id propertyList = self.responsePropertyList;
|
122
|
+
|
123
|
+
if (self.propertyListError) {
|
124
|
+
if (failure) {
|
125
|
+
dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{
|
126
|
+
failure(self, self.error);
|
127
|
+
});
|
128
|
+
}
|
129
|
+
} else {
|
130
|
+
if (success) {
|
131
|
+
dispatch_async(self.successCallbackQueue ?: dispatch_get_main_queue(), ^{
|
132
|
+
success(self, propertyList);
|
133
|
+
});
|
134
|
+
}
|
135
|
+
}
|
136
|
+
});
|
137
|
+
}
|
138
|
+
};
|
139
|
+
#pragma clang diagnostic pop
|
140
|
+
}
|
141
|
+
|
142
|
+
@end
|