├── LICENSE ├── README.md └── ZCNetworking ├── Podfile ├── Podfile.lock ├── Pods ├── AFNetworking │ ├── AFNetworking │ │ ├── AFHTTPSessionManager.h │ │ ├── AFHTTPSessionManager.m │ │ ├── AFNetworkReachabilityManager.h │ │ ├── AFNetworkReachabilityManager.m │ │ ├── AFNetworking.h │ │ ├── AFSecurityPolicy.h │ │ ├── AFSecurityPolicy.m │ │ ├── AFURLRequestSerialization.h │ │ ├── AFURLRequestSerialization.m │ │ ├── AFURLResponseSerialization.h │ │ ├── AFURLResponseSerialization.m │ │ ├── AFURLSessionManager.h │ │ └── AFURLSessionManager.m │ ├── LICENSE │ ├── README.md │ └── UIKit+AFNetworking │ │ ├── AFAutoPurgingImageCache.h │ │ ├── AFAutoPurgingImageCache.m │ │ ├── AFImageDownloader.h │ │ ├── AFImageDownloader.m │ │ ├── AFNetworkActivityIndicatorManager.h │ │ ├── AFNetworkActivityIndicatorManager.m │ │ ├── UIActivityIndicatorView+AFNetworking.h │ │ ├── UIActivityIndicatorView+AFNetworking.m │ │ ├── UIButton+AFNetworking.h │ │ ├── UIButton+AFNetworking.m │ │ ├── UIImage+AFNetworking.h │ │ ├── UIImageView+AFNetworking.h │ │ ├── UIImageView+AFNetworking.m │ │ ├── UIKit+AFNetworking.h │ │ ├── UIProgressView+AFNetworking.h │ │ ├── UIProgressView+AFNetworking.m │ │ ├── UIRefreshControl+AFNetworking.h │ │ ├── UIRefreshControl+AFNetworking.m │ │ ├── UIWebView+AFNetworking.h │ │ └── UIWebView+AFNetworking.m ├── Headers │ ├── Private │ │ └── AFNetworking │ │ │ ├── AFAutoPurgingImageCache.h │ │ │ ├── AFHTTPSessionManager.h │ │ │ ├── AFImageDownloader.h │ │ │ ├── AFNetworkActivityIndicatorManager.h │ │ │ ├── AFNetworkReachabilityManager.h │ │ │ ├── AFNetworking.h │ │ │ ├── AFSecurityPolicy.h │ │ │ ├── AFURLRequestSerialization.h │ │ │ ├── AFURLResponseSerialization.h │ │ │ ├── AFURLSessionManager.h │ │ │ ├── UIActivityIndicatorView+AFNetworking.h │ │ │ ├── UIButton+AFNetworking.h │ │ │ ├── UIImage+AFNetworking.h │ │ │ ├── UIImageView+AFNetworking.h │ │ │ ├── UIKit+AFNetworking.h │ │ │ ├── UIProgressView+AFNetworking.h │ │ │ ├── UIRefreshControl+AFNetworking.h │ │ │ └── UIWebView+AFNetworking.h │ └── Public │ │ └── AFNetworking │ │ ├── AFAutoPurgingImageCache.h │ │ ├── AFHTTPSessionManager.h │ │ ├── AFImageDownloader.h │ │ ├── AFNetworkActivityIndicatorManager.h │ │ ├── AFNetworkReachabilityManager.h │ │ ├── AFNetworking.h │ │ ├── AFSecurityPolicy.h │ │ ├── AFURLRequestSerialization.h │ │ ├── AFURLResponseSerialization.h │ │ ├── AFURLSessionManager.h │ │ ├── UIActivityIndicatorView+AFNetworking.h │ │ ├── UIButton+AFNetworking.h │ │ ├── UIImage+AFNetworking.h │ │ ├── UIImageView+AFNetworking.h │ │ ├── UIKit+AFNetworking.h │ │ ├── UIProgressView+AFNetworking.h │ │ ├── UIRefreshControl+AFNetworking.h │ │ └── UIWebView+AFNetworking.h ├── Manifest.lock ├── Pods.xcodeproj │ ├── project.pbxproj │ └── xcuserdata │ │ └── charles.xcuserdatad │ │ └── xcschemes │ │ ├── AFNetworking.xcscheme │ │ ├── Pods-ZCNetworking.xcscheme │ │ └── xcschememanagement.plist └── Target Support Files │ ├── AFNetworking │ ├── AFNetworking-dummy.m │ ├── AFNetworking-prefix.pch │ └── AFNetworking.xcconfig │ └── Pods-ZCNetworking │ ├── Pods-ZCNetworking-acknowledgements.markdown │ ├── Pods-ZCNetworking-acknowledgements.plist │ ├── Pods-ZCNetworking-dummy.m │ ├── Pods-ZCNetworking-frameworks.sh │ ├── Pods-ZCNetworking-resources.sh │ ├── Pods-ZCNetworking.debug.xcconfig │ └── Pods-ZCNetworking.release.xcconfig ├── ZCNetworking.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── charles.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── charles.xcuserdatad │ └── xcschemes │ ├── ZCNetworking.xcscheme │ └── xcschememanagement.plist ├── ZCNetworking.xcworkspace ├── contents.xcworkspacedata └── xcuserdata │ └── charles.xcuserdatad │ ├── UserInterfaceState.xcuserstate │ └── xcdebugger │ └── Breakpoints_v2.xcbkptlist ├── ZCNetworking ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── Sources │ ├── ZCApiAction.h │ ├── ZCApiAction.m │ ├── ZCApiDownloadAction.h │ ├── ZCApiDownloadAction.m │ ├── ZCApiLauncher.h │ ├── ZCApiRunner.h │ ├── ZCApiRunner.m │ ├── ZCApiUploadAction.h │ ├── ZCApiUploadAction.m │ ├── ZCBlockDefine.h │ ├── ZCChainProcessor.h │ ├── ZCChainProcessor.m │ ├── ZCNetworking.h │ └── ZCNetworking.m ├── ViewController.h ├── ViewController.m └── main.m ├── ZCNetworkingTests ├── Info.plist └── ZCNetworkingTests.m └── ZCNetworkingUITests ├── Info.plist └── ZCNetworkingUITests.m /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 ooppstef 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 all 13 | 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 THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ZCNetworking 2 | [讨论一个网络库的正确姿势?](http://www.jianshu.com/p/27e6100b0d67) 3 | 4 | 5 | -------------------------------------------------------------------------------- /ZCNetworking/Podfile: -------------------------------------------------------------------------------- 1 | platform :ios, '7.0' 2 | 3 | target ‘ZCNetworking’ do 4 | 5 | pod 'AFNetworking' 6 | 7 | end -------------------------------------------------------------------------------- /ZCNetworking/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - AFNetworking (3.1.0): 3 | - AFNetworking/NSURLSession (= 3.1.0) 4 | - AFNetworking/Reachability (= 3.1.0) 5 | - AFNetworking/Security (= 3.1.0) 6 | - AFNetworking/Serialization (= 3.1.0) 7 | - AFNetworking/UIKit (= 3.1.0) 8 | - AFNetworking/NSURLSession (3.1.0): 9 | - AFNetworking/Reachability 10 | - AFNetworking/Security 11 | - AFNetworking/Serialization 12 | - AFNetworking/Reachability (3.1.0) 13 | - AFNetworking/Security (3.1.0) 14 | - AFNetworking/Serialization (3.1.0) 15 | - AFNetworking/UIKit (3.1.0): 16 | - AFNetworking/NSURLSession 17 | 18 | DEPENDENCIES: 19 | - AFNetworking 20 | 21 | SPEC CHECKSUMS: 22 | AFNetworking: 5e0e199f73d8626b11e79750991f5d173d1f8b67 23 | 24 | PODFILE CHECKSUM: 4eb686940e507bf97379ed297dd0d934c39708ff 25 | 26 | COCOAPODS: 1.0.0.beta.6 27 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.h: -------------------------------------------------------------------------------- 1 | // AFNetworkReachabilityManager.h 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #if !TARGET_OS_WATCH 25 | #import 26 | 27 | typedef NS_ENUM(NSInteger, AFNetworkReachabilityStatus) { 28 | AFNetworkReachabilityStatusUnknown = -1, 29 | AFNetworkReachabilityStatusNotReachable = 0, 30 | AFNetworkReachabilityStatusReachableViaWWAN = 1, 31 | AFNetworkReachabilityStatusReachableViaWiFi = 2, 32 | }; 33 | 34 | NS_ASSUME_NONNULL_BEGIN 35 | 36 | /** 37 | `AFNetworkReachabilityManager` monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces. 38 | 39 | Reachability can be used to determine background information about why a network operation failed, or to trigger a network operation retrying when a connection is established. It should not be used to prevent a user from initiating a network request, as it's possible that an initial request may be required to establish reachability. 40 | 41 | See Apple's Reachability Sample Code ( https://developer.apple.com/library/ios/samplecode/reachability/ ) 42 | 43 | @warning Instances of `AFNetworkReachabilityManager` must be started with `-startMonitoring` before reachability status can be determined. 44 | */ 45 | @interface AFNetworkReachabilityManager : NSObject 46 | 47 | /** 48 | The current network reachability status. 49 | */ 50 | @property (readonly, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus; 51 | 52 | /** 53 | Whether or not the network is currently reachable. 54 | */ 55 | @property (readonly, nonatomic, assign, getter = isReachable) BOOL reachable; 56 | 57 | /** 58 | Whether or not the network is currently reachable via WWAN. 59 | */ 60 | @property (readonly, nonatomic, assign, getter = isReachableViaWWAN) BOOL reachableViaWWAN; 61 | 62 | /** 63 | Whether or not the network is currently reachable via WiFi. 64 | */ 65 | @property (readonly, nonatomic, assign, getter = isReachableViaWiFi) BOOL reachableViaWiFi; 66 | 67 | ///--------------------- 68 | /// @name Initialization 69 | ///--------------------- 70 | 71 | /** 72 | Returns the shared network reachability manager. 73 | */ 74 | + (instancetype)sharedManager; 75 | 76 | /** 77 | Creates and returns a network reachability manager with the default socket address. 78 | 79 | @return An initialized network reachability manager, actively monitoring the default socket address. 80 | */ 81 | + (instancetype)manager; 82 | 83 | /** 84 | Creates and returns a network reachability manager for the specified domain. 85 | 86 | @param domain The domain used to evaluate network reachability. 87 | 88 | @return An initialized network reachability manager, actively monitoring the specified domain. 89 | */ 90 | + (instancetype)managerForDomain:(NSString *)domain; 91 | 92 | /** 93 | Creates and returns a network reachability manager for the socket address. 94 | 95 | @param address The socket address (`sockaddr_in6`) used to evaluate network reachability. 96 | 97 | @return An initialized network reachability manager, actively monitoring the specified socket address. 98 | */ 99 | + (instancetype)managerForAddress:(const void *)address; 100 | 101 | /** 102 | Initializes an instance of a network reachability manager from the specified reachability object. 103 | 104 | @param reachability The reachability object to monitor. 105 | 106 | @return An initialized network reachability manager, actively monitoring the specified reachability. 107 | */ 108 | - (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability NS_DESIGNATED_INITIALIZER; 109 | 110 | ///-------------------------------------------------- 111 | /// @name Starting & Stopping Reachability Monitoring 112 | ///-------------------------------------------------- 113 | 114 | /** 115 | Starts monitoring for changes in network reachability status. 116 | */ 117 | - (void)startMonitoring; 118 | 119 | /** 120 | Stops monitoring for changes in network reachability status. 121 | */ 122 | - (void)stopMonitoring; 123 | 124 | ///------------------------------------------------- 125 | /// @name Getting Localized Reachability Description 126 | ///------------------------------------------------- 127 | 128 | /** 129 | Returns a localized string representation of the current network reachability status. 130 | */ 131 | - (NSString *)localizedNetworkReachabilityStatusString; 132 | 133 | ///--------------------------------------------------- 134 | /// @name Setting Network Reachability Change Callback 135 | ///--------------------------------------------------- 136 | 137 | /** 138 | Sets a callback to be executed when the network availability of the `baseURL` host changes. 139 | 140 | @param block A block object to be executed when the network availability of the `baseURL` host changes.. This block has no return value and takes a single argument which represents the various reachability states from the device to the `baseURL`. 141 | */ 142 | - (void)setReachabilityStatusChangeBlock:(nullable void (^)(AFNetworkReachabilityStatus status))block; 143 | 144 | @end 145 | 146 | ///---------------- 147 | /// @name Constants 148 | ///---------------- 149 | 150 | /** 151 | ## Network Reachability 152 | 153 | The following constants are provided by `AFNetworkReachabilityManager` as possible network reachability statuses. 154 | 155 | enum { 156 | AFNetworkReachabilityStatusUnknown, 157 | AFNetworkReachabilityStatusNotReachable, 158 | AFNetworkReachabilityStatusReachableViaWWAN, 159 | AFNetworkReachabilityStatusReachableViaWiFi, 160 | } 161 | 162 | `AFNetworkReachabilityStatusUnknown` 163 | The `baseURL` host reachability is not known. 164 | 165 | `AFNetworkReachabilityStatusNotReachable` 166 | The `baseURL` host cannot be reached. 167 | 168 | `AFNetworkReachabilityStatusReachableViaWWAN` 169 | The `baseURL` host can be reached via a cellular connection, such as EDGE or GPRS. 170 | 171 | `AFNetworkReachabilityStatusReachableViaWiFi` 172 | The `baseURL` host can be reached via a Wi-Fi connection. 173 | 174 | ### Keys for Notification UserInfo Dictionary 175 | 176 | Strings that are used as keys in a `userInfo` dictionary in a network reachability status change notification. 177 | 178 | `AFNetworkingReachabilityNotificationStatusItem` 179 | A key in the userInfo dictionary in a `AFNetworkingReachabilityDidChangeNotification` notification. 180 | The corresponding value is an `NSNumber` object representing the `AFNetworkReachabilityStatus` value for the current reachability status. 181 | */ 182 | 183 | ///-------------------- 184 | /// @name Notifications 185 | ///-------------------- 186 | 187 | /** 188 | Posted when network reachability changes. 189 | This notification assigns no notification object. The `userInfo` dictionary contains an `NSNumber` object under the `AFNetworkingReachabilityNotificationStatusItem` key, representing the `AFNetworkReachabilityStatus` value for the current network reachability. 190 | 191 | @warning In order for network reachability to be monitored, include the `SystemConfiguration` framework in the active target's "Link Binary With Library" build phase, and add `#import ` to the header prefix of the project (`Prefix.pch`). 192 | */ 193 | FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityDidChangeNotification; 194 | FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityNotificationStatusItem; 195 | 196 | ///-------------------- 197 | /// @name Functions 198 | ///-------------------- 199 | 200 | /** 201 | Returns a localized string representation of an `AFNetworkReachabilityStatus` value. 202 | */ 203 | FOUNDATION_EXPORT NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status); 204 | 205 | NS_ASSUME_NONNULL_END 206 | #endif 207 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.m: -------------------------------------------------------------------------------- 1 | // AFNetworkReachabilityManager.m 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import "AFNetworkReachabilityManager.h" 23 | #if !TARGET_OS_WATCH 24 | 25 | #import 26 | #import 27 | #import 28 | #import 29 | #import 30 | 31 | NSString * const AFNetworkingReachabilityDidChangeNotification = @"com.alamofire.networking.reachability.change"; 32 | NSString * const AFNetworkingReachabilityNotificationStatusItem = @"AFNetworkingReachabilityNotificationStatusItem"; 33 | 34 | typedef void (^AFNetworkReachabilityStatusBlock)(AFNetworkReachabilityStatus status); 35 | 36 | NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status) { 37 | switch (status) { 38 | case AFNetworkReachabilityStatusNotReachable: 39 | return NSLocalizedStringFromTable(@"Not Reachable", @"AFNetworking", nil); 40 | case AFNetworkReachabilityStatusReachableViaWWAN: 41 | return NSLocalizedStringFromTable(@"Reachable via WWAN", @"AFNetworking", nil); 42 | case AFNetworkReachabilityStatusReachableViaWiFi: 43 | return NSLocalizedStringFromTable(@"Reachable via WiFi", @"AFNetworking", nil); 44 | case AFNetworkReachabilityStatusUnknown: 45 | default: 46 | return NSLocalizedStringFromTable(@"Unknown", @"AFNetworking", nil); 47 | } 48 | } 49 | 50 | static AFNetworkReachabilityStatus AFNetworkReachabilityStatusForFlags(SCNetworkReachabilityFlags flags) { 51 | BOOL isReachable = ((flags & kSCNetworkReachabilityFlagsReachable) != 0); 52 | BOOL needsConnection = ((flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0); 53 | BOOL canConnectionAutomatically = (((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0) || ((flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0)); 54 | BOOL canConnectWithoutUserInteraction = (canConnectionAutomatically && (flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0); 55 | BOOL isNetworkReachable = (isReachable && (!needsConnection || canConnectWithoutUserInteraction)); 56 | 57 | AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusUnknown; 58 | if (isNetworkReachable == NO) { 59 | status = AFNetworkReachabilityStatusNotReachable; 60 | } 61 | #if TARGET_OS_IPHONE 62 | else if ((flags & kSCNetworkReachabilityFlagsIsWWAN) != 0) { 63 | status = AFNetworkReachabilityStatusReachableViaWWAN; 64 | } 65 | #endif 66 | else { 67 | status = AFNetworkReachabilityStatusReachableViaWiFi; 68 | } 69 | 70 | return status; 71 | } 72 | 73 | /** 74 | * Queue a status change notification for the main thread. 75 | * 76 | * This is done to ensure that the notifications are received in the same order 77 | * as they are sent. If notifications are sent directly, it is possible that 78 | * a queued notification (for an earlier status condition) is processed after 79 | * the later update, resulting in the listener being left in the wrong state. 80 | */ 81 | static void AFPostReachabilityStatusChange(SCNetworkReachabilityFlags flags, AFNetworkReachabilityStatusBlock block) { 82 | AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusForFlags(flags); 83 | dispatch_async(dispatch_get_main_queue(), ^{ 84 | if (block) { 85 | block(status); 86 | } 87 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 88 | NSDictionary *userInfo = @{ AFNetworkingReachabilityNotificationStatusItem: @(status) }; 89 | [notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:userInfo]; 90 | }); 91 | } 92 | 93 | static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNetworkReachabilityFlags flags, void *info) { 94 | AFPostReachabilityStatusChange(flags, (__bridge AFNetworkReachabilityStatusBlock)info); 95 | } 96 | 97 | 98 | static const void * AFNetworkReachabilityRetainCallback(const void *info) { 99 | return Block_copy(info); 100 | } 101 | 102 | static void AFNetworkReachabilityReleaseCallback(const void *info) { 103 | if (info) { 104 | Block_release(info); 105 | } 106 | } 107 | 108 | @interface AFNetworkReachabilityManager () 109 | @property (readonly, nonatomic, assign) SCNetworkReachabilityRef networkReachability; 110 | @property (readwrite, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus; 111 | @property (readwrite, nonatomic, copy) AFNetworkReachabilityStatusBlock networkReachabilityStatusBlock; 112 | @end 113 | 114 | @implementation AFNetworkReachabilityManager 115 | 116 | + (instancetype)sharedManager { 117 | static AFNetworkReachabilityManager *_sharedManager = nil; 118 | static dispatch_once_t onceToken; 119 | dispatch_once(&onceToken, ^{ 120 | _sharedManager = [self manager]; 121 | }); 122 | 123 | return _sharedManager; 124 | } 125 | 126 | + (instancetype)managerForDomain:(NSString *)domain { 127 | SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, [domain UTF8String]); 128 | 129 | AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability]; 130 | 131 | CFRelease(reachability); 132 | 133 | return manager; 134 | } 135 | 136 | + (instancetype)managerForAddress:(const void *)address { 137 | SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr *)address); 138 | AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability]; 139 | 140 | CFRelease(reachability); 141 | 142 | return manager; 143 | } 144 | 145 | + (instancetype)manager 146 | { 147 | #if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90000) || (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 148 | struct sockaddr_in6 address; 149 | bzero(&address, sizeof(address)); 150 | address.sin6_len = sizeof(address); 151 | address.sin6_family = AF_INET6; 152 | #else 153 | struct sockaddr_in address; 154 | bzero(&address, sizeof(address)); 155 | address.sin_len = sizeof(address); 156 | address.sin_family = AF_INET; 157 | #endif 158 | return [self managerForAddress:&address]; 159 | } 160 | 161 | - (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability { 162 | self = [super init]; 163 | if (!self) { 164 | return nil; 165 | } 166 | 167 | _networkReachability = CFRetain(reachability); 168 | self.networkReachabilityStatus = AFNetworkReachabilityStatusUnknown; 169 | 170 | return self; 171 | } 172 | 173 | - (instancetype)init NS_UNAVAILABLE 174 | { 175 | return nil; 176 | } 177 | 178 | - (void)dealloc { 179 | [self stopMonitoring]; 180 | 181 | if (_networkReachability != NULL) { 182 | CFRelease(_networkReachability); 183 | } 184 | } 185 | 186 | #pragma mark - 187 | 188 | - (BOOL)isReachable { 189 | return [self isReachableViaWWAN] || [self isReachableViaWiFi]; 190 | } 191 | 192 | - (BOOL)isReachableViaWWAN { 193 | return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWWAN; 194 | } 195 | 196 | - (BOOL)isReachableViaWiFi { 197 | return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWiFi; 198 | } 199 | 200 | #pragma mark - 201 | 202 | - (void)startMonitoring { 203 | [self stopMonitoring]; 204 | 205 | if (!self.networkReachability) { 206 | return; 207 | } 208 | 209 | __weak __typeof(self)weakSelf = self; 210 | AFNetworkReachabilityStatusBlock callback = ^(AFNetworkReachabilityStatus status) { 211 | __strong __typeof(weakSelf)strongSelf = weakSelf; 212 | 213 | strongSelf.networkReachabilityStatus = status; 214 | if (strongSelf.networkReachabilityStatusBlock) { 215 | strongSelf.networkReachabilityStatusBlock(status); 216 | } 217 | 218 | }; 219 | 220 | SCNetworkReachabilityContext context = {0, (__bridge void *)callback, AFNetworkReachabilityRetainCallback, AFNetworkReachabilityReleaseCallback, NULL}; 221 | SCNetworkReachabilitySetCallback(self.networkReachability, AFNetworkReachabilityCallback, &context); 222 | SCNetworkReachabilityScheduleWithRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes); 223 | 224 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0),^{ 225 | SCNetworkReachabilityFlags flags; 226 | if (SCNetworkReachabilityGetFlags(self.networkReachability, &flags)) { 227 | AFPostReachabilityStatusChange(flags, callback); 228 | } 229 | }); 230 | } 231 | 232 | - (void)stopMonitoring { 233 | if (!self.networkReachability) { 234 | return; 235 | } 236 | 237 | SCNetworkReachabilityUnscheduleFromRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes); 238 | } 239 | 240 | #pragma mark - 241 | 242 | - (NSString *)localizedNetworkReachabilityStatusString { 243 | return AFStringFromNetworkReachabilityStatus(self.networkReachabilityStatus); 244 | } 245 | 246 | #pragma mark - 247 | 248 | - (void)setReachabilityStatusChangeBlock:(void (^)(AFNetworkReachabilityStatus status))block { 249 | self.networkReachabilityStatusBlock = block; 250 | } 251 | 252 | #pragma mark - NSKeyValueObserving 253 | 254 | + (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key { 255 | if ([key isEqualToString:@"reachable"] || [key isEqualToString:@"reachableViaWWAN"] || [key isEqualToString:@"reachableViaWiFi"]) { 256 | return [NSSet setWithObject:@"networkReachabilityStatus"]; 257 | } 258 | 259 | return [super keyPathsForValuesAffectingValueForKey:key]; 260 | } 261 | 262 | @end 263 | #endif 264 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/AFNetworking/AFNetworking/AFNetworking.h: -------------------------------------------------------------------------------- 1 | // AFNetworking.h 2 | // 3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.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 24 | #import 25 | #import 26 | 27 | #ifndef _AFNETWORKING_ 28 | #define _AFNETWORKING_ 29 | 30 | #import "AFURLRequestSerialization.h" 31 | #import "AFURLResponseSerialization.h" 32 | #import "AFSecurityPolicy.h" 33 | 34 | #if !TARGET_OS_WATCH 35 | #import "AFNetworkReachabilityManager.h" 36 | #endif 37 | 38 | #import "AFURLSessionManager.h" 39 | #import "AFHTTPSessionManager.h" 40 | 41 | #endif /* _AFNETWORKING_ */ 42 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.h: -------------------------------------------------------------------------------- 1 | // AFSecurityPolicy.h 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | #import 24 | 25 | typedef NS_ENUM(NSUInteger, AFSSLPinningMode) { 26 | AFSSLPinningModeNone, 27 | AFSSLPinningModePublicKey, 28 | AFSSLPinningModeCertificate, 29 | }; 30 | 31 | /** 32 | `AFSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections. 33 | 34 | Adding pinned SSL certificates to your app helps prevent man-in-the-middle attacks and other vulnerabilities. Applications dealing with sensitive customer data or financial information are strongly encouraged to route all communication over an HTTPS connection with SSL pinning configured and enabled. 35 | */ 36 | 37 | NS_ASSUME_NONNULL_BEGIN 38 | 39 | @interface AFSecurityPolicy : NSObject 40 | 41 | /** 42 | The criteria by which server trust should be evaluated against the pinned SSL certificates. Defaults to `AFSSLPinningModeNone`. 43 | */ 44 | @property (readonly, nonatomic, assign) AFSSLPinningMode SSLPinningMode; 45 | 46 | /** 47 | The certificates used to evaluate server trust according to the SSL pinning mode. 48 | 49 | By default, this property is set to any (`.cer`) certificates included in the target compiling AFNetworking. Note that if you are using AFNetworking as embedded framework, no certificates will be pinned by default. Use `certificatesInBundle` to load certificates from your target, and then create a new policy by calling `policyWithPinningMode:withPinnedCertificates`. 50 | 51 | Note that if pinning is enabled, `evaluateServerTrust:forDomain:` will return true if any pinned certificate matches. 52 | */ 53 | @property (nonatomic, strong, nullable) NSSet *pinnedCertificates; 54 | 55 | /** 56 | Whether or not to trust servers with an invalid or expired SSL certificates. Defaults to `NO`. 57 | */ 58 | @property (nonatomic, assign) BOOL allowInvalidCertificates; 59 | 60 | /** 61 | Whether or not to validate the domain name in the certificate's CN field. Defaults to `YES`. 62 | */ 63 | @property (nonatomic, assign) BOOL validatesDomainName; 64 | 65 | ///----------------------------------------- 66 | /// @name Getting Certificates from the Bundle 67 | ///----------------------------------------- 68 | 69 | /** 70 | Returns any certificates included in the bundle. If you are using AFNetworking as an embedded framework, you must use this method to find the certificates you have included in your app bundle, and use them when creating your security policy by calling `policyWithPinningMode:withPinnedCertificates`. 71 | 72 | @return The certificates included in the given bundle. 73 | */ 74 | + (NSSet *)certificatesInBundle:(NSBundle *)bundle; 75 | 76 | ///----------------------------------------- 77 | /// @name Getting Specific Security Policies 78 | ///----------------------------------------- 79 | 80 | /** 81 | Returns the shared default security policy, which does not allow invalid certificates, validates domain name, and does not validate against pinned certificates or public keys. 82 | 83 | @return The default security policy. 84 | */ 85 | + (instancetype)defaultPolicy; 86 | 87 | ///--------------------- 88 | /// @name Initialization 89 | ///--------------------- 90 | 91 | /** 92 | Creates and returns a security policy with the specified pinning mode. 93 | 94 | @param pinningMode The SSL pinning mode. 95 | 96 | @return A new security policy. 97 | */ 98 | + (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode; 99 | 100 | /** 101 | Creates and returns a security policy with the specified pinning mode. 102 | 103 | @param pinningMode The SSL pinning mode. 104 | @param pinnedCertificates The certificates to pin against. 105 | 106 | @return A new security policy. 107 | */ 108 | + (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode withPinnedCertificates:(NSSet *)pinnedCertificates; 109 | 110 | ///------------------------------ 111 | /// @name Evaluating Server Trust 112 | ///------------------------------ 113 | 114 | /** 115 | Whether or not the specified server trust should be accepted, based on the security policy. 116 | 117 | This method should be used when responding to an authentication challenge from a server. 118 | 119 | @param serverTrust The X.509 certificate trust of the server. 120 | @param domain The domain of serverTrust. If `nil`, the domain will not be validated. 121 | 122 | @return Whether or not to trust the server. 123 | */ 124 | - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust 125 | forDomain:(nullable NSString *)domain; 126 | 127 | @end 128 | 129 | NS_ASSUME_NONNULL_END 130 | 131 | ///---------------- 132 | /// @name Constants 133 | ///---------------- 134 | 135 | /** 136 | ## SSL Pinning Modes 137 | 138 | The following constants are provided by `AFSSLPinningMode` as possible SSL pinning modes. 139 | 140 | enum { 141 | AFSSLPinningModeNone, 142 | AFSSLPinningModePublicKey, 143 | AFSSLPinningModeCertificate, 144 | } 145 | 146 | `AFSSLPinningModeNone` 147 | Do not used pinned certificates to validate servers. 148 | 149 | `AFSSLPinningModePublicKey` 150 | Validate host certificates against public keys of pinned certificates. 151 | 152 | `AFSSLPinningModeCertificate` 153 | Validate host certificates against pinned certificates. 154 | */ 155 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/AFNetworking/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011–2016 Alamofire Software Foundation (http://alamofire.org/) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.h: -------------------------------------------------------------------------------- 1 | // AFAutoPurgingImageCache.h 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | #import 24 | 25 | #if TARGET_OS_IOS || TARGET_OS_TV 26 | #import 27 | 28 | NS_ASSUME_NONNULL_BEGIN 29 | 30 | /** 31 | The `AFImageCache` protocol defines a set of APIs for adding, removing and fetching images from a cache synchronously. 32 | */ 33 | @protocol AFImageCache 34 | 35 | /** 36 | Adds the image to the cache with the given identifier. 37 | 38 | @param image The image to cache. 39 | @param identifier The unique identifier for the image in the cache. 40 | */ 41 | - (void)addImage:(UIImage *)image withIdentifier:(NSString *)identifier; 42 | 43 | /** 44 | Removes the image from the cache matching the given identifier. 45 | 46 | @param identifier The unique identifier for the image in the cache. 47 | 48 | @return A BOOL indicating whether or not the image was removed from the cache. 49 | */ 50 | - (BOOL)removeImageWithIdentifier:(NSString *)identifier; 51 | 52 | /** 53 | Removes all images from the cache. 54 | 55 | @return A BOOL indicating whether or not all images were removed from the cache. 56 | */ 57 | - (BOOL)removeAllImages; 58 | 59 | /** 60 | Returns the image in the cache associated with the given identifier. 61 | 62 | @param identifier The unique identifier for the image in the cache. 63 | 64 | @return An image for the matching identifier, or nil. 65 | */ 66 | - (nullable UIImage *)imageWithIdentifier:(NSString *)identifier; 67 | @end 68 | 69 | 70 | /** 71 | The `ImageRequestCache` protocol extends the `ImageCache` protocol by adding methods for adding, removing and fetching images from a cache given an `NSURLRequest` and additional identifier. 72 | */ 73 | @protocol AFImageRequestCache 74 | 75 | /** 76 | Adds the image to the cache using an identifier created from the request and additional identifier. 77 | 78 | @param image The image to cache. 79 | @param request The unique URL request identifing the image asset. 80 | @param identifier The additional identifier to apply to the URL request to identify the image. 81 | */ 82 | - (void)addImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier; 83 | 84 | /** 85 | Removes the image from the cache using an identifier created from the request and additional identifier. 86 | 87 | @param request The unique URL request identifing the image asset. 88 | @param identifier The additional identifier to apply to the URL request to identify the image. 89 | 90 | @return A BOOL indicating whether or not all images were removed from the cache. 91 | */ 92 | - (BOOL)removeImageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier; 93 | 94 | /** 95 | Returns the image from the cache associated with an identifier created from the request and additional identifier. 96 | 97 | @param request The unique URL request identifing the image asset. 98 | @param identifier The additional identifier to apply to the URL request to identify the image. 99 | 100 | @return An image for the matching request and identifier, or nil. 101 | */ 102 | - (nullable UIImage *)imageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier; 103 | 104 | @end 105 | 106 | /** 107 | The `AutoPurgingImageCache` in an in-memory image cache used to store images up to a given memory capacity. When the memory capacity is reached, the image cache is sorted by last access date, then the oldest image is continuously purged until the preferred memory usage after purge is met. Each time an image is accessed through the cache, the internal access date of the image is updated. 108 | */ 109 | @interface AFAutoPurgingImageCache : NSObject 110 | 111 | /** 112 | The total memory capacity of the cache in bytes. 113 | */ 114 | @property (nonatomic, assign) UInt64 memoryCapacity; 115 | 116 | /** 117 | The preferred memory usage after purge in bytes. During a purge, images will be purged until the memory capacity drops below this limit. 118 | */ 119 | @property (nonatomic, assign) UInt64 preferredMemoryUsageAfterPurge; 120 | 121 | /** 122 | The current total memory usage in bytes of all images stored within the cache. 123 | */ 124 | @property (nonatomic, assign, readonly) UInt64 memoryUsage; 125 | 126 | /** 127 | Initialies the `AutoPurgingImageCache` instance with default values for memory capacity and preferred memory usage after purge limit. `memoryCapcity` defaults to `100 MB`. `preferredMemoryUsageAfterPurge` defaults to `60 MB`. 128 | 129 | @return The new `AutoPurgingImageCache` instance. 130 | */ 131 | - (instancetype)init; 132 | 133 | /** 134 | Initialies the `AutoPurgingImageCache` instance with the given memory capacity and preferred memory usage 135 | after purge limit. 136 | 137 | @param memoryCapacity The total memory capacity of the cache in bytes. 138 | @param preferredMemoryCapacity The preferred memory usage after purge in bytes. 139 | 140 | @return The new `AutoPurgingImageCache` instance. 141 | */ 142 | - (instancetype)initWithMemoryCapacity:(UInt64)memoryCapacity preferredMemoryCapacity:(UInt64)preferredMemoryCapacity; 143 | 144 | @end 145 | 146 | NS_ASSUME_NONNULL_END 147 | 148 | #endif 149 | 150 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.m: -------------------------------------------------------------------------------- 1 | // AFAutoPurgingImageCache.m 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #if TARGET_OS_IOS || TARGET_OS_TV 25 | 26 | #import "AFAutoPurgingImageCache.h" 27 | 28 | @interface AFCachedImage : NSObject 29 | 30 | @property (nonatomic, strong) UIImage *image; 31 | @property (nonatomic, strong) NSString *identifier; 32 | @property (nonatomic, assign) UInt64 totalBytes; 33 | @property (nonatomic, strong) NSDate *lastAccessDate; 34 | @property (nonatomic, assign) UInt64 currentMemoryUsage; 35 | 36 | @end 37 | 38 | @implementation AFCachedImage 39 | 40 | -(instancetype)initWithImage:(UIImage *)image identifier:(NSString *)identifier { 41 | if (self = [self init]) { 42 | self.image = image; 43 | self.identifier = identifier; 44 | 45 | CGSize imageSize = CGSizeMake(image.size.width * image.scale, image.size.height * image.scale); 46 | CGFloat bytesPerPixel = 4.0; 47 | CGFloat bytesPerSize = imageSize.width * imageSize.height; 48 | self.totalBytes = (UInt64)bytesPerPixel * (UInt64)bytesPerSize; 49 | self.lastAccessDate = [NSDate date]; 50 | } 51 | return self; 52 | } 53 | 54 | - (UIImage*)accessImage { 55 | self.lastAccessDate = [NSDate date]; 56 | return self.image; 57 | } 58 | 59 | - (NSString *)description { 60 | NSString *descriptionString = [NSString stringWithFormat:@"Idenfitier: %@ lastAccessDate: %@ ", self.identifier, self.lastAccessDate]; 61 | return descriptionString; 62 | 63 | } 64 | 65 | @end 66 | 67 | @interface AFAutoPurgingImageCache () 68 | @property (nonatomic, strong) NSMutableDictionary *cachedImages; 69 | @property (nonatomic, assign) UInt64 currentMemoryUsage; 70 | @property (nonatomic, strong) dispatch_queue_t synchronizationQueue; 71 | @end 72 | 73 | @implementation AFAutoPurgingImageCache 74 | 75 | - (instancetype)init { 76 | return [self initWithMemoryCapacity:100 * 1024 * 1024 preferredMemoryCapacity:60 * 1024 * 1024]; 77 | } 78 | 79 | - (instancetype)initWithMemoryCapacity:(UInt64)memoryCapacity preferredMemoryCapacity:(UInt64)preferredMemoryCapacity { 80 | if (self = [super init]) { 81 | self.memoryCapacity = memoryCapacity; 82 | self.preferredMemoryUsageAfterPurge = preferredMemoryCapacity; 83 | self.cachedImages = [[NSMutableDictionary alloc] init]; 84 | 85 | NSString *queueName = [NSString stringWithFormat:@"com.alamofire.autopurgingimagecache-%@", [[NSUUID UUID] UUIDString]]; 86 | self.synchronizationQueue = dispatch_queue_create([queueName cStringUsingEncoding:NSASCIIStringEncoding], DISPATCH_QUEUE_CONCURRENT); 87 | 88 | [[NSNotificationCenter defaultCenter] 89 | addObserver:self 90 | selector:@selector(removeAllImages) 91 | name:UIApplicationDidReceiveMemoryWarningNotification 92 | object:nil]; 93 | 94 | } 95 | return self; 96 | } 97 | 98 | - (void)dealloc { 99 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 100 | } 101 | 102 | - (UInt64)memoryUsage { 103 | __block UInt64 result = 0; 104 | dispatch_sync(self.synchronizationQueue, ^{ 105 | result = self.currentMemoryUsage; 106 | }); 107 | return result; 108 | } 109 | 110 | - (void)addImage:(UIImage *)image withIdentifier:(NSString *)identifier { 111 | dispatch_barrier_async(self.synchronizationQueue, ^{ 112 | AFCachedImage *cacheImage = [[AFCachedImage alloc] initWithImage:image identifier:identifier]; 113 | 114 | AFCachedImage *previousCachedImage = self.cachedImages[identifier]; 115 | if (previousCachedImage != nil) { 116 | self.currentMemoryUsage -= previousCachedImage.totalBytes; 117 | } 118 | 119 | self.cachedImages[identifier] = cacheImage; 120 | self.currentMemoryUsage += cacheImage.totalBytes; 121 | }); 122 | 123 | dispatch_barrier_async(self.synchronizationQueue, ^{ 124 | if (self.currentMemoryUsage > self.memoryCapacity) { 125 | UInt64 bytesToPurge = self.currentMemoryUsage - self.preferredMemoryUsageAfterPurge; 126 | NSMutableArray *sortedImages = [NSMutableArray arrayWithArray:self.cachedImages.allValues]; 127 | NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"lastAccessDate" 128 | ascending:YES]; 129 | [sortedImages sortUsingDescriptors:@[sortDescriptor]]; 130 | 131 | UInt64 bytesPurged = 0; 132 | 133 | for (AFCachedImage *cachedImage in sortedImages) { 134 | [self.cachedImages removeObjectForKey:cachedImage.identifier]; 135 | bytesPurged += cachedImage.totalBytes; 136 | if (bytesPurged >= bytesToPurge) { 137 | break ; 138 | } 139 | } 140 | self.currentMemoryUsage -= bytesPurged; 141 | } 142 | }); 143 | } 144 | 145 | - (BOOL)removeImageWithIdentifier:(NSString *)identifier { 146 | __block BOOL removed = NO; 147 | dispatch_barrier_sync(self.synchronizationQueue, ^{ 148 | AFCachedImage *cachedImage = self.cachedImages[identifier]; 149 | if (cachedImage != nil) { 150 | [self.cachedImages removeObjectForKey:identifier]; 151 | self.currentMemoryUsage -= cachedImage.totalBytes; 152 | removed = YES; 153 | } 154 | }); 155 | return removed; 156 | } 157 | 158 | - (BOOL)removeAllImages { 159 | __block BOOL removed = NO; 160 | dispatch_barrier_sync(self.synchronizationQueue, ^{ 161 | if (self.cachedImages.count > 0) { 162 | [self.cachedImages removeAllObjects]; 163 | self.currentMemoryUsage = 0; 164 | removed = YES; 165 | } 166 | }); 167 | return removed; 168 | } 169 | 170 | - (nullable UIImage *)imageWithIdentifier:(NSString *)identifier { 171 | __block UIImage *image = nil; 172 | dispatch_sync(self.synchronizationQueue, ^{ 173 | AFCachedImage *cachedImage = self.cachedImages[identifier]; 174 | image = [cachedImage accessImage]; 175 | }); 176 | return image; 177 | } 178 | 179 | - (void)addImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)identifier { 180 | [self addImage:image withIdentifier:[self imageCacheKeyFromURLRequest:request withAdditionalIdentifier:identifier]]; 181 | } 182 | 183 | - (BOOL)removeImageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)identifier { 184 | return [self removeImageWithIdentifier:[self imageCacheKeyFromURLRequest:request withAdditionalIdentifier:identifier]]; 185 | } 186 | 187 | - (nullable UIImage *)imageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)identifier { 188 | return [self imageWithIdentifier:[self imageCacheKeyFromURLRequest:request withAdditionalIdentifier:identifier]]; 189 | } 190 | 191 | - (NSString *)imageCacheKeyFromURLRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)additionalIdentifier { 192 | NSString *key = request.URL.absoluteString; 193 | if (additionalIdentifier != nil) { 194 | key = [key stringByAppendingString:additionalIdentifier]; 195 | } 196 | return key; 197 | } 198 | 199 | @end 200 | 201 | #endif 202 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/AFNetworking/UIKit+AFNetworking/AFImageDownloader.h: -------------------------------------------------------------------------------- 1 | // AFImageDownloader.h 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #if TARGET_OS_IOS || TARGET_OS_TV 25 | 26 | #import 27 | #import "AFAutoPurgingImageCache.h" 28 | #import "AFHTTPSessionManager.h" 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | typedef NS_ENUM(NSInteger, AFImageDownloadPrioritization) { 33 | AFImageDownloadPrioritizationFIFO, 34 | AFImageDownloadPrioritizationLIFO 35 | }; 36 | 37 | /** 38 | The `AFImageDownloadReceipt` is an object vended by the `AFImageDownloader` when starting a data task. It can be used to cancel active tasks running on the `AFImageDownloader` session. As a general rule, image data tasks should be cancelled using the `AFImageDownloadReceipt` instead of calling `cancel` directly on the `task` itself. The `AFImageDownloader` is optimized to handle duplicate task scenarios as well as pending versus active downloads. 39 | */ 40 | @interface AFImageDownloadReceipt : NSObject 41 | 42 | /** 43 | The data task created by the `AFImageDownloader`. 44 | */ 45 | @property (nonatomic, strong) NSURLSessionDataTask *task; 46 | 47 | /** 48 | The unique identifier for the success and failure blocks when duplicate requests are made. 49 | */ 50 | @property (nonatomic, strong) NSUUID *receiptID; 51 | @end 52 | 53 | /** The `AFImageDownloader` class is responsible for downloading images in parallel on a prioritized queue. Incoming downloads are added to the front or back of the queue depending on the download prioritization. Each downloaded image is cached in the underlying `NSURLCache` as well as the in-memory image cache. By default, any download request with a cached image equivalent in the image cache will automatically be served the cached image representation. 54 | */ 55 | @interface AFImageDownloader : NSObject 56 | 57 | /** 58 | The image cache used to store all downloaded images in. `AFAutoPurgingImageCache` by default. 59 | */ 60 | @property (nonatomic, strong, nullable) id imageCache; 61 | 62 | /** 63 | The `AFHTTPSessionManager` used to download images. By default, this is configured with an `AFImageResponseSerializer`, and a shared `NSURLCache` for all image downloads. 64 | */ 65 | @property (nonatomic, strong) AFHTTPSessionManager *sessionManager; 66 | 67 | /** 68 | Defines the order prioritization of incoming download requests being inserted into the queue. `AFImageDownloadPrioritizationFIFO` by default. 69 | */ 70 | @property (nonatomic, assign) AFImageDownloadPrioritization downloadPrioritizaton; 71 | 72 | /** 73 | The shared default instance of `AFImageDownloader` initialized with default values. 74 | */ 75 | + (instancetype)defaultInstance; 76 | 77 | /** 78 | Creates a default `NSURLCache` with common usage parameter values. 79 | 80 | @returns The default `NSURLCache` instance. 81 | */ 82 | + (NSURLCache *)defaultURLCache; 83 | 84 | /** 85 | Default initializer 86 | 87 | @return An instance of `AFImageDownloader` initialized with default values. 88 | */ 89 | - (instancetype)init; 90 | 91 | /** 92 | Initializes the `AFImageDownloader` instance with the given session manager, download prioritization, maximum active download count and image cache. 93 | 94 | @param sessionManager The session manager to use to download images. 95 | @param downloadPrioritization The download prioritization of the download queue. 96 | @param maximumActiveDownloads The maximum number of active downloads allowed at any given time. Recommend `4`. 97 | @param imageCache The image cache used to store all downloaded images in. 98 | 99 | @return The new `AFImageDownloader` instance. 100 | */ 101 | - (instancetype)initWithSessionManager:(AFHTTPSessionManager *)sessionManager 102 | downloadPrioritization:(AFImageDownloadPrioritization)downloadPrioritization 103 | maximumActiveDownloads:(NSInteger)maximumActiveDownloads 104 | imageCache:(nullable id )imageCache; 105 | 106 | /** 107 | Creates a data task using the `sessionManager` instance for the specified URL request. 108 | 109 | If the same data task is already in the queue or currently being downloaded, the success and failure blocks are 110 | appended to the already existing task. Once the task completes, all success or failure blocks attached to the 111 | task are executed in the order they were added. 112 | 113 | @param request The URL request. 114 | @param success A block to be executed when the image data task 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 image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`. 115 | @param failure A block object to be executed when the image data task finishes unsuccessfully, or that 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 error object describing the network or parsing error that occurred. 116 | 117 | @return The image download receipt for the data task if available. `nil` if the image is stored in the cache. 118 | cache and the URL request cache policy allows the cache to be used. 119 | */ 120 | - (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *)request 121 | success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *responseObject))success 122 | failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure; 123 | 124 | /** 125 | Creates a data task using the `sessionManager` instance for the specified URL request. 126 | 127 | If the same data task is already in the queue or currently being downloaded, the success and failure blocks are 128 | appended to the already existing task. Once the task completes, all success or failure blocks attached to the 129 | task are executed in the order they were added. 130 | 131 | @param request The URL request. 132 | @param receiptID The identifier to use for the download receipt that will be created for this request. This must be a unique identifier that does not represent any other request. 133 | @param success A block to be executed when the image data task 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 image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`. 134 | @param failure A block object to be executed when the image data task finishes unsuccessfully, or that 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 error object describing the network or parsing error that occurred. 135 | 136 | @return The image download receipt for the data task if available. `nil` if the image is stored in the cache. 137 | cache and the URL request cache policy allows the cache to be used. 138 | */ 139 | - (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *)request 140 | withReceiptID:(NSUUID *)receiptID 141 | success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *responseObject))success 142 | failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure; 143 | 144 | /** 145 | Cancels the data task in the receipt by removing the corresponding success and failure blocks and cancelling the data task if necessary. 146 | 147 | If the data task is pending in the queue, it will be cancelled if no other success and failure blocks are registered with the data task. If the data task is currently executing or is already completed, the success and failure blocks are removed and will not be called when the task finishes. 148 | 149 | @param imageDownloadReceipt The image download receipt to cancel. 150 | */ 151 | - (void)cancelTaskForImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt; 152 | 153 | @end 154 | 155 | #endif 156 | 157 | NS_ASSUME_NONNULL_END 158 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h: -------------------------------------------------------------------------------- 1 | // AFNetworkActivityIndicatorManager.h 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #import 25 | 26 | #if TARGET_OS_IOS 27 | 28 | #import 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | /** 33 | `AFNetworkActivityIndicatorManager` manages the state of the network activity indicator in the status bar. When enabled, it will listen for notifications indicating that a session task 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. 34 | 35 | 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: 36 | 37 | [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES]; 38 | 39 | By setting `enabled` 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. 40 | 41 | See the Apple Human Interface Guidelines section about the Network Activity Indicator for more information: 42 | http://developer.apple.com/library/iOS/#documentation/UserExperience/Conceptual/MobileHIG/UIElementGuidelines/UIElementGuidelines.html#//apple_ref/doc/uid/TP40006556-CH13-SW44 43 | */ 44 | NS_EXTENSION_UNAVAILABLE_IOS("Use view controller based solutions where appropriate instead.") 45 | @interface AFNetworkActivityIndicatorManager : NSObject 46 | 47 | /** 48 | A Boolean value indicating whether the manager is enabled. 49 | 50 | If YES, the manager will change status bar network activity indicator according to network operation notifications it receives. The default value is NO. 51 | */ 52 | @property (nonatomic, assign, getter = isEnabled) BOOL enabled; 53 | 54 | /** 55 | A Boolean value indicating whether the network activity indicator manager is currently active. 56 | */ 57 | @property (readonly, nonatomic, assign, getter=isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible; 58 | 59 | /** 60 | A time interval indicating the minimum duration of networking activity that should occur before the activity indicator is displayed. The default value 1 second. If the network activity indicator should be displayed immediately when network activity occurs, this value should be set to 0 seconds. 61 | 62 | Apple's HIG describes the following: 63 | 64 | > Display the network activity indicator to provide feedback when your app accesses the network for more than a couple of seconds. If the operation finishes sooner than that, you don’t have to show the network activity indicator, because the indicator is likely to disappear before users notice its presence. 65 | 66 | */ 67 | @property (nonatomic, assign) NSTimeInterval activationDelay; 68 | 69 | /** 70 | A time interval indicating the duration of time of no networking activity required before the activity indicator is disabled. This allows for continuous display of the network activity indicator across multiple requests. The default value is 0.17 seconds. 71 | */ 72 | 73 | @property (nonatomic, assign) NSTimeInterval completionDelay; 74 | 75 | /** 76 | Returns the shared network activity indicator manager object for the system. 77 | 78 | @return The systemwide network activity indicator manager. 79 | */ 80 | + (instancetype)sharedManager; 81 | 82 | /** 83 | Increments the number of active network requests. If this number was zero before incrementing, this will start animating the status bar network activity indicator. 84 | */ 85 | - (void)incrementActivityCount; 86 | 87 | /** 88 | Decrements the number of active network requests. If this number becomes zero after decrementing, this will stop animating the status bar network activity indicator. 89 | */ 90 | - (void)decrementActivityCount; 91 | 92 | /** 93 | Set the a custom method to be executed when the network activity indicator manager should be hidden/shown. By default, this is null, and the UIApplication Network Activity Indicator will be managed automatically. If this block is set, it is the responsiblity of the caller to manager the network activity indicator going forward. 94 | 95 | @param block A block to be executed when the network activity indicator status changes. 96 | */ 97 | - (void)setNetworkingActivityActionWithBlock:(nullable void (^)(BOOL networkActivityIndicatorVisible))block; 98 | 99 | @end 100 | 101 | NS_ASSUME_NONNULL_END 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m: -------------------------------------------------------------------------------- 1 | // AFNetworkActivityIndicatorManager.m 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import "AFNetworkActivityIndicatorManager.h" 23 | 24 | #if TARGET_OS_IOS 25 | #import "AFURLSessionManager.h" 26 | 27 | typedef NS_ENUM(NSInteger, AFNetworkActivityManagerState) { 28 | AFNetworkActivityManagerStateNotActive, 29 | AFNetworkActivityManagerStateDelayingStart, 30 | AFNetworkActivityManagerStateActive, 31 | AFNetworkActivityManagerStateDelayingEnd 32 | }; 33 | 34 | static NSTimeInterval const kDefaultAFNetworkActivityManagerActivationDelay = 1.0; 35 | static NSTimeInterval const kDefaultAFNetworkActivityManagerCompletionDelay = 0.17; 36 | 37 | static NSURLRequest * AFNetworkRequestFromNotification(NSNotification *notification) { 38 | if ([[notification object] respondsToSelector:@selector(originalRequest)]) { 39 | return [(NSURLSessionTask *)[notification object] originalRequest]; 40 | } else { 41 | return nil; 42 | } 43 | } 44 | 45 | typedef void (^AFNetworkActivityActionBlock)(BOOL networkActivityIndicatorVisible); 46 | 47 | @interface AFNetworkActivityIndicatorManager () 48 | @property (readwrite, nonatomic, assign) NSInteger activityCount; 49 | @property (readwrite, nonatomic, strong) NSTimer *activationDelayTimer; 50 | @property (readwrite, nonatomic, strong) NSTimer *completionDelayTimer; 51 | @property (readonly, nonatomic, getter = isNetworkActivityOccurring) BOOL networkActivityOccurring; 52 | @property (nonatomic, copy) AFNetworkActivityActionBlock networkActivityActionBlock; 53 | @property (nonatomic, assign) AFNetworkActivityManagerState currentState; 54 | @property (nonatomic, assign, getter=isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible; 55 | 56 | - (void)updateCurrentStateForNetworkActivityChange; 57 | @end 58 | 59 | @implementation AFNetworkActivityIndicatorManager 60 | 61 | + (instancetype)sharedManager { 62 | static AFNetworkActivityIndicatorManager *_sharedManager = nil; 63 | static dispatch_once_t oncePredicate; 64 | dispatch_once(&oncePredicate, ^{ 65 | _sharedManager = [[self alloc] init]; 66 | }); 67 | 68 | return _sharedManager; 69 | } 70 | 71 | - (instancetype)init { 72 | self = [super init]; 73 | if (!self) { 74 | return nil; 75 | } 76 | self.currentState = AFNetworkActivityManagerStateNotActive; 77 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidStart:) name:AFNetworkingTaskDidResumeNotification object:nil]; 78 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingTaskDidSuspendNotification object:nil]; 79 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingTaskDidCompleteNotification object:nil]; 80 | self.activationDelay = kDefaultAFNetworkActivityManagerActivationDelay; 81 | self.completionDelay = kDefaultAFNetworkActivityManagerCompletionDelay; 82 | 83 | return self; 84 | } 85 | 86 | - (void)dealloc { 87 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 88 | 89 | [_activationDelayTimer invalidate]; 90 | [_completionDelayTimer invalidate]; 91 | } 92 | 93 | - (void)setEnabled:(BOOL)enabled { 94 | _enabled = enabled; 95 | if (enabled == NO) { 96 | [self setCurrentState:AFNetworkActivityManagerStateNotActive]; 97 | } 98 | } 99 | 100 | - (void)setNetworkingActivityActionWithBlock:(void (^)(BOOL networkActivityIndicatorVisible))block { 101 | self.networkActivityActionBlock = block; 102 | } 103 | 104 | - (BOOL)isNetworkActivityOccurring { 105 | @synchronized(self) { 106 | return self.activityCount > 0; 107 | } 108 | } 109 | 110 | - (void)setNetworkActivityIndicatorVisible:(BOOL)networkActivityIndicatorVisible { 111 | if (_networkActivityIndicatorVisible != networkActivityIndicatorVisible) { 112 | [self willChangeValueForKey:@"networkActivityIndicatorVisible"]; 113 | @synchronized(self) { 114 | _networkActivityIndicatorVisible = networkActivityIndicatorVisible; 115 | } 116 | [self didChangeValueForKey:@"networkActivityIndicatorVisible"]; 117 | if (self.networkActivityActionBlock) { 118 | self.networkActivityActionBlock(networkActivityIndicatorVisible); 119 | } else { 120 | [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:networkActivityIndicatorVisible]; 121 | } 122 | } 123 | } 124 | 125 | - (void)setActivityCount:(NSInteger)activityCount { 126 | @synchronized(self) { 127 | _activityCount = activityCount; 128 | } 129 | 130 | dispatch_async(dispatch_get_main_queue(), ^{ 131 | [self updateCurrentStateForNetworkActivityChange]; 132 | }); 133 | } 134 | 135 | - (void)incrementActivityCount { 136 | [self willChangeValueForKey:@"activityCount"]; 137 | @synchronized(self) { 138 | _activityCount++; 139 | } 140 | [self didChangeValueForKey:@"activityCount"]; 141 | 142 | dispatch_async(dispatch_get_main_queue(), ^{ 143 | [self updateCurrentStateForNetworkActivityChange]; 144 | }); 145 | } 146 | 147 | - (void)decrementActivityCount { 148 | [self willChangeValueForKey:@"activityCount"]; 149 | @synchronized(self) { 150 | #pragma clang diagnostic push 151 | #pragma clang diagnostic ignored "-Wgnu" 152 | _activityCount = MAX(_activityCount - 1, 0); 153 | #pragma clang diagnostic pop 154 | } 155 | [self didChangeValueForKey:@"activityCount"]; 156 | 157 | dispatch_async(dispatch_get_main_queue(), ^{ 158 | [self updateCurrentStateForNetworkActivityChange]; 159 | }); 160 | } 161 | 162 | - (void)networkRequestDidStart:(NSNotification *)notification { 163 | if ([AFNetworkRequestFromNotification(notification) URL]) { 164 | [self incrementActivityCount]; 165 | } 166 | } 167 | 168 | - (void)networkRequestDidFinish:(NSNotification *)notification { 169 | if ([AFNetworkRequestFromNotification(notification) URL]) { 170 | [self decrementActivityCount]; 171 | } 172 | } 173 | 174 | #pragma mark - Internal State Management 175 | - (void)setCurrentState:(AFNetworkActivityManagerState)currentState { 176 | @synchronized(self) { 177 | if (_currentState != currentState) { 178 | [self willChangeValueForKey:@"currentState"]; 179 | _currentState = currentState; 180 | switch (currentState) { 181 | case AFNetworkActivityManagerStateNotActive: 182 | [self cancelActivationDelayTimer]; 183 | [self cancelCompletionDelayTimer]; 184 | [self setNetworkActivityIndicatorVisible:NO]; 185 | break; 186 | case AFNetworkActivityManagerStateDelayingStart: 187 | [self startActivationDelayTimer]; 188 | break; 189 | case AFNetworkActivityManagerStateActive: 190 | [self cancelCompletionDelayTimer]; 191 | [self setNetworkActivityIndicatorVisible:YES]; 192 | break; 193 | case AFNetworkActivityManagerStateDelayingEnd: 194 | [self startCompletionDelayTimer]; 195 | break; 196 | } 197 | } 198 | [self didChangeValueForKey:@"currentState"]; 199 | } 200 | } 201 | 202 | - (void)updateCurrentStateForNetworkActivityChange { 203 | if (self.enabled) { 204 | switch (self.currentState) { 205 | case AFNetworkActivityManagerStateNotActive: 206 | if (self.isNetworkActivityOccurring) { 207 | [self setCurrentState:AFNetworkActivityManagerStateDelayingStart]; 208 | } 209 | break; 210 | case AFNetworkActivityManagerStateDelayingStart: 211 | //No op. Let the delay timer finish out. 212 | break; 213 | case AFNetworkActivityManagerStateActive: 214 | if (!self.isNetworkActivityOccurring) { 215 | [self setCurrentState:AFNetworkActivityManagerStateDelayingEnd]; 216 | } 217 | break; 218 | case AFNetworkActivityManagerStateDelayingEnd: 219 | if (self.isNetworkActivityOccurring) { 220 | [self setCurrentState:AFNetworkActivityManagerStateActive]; 221 | } 222 | break; 223 | } 224 | } 225 | } 226 | 227 | - (void)startActivationDelayTimer { 228 | self.activationDelayTimer = [NSTimer 229 | timerWithTimeInterval:self.activationDelay target:self selector:@selector(activationDelayTimerFired) userInfo:nil repeats:NO]; 230 | [[NSRunLoop mainRunLoop] addTimer:self.activationDelayTimer forMode:NSRunLoopCommonModes]; 231 | } 232 | 233 | - (void)activationDelayTimerFired { 234 | if (self.networkActivityOccurring) { 235 | [self setCurrentState:AFNetworkActivityManagerStateActive]; 236 | } else { 237 | [self setCurrentState:AFNetworkActivityManagerStateNotActive]; 238 | } 239 | } 240 | 241 | - (void)startCompletionDelayTimer { 242 | [self.completionDelayTimer invalidate]; 243 | self.completionDelayTimer = [NSTimer timerWithTimeInterval:self.completionDelay target:self selector:@selector(completionDelayTimerFired) userInfo:nil repeats:NO]; 244 | [[NSRunLoop mainRunLoop] addTimer:self.completionDelayTimer forMode:NSRunLoopCommonModes]; 245 | } 246 | 247 | - (void)completionDelayTimerFired { 248 | [self setCurrentState:AFNetworkActivityManagerStateNotActive]; 249 | } 250 | 251 | - (void)cancelActivationDelayTimer { 252 | [self.activationDelayTimer invalidate]; 253 | } 254 | 255 | - (void)cancelCompletionDelayTimer { 256 | [self.completionDelayTimer invalidate]; 257 | } 258 | 259 | @end 260 | 261 | #endif 262 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIActivityIndicatorView+AFNetworking.h 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #import 25 | 26 | #if TARGET_OS_IOS || TARGET_OS_TV 27 | 28 | #import 29 | 30 | /** 31 | This category adds methods to the UIKit framework's `UIActivityIndicatorView` class. The methods in this category provide support for automatically starting and stopping animation depending on the loading state of a session task. 32 | */ 33 | @interface UIActivityIndicatorView (AFNetworking) 34 | 35 | ///---------------------------------- 36 | /// @name Animating for Session Tasks 37 | ///---------------------------------- 38 | 39 | /** 40 | Binds the animating state to the state of the specified task. 41 | 42 | @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled. 43 | */ 44 | - (void)setAnimatingWithStateOfTask:(nullable NSURLSessionTask *)task; 45 | 46 | @end 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIActivityIndicatorView+AFNetworking.m 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import "UIActivityIndicatorView+AFNetworking.h" 23 | #import 24 | 25 | #if TARGET_OS_IOS || TARGET_OS_TV 26 | 27 | #import "AFURLSessionManager.h" 28 | 29 | @interface AFActivityIndicatorViewNotificationObserver : NSObject 30 | @property (readonly, nonatomic, weak) UIActivityIndicatorView *activityIndicatorView; 31 | - (instancetype)initWithActivityIndicatorView:(UIActivityIndicatorView *)activityIndicatorView; 32 | 33 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task; 34 | 35 | @end 36 | 37 | @implementation UIActivityIndicatorView (AFNetworking) 38 | 39 | - (AFActivityIndicatorViewNotificationObserver *)af_notificationObserver { 40 | AFActivityIndicatorViewNotificationObserver *notificationObserver = objc_getAssociatedObject(self, @selector(af_notificationObserver)); 41 | if (notificationObserver == nil) { 42 | notificationObserver = [[AFActivityIndicatorViewNotificationObserver alloc] initWithActivityIndicatorView:self]; 43 | objc_setAssociatedObject(self, @selector(af_notificationObserver), notificationObserver, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 44 | } 45 | return notificationObserver; 46 | } 47 | 48 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task { 49 | [[self af_notificationObserver] setAnimatingWithStateOfTask:task]; 50 | } 51 | 52 | @end 53 | 54 | @implementation AFActivityIndicatorViewNotificationObserver 55 | 56 | - (instancetype)initWithActivityIndicatorView:(UIActivityIndicatorView *)activityIndicatorView 57 | { 58 | self = [super init]; 59 | if (self) { 60 | _activityIndicatorView = activityIndicatorView; 61 | } 62 | return self; 63 | } 64 | 65 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task { 66 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 67 | 68 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; 69 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; 70 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; 71 | 72 | if (task) { 73 | if (task.state != NSURLSessionTaskStateCompleted) { 74 | 75 | #pragma clang diagnostic push 76 | #pragma clang diagnostic ignored "-Wreceiver-is-weak" 77 | #pragma clang diagnostic ignored "-Warc-repeated-use-of-weak" 78 | if (task.state == NSURLSessionTaskStateRunning) { 79 | [self.activityIndicatorView startAnimating]; 80 | } else { 81 | [self.activityIndicatorView stopAnimating]; 82 | } 83 | #pragma clang diagnostic pop 84 | 85 | [notificationCenter addObserver:self selector:@selector(af_startAnimating) name:AFNetworkingTaskDidResumeNotification object:task]; 86 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidCompleteNotification object:task]; 87 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidSuspendNotification object:task]; 88 | } 89 | } 90 | } 91 | 92 | #pragma mark - 93 | 94 | - (void)af_startAnimating { 95 | dispatch_async(dispatch_get_main_queue(), ^{ 96 | #pragma clang diagnostic push 97 | #pragma clang diagnostic ignored "-Wreceiver-is-weak" 98 | [self.activityIndicatorView startAnimating]; 99 | #pragma clang diagnostic pop 100 | }); 101 | } 102 | 103 | - (void)af_stopAnimating { 104 | dispatch_async(dispatch_get_main_queue(), ^{ 105 | #pragma clang diagnostic push 106 | #pragma clang diagnostic ignored "-Wreceiver-is-weak" 107 | [self.activityIndicatorView stopAnimating]; 108 | #pragma clang diagnostic pop 109 | }); 110 | } 111 | 112 | #pragma mark - 113 | 114 | - (void)dealloc { 115 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 116 | 117 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; 118 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; 119 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; 120 | } 121 | 122 | @end 123 | 124 | #endif 125 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIButton+AFNetworking.h 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #import 25 | 26 | #if TARGET_OS_IOS || TARGET_OS_TV 27 | 28 | #import 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | @class AFImageDownloader; 33 | 34 | /** 35 | This category adds methods to the UIKit framework's `UIButton` class. The methods in this category provide support for loading remote images and background images asynchronously from a URL. 36 | 37 | @warning Compound values for control `state` (such as `UIControlStateHighlighted | UIControlStateDisabled`) are unsupported. 38 | */ 39 | @interface UIButton (AFNetworking) 40 | 41 | ///------------------------------------ 42 | /// @name Accessing the Image Downloader 43 | ///------------------------------------ 44 | 45 | /** 46 | Set the shared image downloader used to download images. 47 | 48 | @param imageDownloader The shared image downloader used to download images. 49 | */ 50 | + (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader; 51 | 52 | /** 53 | The shared image downloader used to download images. 54 | */ 55 | + (AFImageDownloader *)sharedImageDownloader; 56 | 57 | ///-------------------- 58 | /// @name Setting Image 59 | ///-------------------- 60 | 61 | /** 62 | Asynchronously downloads an image from the specified URL, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. 63 | 64 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. 65 | 66 | @param state The control state. 67 | @param url The URL used for the image request. 68 | */ 69 | - (void)setImageForState:(UIControlState)state 70 | withURL:(NSURL *)url; 71 | 72 | /** 73 | Asynchronously downloads an image from the specified URL, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. 74 | 75 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. 76 | 77 | @param state The control state. 78 | @param url The URL used for the image request. 79 | @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the button will not change its image until the image request finishes. 80 | */ 81 | - (void)setImageForState:(UIControlState)state 82 | withURL:(NSURL *)url 83 | placeholderImage:(nullable UIImage *)placeholderImage; 84 | 85 | /** 86 | Asynchronously downloads an image from the specified URL request, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. 87 | 88 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. 89 | 90 | If a success block is specified, it is the responsibility of the block to set the image of the button before returning. If no success block is specified, the default behavior of setting the image with `setImage:forState:` is applied. 91 | 92 | @param state The control state. 93 | @param urlRequest The URL request used for the image request. 94 | @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the button will not change its image until the image request finishes. 95 | @param success A block to be executed when the image data task 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 image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`. 96 | @param failure A block object to be executed when the image data task finishes unsuccessfully, or that 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 error object describing the network or parsing error that occurred. 97 | */ 98 | - (void)setImageForState:(UIControlState)state 99 | withURLRequest:(NSURLRequest *)urlRequest 100 | placeholderImage:(nullable UIImage *)placeholderImage 101 | success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success 102 | failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure; 103 | 104 | 105 | ///------------------------------- 106 | /// @name Setting Background Image 107 | ///------------------------------- 108 | 109 | /** 110 | Asynchronously downloads an image from the specified URL, and sets it as the background image for the specified state once the request is finished. Any previous background image request for the receiver will be cancelled. 111 | 112 | If the background image is cached locally, the background image is set immediately, otherwise the specified placeholder background image will be set immediately, and then the remote background image will be set once the request is finished. 113 | 114 | @param state The control state. 115 | @param url The URL used for the background image request. 116 | */ 117 | - (void)setBackgroundImageForState:(UIControlState)state 118 | withURL:(NSURL *)url; 119 | 120 | /** 121 | Asynchronously downloads an image from the specified URL, and sets it as the background image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. 122 | 123 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. 124 | 125 | @param state The control state. 126 | @param url The URL used for the background image request. 127 | @param placeholderImage The background image to be set initially, until the background image request finishes. If `nil`, the button will not change its background image until the background image request finishes. 128 | */ 129 | - (void)setBackgroundImageForState:(UIControlState)state 130 | withURL:(NSURL *)url 131 | placeholderImage:(nullable UIImage *)placeholderImage; 132 | 133 | /** 134 | Asynchronously downloads an image from the specified URL request, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. 135 | 136 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. 137 | 138 | If a success block is specified, it is the responsibility of the block to set the image of the button before returning. If no success block is specified, the default behavior of setting the image with `setBackgroundImage:forState:` is applied. 139 | 140 | @param state The control state. 141 | @param urlRequest The URL request used for the image request. 142 | @param placeholderImage The background image to be set initially, until the background image request finishes. If `nil`, the button will not change its background image until the background image request finishes. 143 | @param success A block to be executed when the image data task 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 image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`. 144 | @param failure A block object to be executed when the image data task finishes unsuccessfully, or that 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 error object describing the network or parsing error that occurred. 145 | */ 146 | - (void)setBackgroundImageForState:(UIControlState)state 147 | withURLRequest:(NSURLRequest *)urlRequest 148 | placeholderImage:(nullable UIImage *)placeholderImage 149 | success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success 150 | failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure; 151 | 152 | 153 | ///------------------------------ 154 | /// @name Canceling Image Loading 155 | ///------------------------------ 156 | 157 | /** 158 | Cancels any executing image task for the specified control state of the receiver, if one exists. 159 | 160 | @param state The control state. 161 | */ 162 | - (void)cancelImageDownloadTaskForState:(UIControlState)state; 163 | 164 | /** 165 | Cancels any executing background image task for the specified control state of the receiver, if one exists. 166 | 167 | @param state The control state. 168 | */ 169 | - (void)cancelBackgroundImageDownloadTaskForState:(UIControlState)state; 170 | 171 | @end 172 | 173 | NS_ASSUME_NONNULL_END 174 | 175 | #endif 176 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+AFNetworking.h 3 | // 4 | // 5 | // Created by Paulo Ferreira on 08/07/15. 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | #if TARGET_OS_IOS || TARGET_OS_TV 26 | 27 | #import 28 | 29 | @interface UIImage (AFNetworking) 30 | 31 | + (UIImage*) safeImageWithData:(NSData*)data; 32 | 33 | @end 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIImageView+AFNetworking.h 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #import 25 | 26 | #if TARGET_OS_IOS || TARGET_OS_TV 27 | 28 | #import 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | @class AFImageDownloader; 33 | 34 | /** 35 | This category adds methods to the UIKit framework's `UIImageView` class. The methods in this category provide support for loading remote images asynchronously from a URL. 36 | */ 37 | @interface UIImageView (AFNetworking) 38 | 39 | ///------------------------------------ 40 | /// @name Accessing the Image Downloader 41 | ///------------------------------------ 42 | 43 | /** 44 | Set the shared image downloader used to download images. 45 | 46 | @param imageDownloader The shared image downloader used to download images. 47 | */ 48 | + (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader; 49 | 50 | /** 51 | The shared image downloader used to download images. 52 | */ 53 | + (AFImageDownloader *)sharedImageDownloader; 54 | 55 | ///-------------------- 56 | /// @name Setting Image 57 | ///-------------------- 58 | 59 | /** 60 | Asynchronously downloads an image from the specified URL, and sets it once the request is finished. Any previous image request for the receiver will be cancelled. 61 | 62 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. 63 | 64 | By default, URL requests have a `Accept` header field value of "image / *", a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:` 65 | 66 | @param url The URL used for the image request. 67 | */ 68 | - (void)setImageWithURL:(NSURL *)url; 69 | 70 | /** 71 | Asynchronously downloads an image from the specified URL, and sets it once the request is finished. Any previous image request for the receiver will be cancelled. 72 | 73 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. 74 | 75 | By default, URL requests have a `Accept` header field value of "image / *", a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:` 76 | 77 | @param url The URL used for the image request. 78 | @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes. 79 | */ 80 | - (void)setImageWithURL:(NSURL *)url 81 | placeholderImage:(nullable UIImage *)placeholderImage; 82 | 83 | /** 84 | Asynchronously downloads an image from the specified URL request, and sets it once the request is finished. Any previous image request for the receiver will be cancelled. 85 | 86 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. 87 | 88 | If a success block is specified, it is the responsibility of the block to set the image of the image view before returning. If no success block is specified, the default behavior of setting the image with `self.image = image` is applied. 89 | 90 | @param urlRequest The URL request used for the image request. 91 | @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes. 92 | @param success A block to be executed when the image data task 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 image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`. 93 | @param failure A block object to be executed when the image data task finishes unsuccessfully, or that 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 error object describing the network or parsing error that occurred. 94 | */ 95 | - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest 96 | placeholderImage:(nullable UIImage *)placeholderImage 97 | success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success 98 | failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure; 99 | 100 | /** 101 | Cancels any executing image operation for the receiver, if one exists. 102 | */ 103 | - (void)cancelImageDownloadTask; 104 | 105 | @end 106 | 107 | NS_ASSUME_NONNULL_END 108 | 109 | #endif 110 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIImageView+AFNetworking.m 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import "UIImageView+AFNetworking.h" 23 | 24 | #import 25 | 26 | #if TARGET_OS_IOS || TARGET_OS_TV 27 | 28 | #import "AFImageDownloader.h" 29 | 30 | @interface UIImageView (_AFNetworking) 31 | @property (readwrite, nonatomic, strong, setter = af_setActiveImageDownloadReceipt:) AFImageDownloadReceipt *af_activeImageDownloadReceipt; 32 | @end 33 | 34 | @implementation UIImageView (_AFNetworking) 35 | 36 | - (AFImageDownloadReceipt *)af_activeImageDownloadReceipt { 37 | return (AFImageDownloadReceipt *)objc_getAssociatedObject(self, @selector(af_activeImageDownloadReceipt)); 38 | } 39 | 40 | - (void)af_setActiveImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt { 41 | objc_setAssociatedObject(self, @selector(af_activeImageDownloadReceipt), imageDownloadReceipt, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 42 | } 43 | 44 | @end 45 | 46 | #pragma mark - 47 | 48 | @implementation UIImageView (AFNetworking) 49 | 50 | + (AFImageDownloader *)sharedImageDownloader { 51 | 52 | #pragma clang diagnostic push 53 | #pragma clang diagnostic ignored "-Wgnu" 54 | return objc_getAssociatedObject(self, @selector(sharedImageDownloader)) ?: [AFImageDownloader defaultInstance]; 55 | #pragma clang diagnostic pop 56 | } 57 | 58 | + (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader { 59 | objc_setAssociatedObject(self, @selector(sharedImageDownloader), imageDownloader, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 60 | } 61 | 62 | #pragma mark - 63 | 64 | - (void)setImageWithURL:(NSURL *)url { 65 | [self setImageWithURL:url placeholderImage:nil]; 66 | } 67 | 68 | - (void)setImageWithURL:(NSURL *)url 69 | placeholderImage:(UIImage *)placeholderImage 70 | { 71 | NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; 72 | [request addValue:@"image/*" forHTTPHeaderField:@"Accept"]; 73 | 74 | [self setImageWithURLRequest:request placeholderImage:placeholderImage success:nil failure:nil]; 75 | } 76 | 77 | - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest 78 | placeholderImage:(UIImage *)placeholderImage 79 | success:(void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success 80 | failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure 81 | { 82 | 83 | if ([urlRequest URL] == nil) { 84 | [self cancelImageDownloadTask]; 85 | self.image = placeholderImage; 86 | return; 87 | } 88 | 89 | if ([self isActiveTaskURLEqualToURLRequest:urlRequest]){ 90 | return; 91 | } 92 | 93 | [self cancelImageDownloadTask]; 94 | 95 | AFImageDownloader *downloader = [[self class] sharedImageDownloader]; 96 | id imageCache = downloader.imageCache; 97 | 98 | //Use the image from the image cache if it exists 99 | UIImage *cachedImage = [imageCache imageforRequest:urlRequest withAdditionalIdentifier:nil]; 100 | if (cachedImage) { 101 | if (success) { 102 | success(urlRequest, nil, cachedImage); 103 | } else { 104 | self.image = cachedImage; 105 | } 106 | [self clearActiveDownloadInformation]; 107 | } else { 108 | if (placeholderImage) { 109 | self.image = placeholderImage; 110 | } 111 | 112 | __weak __typeof(self)weakSelf = self; 113 | NSUUID *downloadID = [NSUUID UUID]; 114 | AFImageDownloadReceipt *receipt; 115 | receipt = [downloader 116 | downloadImageForURLRequest:urlRequest 117 | withReceiptID:downloadID 118 | success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull responseObject) { 119 | __strong __typeof(weakSelf)strongSelf = weakSelf; 120 | if ([strongSelf.af_activeImageDownloadReceipt.receiptID isEqual:downloadID]) { 121 | if (success) { 122 | success(request, response, responseObject); 123 | } else if(responseObject) { 124 | strongSelf.image = responseObject; 125 | } 126 | [strongSelf clearActiveDownloadInformation]; 127 | } 128 | 129 | } 130 | failure:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, NSError * _Nonnull error) { 131 | __strong __typeof(weakSelf)strongSelf = weakSelf; 132 | if ([strongSelf.af_activeImageDownloadReceipt.receiptID isEqual:downloadID]) { 133 | if (failure) { 134 | failure(request, response, error); 135 | } 136 | [strongSelf clearActiveDownloadInformation]; 137 | } 138 | }]; 139 | 140 | self.af_activeImageDownloadReceipt = receipt; 141 | } 142 | } 143 | 144 | - (void)cancelImageDownloadTask { 145 | if (self.af_activeImageDownloadReceipt != nil) { 146 | [[self.class sharedImageDownloader] cancelTaskForImageDownloadReceipt:self.af_activeImageDownloadReceipt]; 147 | [self clearActiveDownloadInformation]; 148 | } 149 | } 150 | 151 | - (void)clearActiveDownloadInformation { 152 | self.af_activeImageDownloadReceipt = nil; 153 | } 154 | 155 | - (BOOL)isActiveTaskURLEqualToURLRequest:(NSURLRequest *)urlRequest { 156 | return [self.af_activeImageDownloadReceipt.task.originalRequest.URL.absoluteString isEqualToString:urlRequest.URL.absoluteString]; 157 | } 158 | 159 | @end 160 | 161 | #endif 162 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIKit+AFNetworking.h 2 | // 3 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 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 | #if TARGET_OS_IOS || TARGET_OS_TV 24 | #import 25 | 26 | #ifndef _UIKIT_AFNETWORKING_ 27 | #define _UIKIT_AFNETWORKING_ 28 | 29 | #if TARGET_OS_IOS 30 | #import "AFAutoPurgingImageCache.h" 31 | #import "AFImageDownloader.h" 32 | #import "AFNetworkActivityIndicatorManager.h" 33 | #import "UIRefreshControl+AFNetworking.h" 34 | #import "UIWebView+AFNetworking.h" 35 | #endif 36 | 37 | #import "UIActivityIndicatorView+AFNetworking.h" 38 | #import "UIButton+AFNetworking.h" 39 | #import "UIImageView+AFNetworking.h" 40 | #import "UIProgressView+AFNetworking.h" 41 | #endif /* _UIKIT_AFNETWORKING_ */ 42 | #endif 43 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIProgressView+AFNetworking.h 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #import 25 | 26 | #if TARGET_OS_IOS || TARGET_OS_TV 27 | 28 | #import 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | 33 | /** 34 | This category adds methods to the UIKit framework's `UIProgressView` class. The methods in this category provide support for binding the progress to the upload and download progress of a session task. 35 | */ 36 | @interface UIProgressView (AFNetworking) 37 | 38 | ///------------------------------------ 39 | /// @name Setting Session Task Progress 40 | ///------------------------------------ 41 | 42 | /** 43 | Binds the progress to the upload progress of the specified session task. 44 | 45 | @param task The session task. 46 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. 47 | */ 48 | - (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task 49 | animated:(BOOL)animated; 50 | 51 | /** 52 | Binds the progress to the download progress of the specified session task. 53 | 54 | @param task The session task. 55 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. 56 | */ 57 | - (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task 58 | animated:(BOOL)animated; 59 | 60 | @end 61 | 62 | NS_ASSUME_NONNULL_END 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIProgressView+AFNetworking.m 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import "UIProgressView+AFNetworking.h" 23 | 24 | #import 25 | 26 | #if TARGET_OS_IOS || TARGET_OS_TV 27 | 28 | #import "AFURLSessionManager.h" 29 | 30 | static void * AFTaskCountOfBytesSentContext = &AFTaskCountOfBytesSentContext; 31 | static void * AFTaskCountOfBytesReceivedContext = &AFTaskCountOfBytesReceivedContext; 32 | 33 | #pragma mark - 34 | 35 | @implementation UIProgressView (AFNetworking) 36 | 37 | - (BOOL)af_uploadProgressAnimated { 38 | return [(NSNumber *)objc_getAssociatedObject(self, @selector(af_uploadProgressAnimated)) boolValue]; 39 | } 40 | 41 | - (void)af_setUploadProgressAnimated:(BOOL)animated { 42 | objc_setAssociatedObject(self, @selector(af_uploadProgressAnimated), @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 43 | } 44 | 45 | - (BOOL)af_downloadProgressAnimated { 46 | return [(NSNumber *)objc_getAssociatedObject(self, @selector(af_downloadProgressAnimated)) boolValue]; 47 | } 48 | 49 | - (void)af_setDownloadProgressAnimated:(BOOL)animated { 50 | objc_setAssociatedObject(self, @selector(af_downloadProgressAnimated), @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 51 | } 52 | 53 | #pragma mark - 54 | 55 | - (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task 56 | animated:(BOOL)animated 57 | { 58 | [task addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesSentContext]; 59 | [task addObserver:self forKeyPath:@"countOfBytesSent" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesSentContext]; 60 | 61 | [self af_setUploadProgressAnimated:animated]; 62 | } 63 | 64 | - (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task 65 | animated:(BOOL)animated 66 | { 67 | [task addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesReceivedContext]; 68 | [task addObserver:self forKeyPath:@"countOfBytesReceived" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesReceivedContext]; 69 | 70 | [self af_setDownloadProgressAnimated:animated]; 71 | } 72 | 73 | #pragma mark - NSKeyValueObserving 74 | 75 | - (void)observeValueForKeyPath:(NSString *)keyPath 76 | ofObject:(id)object 77 | change:(__unused NSDictionary *)change 78 | context:(void *)context 79 | { 80 | if (context == AFTaskCountOfBytesSentContext || context == AFTaskCountOfBytesReceivedContext) { 81 | if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesSent))]) { 82 | if ([object countOfBytesExpectedToSend] > 0) { 83 | dispatch_async(dispatch_get_main_queue(), ^{ 84 | [self setProgress:[object countOfBytesSent] / ([object countOfBytesExpectedToSend] * 1.0f) animated:self.af_uploadProgressAnimated]; 85 | }); 86 | } 87 | } 88 | 89 | if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesReceived))]) { 90 | if ([object countOfBytesExpectedToReceive] > 0) { 91 | dispatch_async(dispatch_get_main_queue(), ^{ 92 | [self setProgress:[object countOfBytesReceived] / ([object countOfBytesExpectedToReceive] * 1.0f) animated:self.af_downloadProgressAnimated]; 93 | }); 94 | } 95 | } 96 | 97 | if ([keyPath isEqualToString:NSStringFromSelector(@selector(state))]) { 98 | if ([(NSURLSessionTask *)object state] == NSURLSessionTaskStateCompleted) { 99 | @try { 100 | [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(state))]; 101 | 102 | if (context == AFTaskCountOfBytesSentContext) { 103 | [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesSent))]; 104 | } 105 | 106 | if (context == AFTaskCountOfBytesReceivedContext) { 107 | [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesReceived))]; 108 | } 109 | } 110 | @catch (NSException * __unused exception) {} 111 | } 112 | } 113 | } 114 | } 115 | 116 | @end 117 | 118 | #endif 119 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIRefreshControl+AFNetworking.m 2 | // 3 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 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 24 | 25 | #import 26 | 27 | #if TARGET_OS_IOS 28 | 29 | #import 30 | 31 | NS_ASSUME_NONNULL_BEGIN 32 | 33 | /** 34 | This category adds methods to the UIKit framework's `UIRefreshControl` class. The methods in this category provide support for automatically beginning and ending refreshing depending on the loading state of a session task. 35 | */ 36 | @interface UIRefreshControl (AFNetworking) 37 | 38 | ///----------------------------------- 39 | /// @name Refreshing for Session Tasks 40 | ///----------------------------------- 41 | 42 | /** 43 | Binds the refreshing state to the state of the specified task. 44 | 45 | @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled. 46 | */ 47 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task; 48 | 49 | @end 50 | 51 | NS_ASSUME_NONNULL_END 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIRefreshControl+AFNetworking.m 2 | // 3 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 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 "UIRefreshControl+AFNetworking.h" 24 | #import 25 | 26 | #if TARGET_OS_IOS 27 | 28 | #import "AFURLSessionManager.h" 29 | 30 | @interface AFRefreshControlNotificationObserver : NSObject 31 | @property (readonly, nonatomic, weak) UIRefreshControl *refreshControl; 32 | - (instancetype)initWithActivityRefreshControl:(UIRefreshControl *)refreshControl; 33 | 34 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task; 35 | 36 | @end 37 | 38 | @implementation UIRefreshControl (AFNetworking) 39 | 40 | - (AFRefreshControlNotificationObserver *)af_notificationObserver { 41 | AFRefreshControlNotificationObserver *notificationObserver = objc_getAssociatedObject(self, @selector(af_notificationObserver)); 42 | if (notificationObserver == nil) { 43 | notificationObserver = [[AFRefreshControlNotificationObserver alloc] initWithActivityRefreshControl:self]; 44 | objc_setAssociatedObject(self, @selector(af_notificationObserver), notificationObserver, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 45 | } 46 | return notificationObserver; 47 | } 48 | 49 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task { 50 | [[self af_notificationObserver] setRefreshingWithStateOfTask:task]; 51 | } 52 | 53 | @end 54 | 55 | @implementation AFRefreshControlNotificationObserver 56 | 57 | - (instancetype)initWithActivityRefreshControl:(UIRefreshControl *)refreshControl 58 | { 59 | self = [super init]; 60 | if (self) { 61 | _refreshControl = refreshControl; 62 | } 63 | return self; 64 | } 65 | 66 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task { 67 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 68 | 69 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; 70 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; 71 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; 72 | 73 | if (task) { 74 | #pragma clang diagnostic push 75 | #pragma clang diagnostic ignored "-Wreceiver-is-weak" 76 | #pragma clang diagnostic ignored "-Warc-repeated-use-of-weak" 77 | if (task.state == NSURLSessionTaskStateRunning) { 78 | [self.refreshControl beginRefreshing]; 79 | 80 | [notificationCenter addObserver:self selector:@selector(af_beginRefreshing) name:AFNetworkingTaskDidResumeNotification object:task]; 81 | [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidCompleteNotification object:task]; 82 | [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidSuspendNotification object:task]; 83 | } else { 84 | [self.refreshControl endRefreshing]; 85 | } 86 | #pragma clang diagnostic pop 87 | } 88 | } 89 | 90 | #pragma mark - 91 | 92 | - (void)af_beginRefreshing { 93 | dispatch_async(dispatch_get_main_queue(), ^{ 94 | #pragma clang diagnostic push 95 | #pragma clang diagnostic ignored "-Wreceiver-is-weak" 96 | [self.refreshControl beginRefreshing]; 97 | #pragma clang diagnostic pop 98 | }); 99 | } 100 | 101 | - (void)af_endRefreshing { 102 | dispatch_async(dispatch_get_main_queue(), ^{ 103 | #pragma clang diagnostic push 104 | #pragma clang diagnostic ignored "-Wreceiver-is-weak" 105 | [self.refreshControl endRefreshing]; 106 | #pragma clang diagnostic pop 107 | }); 108 | } 109 | 110 | #pragma mark - 111 | 112 | - (void)dealloc { 113 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 114 | 115 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; 116 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; 117 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; 118 | } 119 | 120 | @end 121 | 122 | #endif 123 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIWebView+AFNetworking.h 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #import 25 | 26 | #if TARGET_OS_IOS 27 | 28 | #import 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | @class AFHTTPSessionManager; 33 | 34 | /** 35 | This category adds methods to the UIKit framework's `UIWebView` class. The methods in this category provide increased control over the request cycle, including progress monitoring and success / failure handling. 36 | 37 | @discussion When using these category methods, make sure to assign `delegate` for the web view, which implements `–webView:shouldStartLoadWithRequest:navigationType:` appropriately. This allows for tapped links to be loaded through AFNetworking, and can ensure that `canGoBack` & `canGoForward` update their values correctly. 38 | */ 39 | @interface UIWebView (AFNetworking) 40 | 41 | /** 42 | The session manager used to download all requests. 43 | */ 44 | @property (nonatomic, strong) AFHTTPSessionManager *sessionManager; 45 | 46 | /** 47 | Asynchronously loads the specified request. 48 | 49 | @param request A URL request identifying the location of the content to load. This must not be `nil`. 50 | @param progress A progress object monitoring the current download progress. 51 | @param success A block object to be executed when the request finishes loading successfully. This block returns the HTML string to be loaded by the web view, and takes two arguments: the response, and the response string. 52 | @param failure A block object to be executed when the data task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred. 53 | */ 54 | - (void)loadRequest:(NSURLRequest *)request 55 | progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress 56 | success:(nullable NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success 57 | failure:(nullable void (^)(NSError *error))failure; 58 | 59 | /** 60 | Asynchronously loads the data associated with a particular request with a specified MIME type and text encoding. 61 | 62 | @param request A URL request identifying the location of the content to load. This must not be `nil`. 63 | @param MIMEType The MIME type of the content. Defaults to the content type of the response if not specified. 64 | @param textEncodingName The IANA encoding name, as in `utf-8` or `utf-16`. Defaults to the response text encoding if not specified. 65 | @param progress A progress object monitoring the current download progress. 66 | @param success A block object to be executed when the request finishes loading successfully. This block returns the data to be loaded by the web view and takes two arguments: the response, and the downloaded data. 67 | @param failure A block object to be executed when the data task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred. 68 | */ 69 | - (void)loadRequest:(NSURLRequest *)request 70 | MIMEType:(nullable NSString *)MIMEType 71 | textEncodingName:(nullable NSString *)textEncodingName 72 | progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress 73 | success:(nullable NSData * (^)(NSHTTPURLResponse *response, NSData *data))success 74 | failure:(nullable void (^)(NSError *error))failure; 75 | 76 | @end 77 | 78 | NS_ASSUME_NONNULL_END 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIWebView+AFNetworking.m 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import "UIWebView+AFNetworking.h" 23 | 24 | #import 25 | 26 | #if TARGET_OS_IOS 27 | 28 | #import "AFHTTPSessionManager.h" 29 | #import "AFURLResponseSerialization.h" 30 | #import "AFURLRequestSerialization.h" 31 | 32 | @interface UIWebView (_AFNetworking) 33 | @property (readwrite, nonatomic, strong, setter = af_setURLSessionTask:) NSURLSessionDataTask *af_URLSessionTask; 34 | @end 35 | 36 | @implementation UIWebView (_AFNetworking) 37 | 38 | - (NSURLSessionDataTask *)af_URLSessionTask { 39 | return (NSURLSessionDataTask *)objc_getAssociatedObject(self, @selector(af_URLSessionTask)); 40 | } 41 | 42 | - (void)af_setURLSessionTask:(NSURLSessionDataTask *)af_URLSessionTask { 43 | objc_setAssociatedObject(self, @selector(af_URLSessionTask), af_URLSessionTask, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 44 | } 45 | 46 | @end 47 | 48 | #pragma mark - 49 | 50 | @implementation UIWebView (AFNetworking) 51 | 52 | - (AFHTTPSessionManager *)sessionManager { 53 | static AFHTTPSessionManager *_af_defaultHTTPSessionManager = nil; 54 | static dispatch_once_t onceToken; 55 | dispatch_once(&onceToken, ^{ 56 | _af_defaultHTTPSessionManager = [[AFHTTPSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]]; 57 | _af_defaultHTTPSessionManager.requestSerializer = [AFHTTPRequestSerializer serializer]; 58 | _af_defaultHTTPSessionManager.responseSerializer = [AFHTTPResponseSerializer serializer]; 59 | }); 60 | 61 | #pragma clang diagnostic push 62 | #pragma clang diagnostic ignored "-Wgnu" 63 | return objc_getAssociatedObject(self, @selector(sessionManager)) ?: _af_defaultHTTPSessionManager; 64 | #pragma clang diagnostic pop 65 | } 66 | 67 | - (void)setSessionManager:(AFHTTPSessionManager *)sessionManager { 68 | objc_setAssociatedObject(self, @selector(sessionManager), sessionManager, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 69 | } 70 | 71 | - (AFHTTPResponseSerializer *)responseSerializer { 72 | static AFHTTPResponseSerializer *_af_defaultResponseSerializer = nil; 73 | static dispatch_once_t onceToken; 74 | dispatch_once(&onceToken, ^{ 75 | _af_defaultResponseSerializer = [AFHTTPResponseSerializer serializer]; 76 | }); 77 | 78 | #pragma clang diagnostic push 79 | #pragma clang diagnostic ignored "-Wgnu" 80 | return objc_getAssociatedObject(self, @selector(responseSerializer)) ?: _af_defaultResponseSerializer; 81 | #pragma clang diagnostic pop 82 | } 83 | 84 | - (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer { 85 | objc_setAssociatedObject(self, @selector(responseSerializer), responseSerializer, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 86 | } 87 | 88 | #pragma mark - 89 | 90 | - (void)loadRequest:(NSURLRequest *)request 91 | progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress 92 | success:(NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success 93 | failure:(void (^)(NSError *error))failure 94 | { 95 | [self loadRequest:request MIMEType:nil textEncodingName:nil progress:progress success:^NSData *(NSHTTPURLResponse *response, NSData *data) { 96 | NSStringEncoding stringEncoding = NSUTF8StringEncoding; 97 | if (response.textEncodingName) { 98 | CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)response.textEncodingName); 99 | if (encoding != kCFStringEncodingInvalidId) { 100 | stringEncoding = CFStringConvertEncodingToNSStringEncoding(encoding); 101 | } 102 | } 103 | 104 | NSString *string = [[NSString alloc] initWithData:data encoding:stringEncoding]; 105 | if (success) { 106 | string = success(response, string); 107 | } 108 | 109 | return [string dataUsingEncoding:stringEncoding]; 110 | } failure:failure]; 111 | } 112 | 113 | - (void)loadRequest:(NSURLRequest *)request 114 | MIMEType:(NSString *)MIMEType 115 | textEncodingName:(NSString *)textEncodingName 116 | progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress 117 | success:(NSData * (^)(NSHTTPURLResponse *response, NSData *data))success 118 | failure:(void (^)(NSError *error))failure 119 | { 120 | NSParameterAssert(request); 121 | 122 | if (self.af_URLSessionTask.state == NSURLSessionTaskStateRunning || self.af_URLSessionTask.state == NSURLSessionTaskStateSuspended) { 123 | [self.af_URLSessionTask cancel]; 124 | } 125 | self.af_URLSessionTask = nil; 126 | 127 | __weak __typeof(self)weakSelf = self; 128 | NSURLSessionDataTask *dataTask; 129 | dataTask = [self.sessionManager 130 | GET:request.URL.absoluteString 131 | parameters:nil 132 | progress:nil 133 | success:^(NSURLSessionDataTask * _Nonnull task, id _Nonnull responseObject) { 134 | __strong __typeof(weakSelf) strongSelf = weakSelf; 135 | if (success) { 136 | success((NSHTTPURLResponse *)task.response, responseObject); 137 | } 138 | [strongSelf loadData:responseObject MIMEType:MIMEType textEncodingName:textEncodingName baseURL:[task.currentRequest URL]]; 139 | 140 | if ([strongSelf.delegate respondsToSelector:@selector(webViewDidStartLoad:)]) { 141 | [strongSelf.delegate webViewDidFinishLoad:strongSelf]; 142 | } 143 | } 144 | failure:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) { 145 | if (failure) { 146 | failure(error); 147 | } 148 | }]; 149 | self.af_URLSessionTask = dataTask; 150 | if (progress != nil) { 151 | *progress = [self.sessionManager downloadProgressForTask:dataTask]; 152 | } 153 | [self.af_URLSessionTask resume]; 154 | 155 | if ([self.delegate respondsToSelector:@selector(webViewDidStartLoad:)]) { 156 | [self.delegate webViewDidStartLoad:self]; 157 | } 158 | } 159 | 160 | @end 161 | 162 | #endif -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Private/AFNetworking/AFAutoPurgingImageCache.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Private/AFNetworking/AFHTTPSessionManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFHTTPSessionManager.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Private/AFNetworking/AFImageDownloader.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/AFImageDownloader.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Private/AFNetworking/AFNetworkActivityIndicatorManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Private/AFNetworking/AFNetworkReachabilityManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFNetworkReachabilityManager.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Private/AFNetworking/AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFNetworking.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Private/AFNetworking/AFSecurityPolicy.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFSecurityPolicy.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Private/AFNetworking/AFURLRequestSerialization.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLRequestSerialization.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Private/AFNetworking/AFURLResponseSerialization.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLResponseSerialization.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Private/AFNetworking/AFURLSessionManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLSessionManager.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Private/AFNetworking/UIActivityIndicatorView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Private/AFNetworking/UIButton+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Private/AFNetworking/UIImage+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Private/AFNetworking/UIImageView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Private/AFNetworking/UIKit+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Private/AFNetworking/UIProgressView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Private/AFNetworking/UIRefreshControl+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Private/AFNetworking/UIWebView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Public/AFNetworking/AFAutoPurgingImageCache.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Public/AFNetworking/AFHTTPSessionManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFHTTPSessionManager.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Public/AFNetworking/AFImageDownloader.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/AFImageDownloader.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Public/AFNetworking/AFNetworkActivityIndicatorManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Public/AFNetworking/AFNetworkReachabilityManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFNetworkReachabilityManager.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Public/AFNetworking/AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFNetworking.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Public/AFNetworking/AFSecurityPolicy.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFSecurityPolicy.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Public/AFNetworking/AFURLRequestSerialization.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLRequestSerialization.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Public/AFNetworking/AFURLResponseSerialization.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLResponseSerialization.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Public/AFNetworking/AFURLSessionManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLSessionManager.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Public/AFNetworking/UIActivityIndicatorView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Public/AFNetworking/UIButton+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Public/AFNetworking/UIImage+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Public/AFNetworking/UIImageView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Public/AFNetworking/UIKit+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Public/AFNetworking/UIProgressView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Public/AFNetworking/UIRefreshControl+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Headers/Public/AFNetworking/UIWebView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h -------------------------------------------------------------------------------- /ZCNetworking/Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - AFNetworking (3.1.0): 3 | - AFNetworking/NSURLSession (= 3.1.0) 4 | - AFNetworking/Reachability (= 3.1.0) 5 | - AFNetworking/Security (= 3.1.0) 6 | - AFNetworking/Serialization (= 3.1.0) 7 | - AFNetworking/UIKit (= 3.1.0) 8 | - AFNetworking/NSURLSession (3.1.0): 9 | - AFNetworking/Reachability 10 | - AFNetworking/Security 11 | - AFNetworking/Serialization 12 | - AFNetworking/Reachability (3.1.0) 13 | - AFNetworking/Security (3.1.0) 14 | - AFNetworking/Serialization (3.1.0) 15 | - AFNetworking/UIKit (3.1.0): 16 | - AFNetworking/NSURLSession 17 | 18 | DEPENDENCIES: 19 | - AFNetworking 20 | 21 | SPEC CHECKSUMS: 22 | AFNetworking: 5e0e199f73d8626b11e79750991f5d173d1f8b67 23 | 24 | PODFILE CHECKSUM: 4eb686940e507bf97379ed297dd0d934c39708ff 25 | 26 | COCOAPODS: 1.0.0.beta.6 27 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/Pods.xcodeproj/xcuserdata/charles.xcuserdatad/xcschemes/AFNetworking.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/Pods.xcodeproj/xcuserdata/charles.xcuserdatad/xcschemes/Pods-ZCNetworking.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/Pods.xcodeproj/xcuserdata/charles.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | AFNetworking.xcscheme 8 | 9 | isShown 10 | 11 | 12 | Pods-ZCNetworking.xcscheme 13 | 14 | isShown 15 | 16 | 17 | 18 | SuppressBuildableAutocreation 19 | 20 | 8EEC08977EB9CC6968C0ABD90B4FBC6D 21 | 22 | primary 23 | 24 | 25 | 928353533005A4198EBDA5B700D37B64 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/Target Support Files/AFNetworking/AFNetworking-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_AFNetworking : NSObject 3 | @end 4 | @implementation PodsDummy_AFNetworking 5 | @end 6 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/Target Support Files/AFNetworking/AFNetworking-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | #ifndef TARGET_OS_IOS 6 | #define TARGET_OS_IOS TARGET_OS_IPHONE 7 | #endif 8 | 9 | #ifndef TARGET_OS_WATCH 10 | #define TARGET_OS_WATCH 0 11 | #endif 12 | 13 | #ifndef TARGET_OS_TV 14 | #define TARGET_OS_TV 0 15 | #endif 16 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/Target Support Files/AFNetworking/AFNetworking.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = $PODS_SHARED_BUILD_DIR/AFNetworking 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/AFNetworking" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" 4 | OTHER_LDFLAGS = -framework "CoreGraphics" -framework "MobileCoreServices" -framework "Security" -framework "SystemConfiguration" 5 | PODS_ROOT = ${SRCROOT} 6 | PODS_SHARED_BUILD_DIR = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 8 | SKIP_INSTALL = YES 9 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/Target Support Files/Pods-ZCNetworking/Pods-ZCNetworking-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## AFNetworking 5 | 6 | Copyright (c) 2011–2016 Alamofire Software Foundation (http://alamofire.org/) 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | 26 | Generated by CocoaPods - https://cocoapods.org 27 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/Target Support Files/Pods-ZCNetworking/Pods-ZCNetworking-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Copyright (c) 2011–2016 Alamofire Software Foundation (http://alamofire.org/) 18 | 19 | Permission is hereby granted, free of charge, to any person obtaining a copy 20 | of this software and associated documentation files (the "Software"), to deal 21 | in the Software without restriction, including without limitation the rights 22 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 23 | copies of the Software, and to permit persons to whom the Software is 24 | furnished to do so, subject to the following conditions: 25 | 26 | The above copyright notice and this permission notice shall be included in 27 | all copies or substantial portions of the Software. 28 | 29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 35 | THE SOFTWARE. 36 | 37 | Title 38 | AFNetworking 39 | Type 40 | PSGroupSpecifier 41 | 42 | 43 | FooterText 44 | Generated by CocoaPods - https://cocoapods.org 45 | Title 46 | 47 | Type 48 | PSGroupSpecifier 49 | 50 | 51 | StringsTable 52 | Acknowledgements 53 | Title 54 | Acknowledgements 55 | 56 | 57 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/Target Support Files/Pods-ZCNetworking/Pods-ZCNetworking-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_ZCNetworking : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_ZCNetworking 5 | @end 6 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/Target Support Files/Pods-ZCNetworking/Pods-ZCNetworking-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 6 | 7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 8 | 9 | install_framework() 10 | { 11 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 12 | local source="${BUILT_PRODUCTS_DIR}/$1" 13 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 14 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 15 | elif [ -r "$1" ]; then 16 | local source="$1" 17 | fi 18 | 19 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 20 | 21 | if [ -L "${source}" ]; then 22 | echo "Symlinked..." 23 | source="$(readlink "${source}")" 24 | fi 25 | 26 | # use filter instead of exclude so missing patterns dont' throw errors 27 | echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 28 | rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 29 | 30 | local basename 31 | basename="$(basename -s .framework "$1")" 32 | binary="${destination}/${basename}.framework/${basename}" 33 | if ! [ -r "$binary" ]; then 34 | binary="${destination}/${basename}" 35 | fi 36 | 37 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 38 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 39 | strip_invalid_archs "$binary" 40 | fi 41 | 42 | # Resign the code if required by the build settings to avoid unstable apps 43 | code_sign_if_enabled "${destination}/$(basename "$1")" 44 | 45 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 46 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 47 | local swift_runtime_libs 48 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 49 | for lib in $swift_runtime_libs; do 50 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 51 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 52 | code_sign_if_enabled "${destination}/${lib}" 53 | done 54 | fi 55 | } 56 | 57 | # Signs a framework with the provided identity 58 | code_sign_if_enabled() { 59 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 60 | # Use the current code_sign_identitiy 61 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 62 | echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements \"$1\"" 63 | /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements "$1" 64 | fi 65 | } 66 | 67 | # Strip invalid architectures 68 | strip_invalid_archs() { 69 | binary="$1" 70 | # Get architectures for current file 71 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" 72 | stripped="" 73 | for arch in $archs; do 74 | if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then 75 | # Strip non-valid architectures in-place 76 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 77 | stripped="$stripped $arch" 78 | fi 79 | done 80 | if [[ "$stripped" ]]; then 81 | echo "Stripped $binary of architectures:$stripped" 82 | fi 83 | } 84 | 85 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/Target Support Files/Pods-ZCNetworking/Pods-ZCNetworking-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | XCASSET_FILES=() 10 | 11 | case "${TARGETED_DEVICE_FAMILY}" in 12 | 1,2) 13 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 14 | ;; 15 | 1) 16 | TARGET_DEVICE_ARGS="--target-device iphone" 17 | ;; 18 | 2) 19 | TARGET_DEVICE_ARGS="--target-device ipad" 20 | ;; 21 | *) 22 | TARGET_DEVICE_ARGS="--target-device mac" 23 | ;; 24 | esac 25 | 26 | realpath() { 27 | DIRECTORY="$(cd "${1%/*}" && pwd)" 28 | FILENAME="${1##*/}" 29 | echo "$DIRECTORY/$FILENAME" 30 | } 31 | 32 | install_resource() 33 | { 34 | if [[ "$1" = /* ]] ; then 35 | RESOURCE_PATH="$1" 36 | else 37 | RESOURCE_PATH="${PODS_ROOT}/$1" 38 | fi 39 | if [[ ! -e "$RESOURCE_PATH" ]] ; then 40 | cat << EOM 41 | error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script. 42 | EOM 43 | exit 1 44 | fi 45 | case $RESOURCE_PATH in 46 | *.storyboard) 47 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 48 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 49 | ;; 50 | *.xib) 51 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT}" 52 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" 53 | ;; 54 | *.framework) 55 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 56 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 57 | echo "rsync -av $RESOURCE_PATH ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 58 | rsync -av "$RESOURCE_PATH" "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 59 | ;; 60 | *.xcdatamodel) 61 | echo "xcrun momc \"$RESOURCE_PATH\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" 62 | xcrun momc "$RESOURCE_PATH" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom" 63 | ;; 64 | *.xcdatamodeld) 65 | echo "xcrun momc \"$RESOURCE_PATH\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" 66 | xcrun momc "$RESOURCE_PATH" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd" 67 | ;; 68 | *.xcmappingmodel) 69 | echo "xcrun mapc \"$RESOURCE_PATH\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" 70 | xcrun mapc "$RESOURCE_PATH" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm" 71 | ;; 72 | *.xcassets) 73 | ABSOLUTE_XCASSET_FILE=$(realpath "$RESOURCE_PATH") 74 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") 75 | ;; 76 | *) 77 | echo "$RESOURCE_PATH" 78 | echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY" 79 | ;; 80 | esac 81 | } 82 | 83 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 84 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 85 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then 86 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 87 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 88 | fi 89 | rm -f "$RESOURCES_TO_COPY" 90 | 91 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] 92 | then 93 | # Find all other xcassets (this unfortunately includes those of path pods and other targets). 94 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) 95 | while read line; do 96 | if [[ $line != "`realpath $PODS_ROOT`*" ]]; then 97 | XCASSET_FILES+=("$line") 98 | fi 99 | done <<<"$OTHER_XCASSETS" 100 | 101 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 102 | fi 103 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/Target Support Files/Pods-ZCNetworking/Pods-ZCNetworking.debug.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" 3 | LIBRARY_SEARCH_PATHS = $(inherited) "$CONFIGURATION_BUILD_DIR/AFNetworking" 4 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/AFNetworking" 5 | OTHER_LDFLAGS = $(inherited) -ObjC -l"AFNetworking" -framework "CoreGraphics" -framework "MobileCoreServices" -framework "Security" -framework "SystemConfiguration" 6 | PODS_ROOT = ${SRCROOT}/Pods 7 | -------------------------------------------------------------------------------- /ZCNetworking/Pods/Target Support Files/Pods-ZCNetworking/Pods-ZCNetworking.release.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" 3 | LIBRARY_SEARCH_PATHS = $(inherited) "$CONFIGURATION_BUILD_DIR/AFNetworking" 4 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/AFNetworking" 5 | OTHER_LDFLAGS = $(inherited) -ObjC -l"AFNetworking" -framework "CoreGraphics" -framework "MobileCoreServices" -framework "Security" -framework "SystemConfiguration" 6 | PODS_ROOT = ${SRCROOT}/Pods 7 | -------------------------------------------------------------------------------- /ZCNetworking/ZCNetworking.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ZCNetworking/ZCNetworking.xcodeproj/project.xcworkspace/xcuserdata/charles.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ooppstef/ZCNetworking/6b8083da1683f479071b393dcfb747e0d383545c/ZCNetworking/ZCNetworking.xcodeproj/project.xcworkspace/xcuserdata/charles.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /ZCNetworking/ZCNetworking.xcodeproj/xcuserdata/charles.xcuserdatad/xcschemes/ZCNetworking.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 74 | 76 | 82 | 83 | 84 | 85 | 89 | 90 | 91 | 92 | 93 | 94 | 100 | 102 | 108 | 109 | 110 | 111 | 113 | 114 | 117 | 118 | 119 | -------------------------------------------------------------------------------- /ZCNetworking/ZCNetworking.xcodeproj/xcuserdata/charles.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ZCNetworking.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 56CCAECE1CC0CDB1006227A9 16 | 17 | primary 18 | 19 | 20 | 56CCAEE71CC0CDB1006227A9 21 | 22 | primary 23 | 24 | 25 | 56CCAEF21CC0CDB1006227A9 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /ZCNetworking/ZCNetworking.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ZCNetworking/ZCNetworking.xcworkspace/xcuserdata/charles.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ooppstef/ZCNetworking/6b8083da1683f479071b393dcfb747e0d383545c/ZCNetworking/ZCNetworking.xcworkspace/xcuserdata/charles.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /ZCNetworking/ZCNetworking.xcworkspace/xcuserdata/charles.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /ZCNetworking/ZCNetworking/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // ZCNetworking 4 | // 5 | // Created by charles on 16/4/15. 6 | // Copyright © 2016年 charles. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /ZCNetworking/ZCNetworking/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // ZCNetworking 4 | // 5 | // Created by charles on 16/4/15. 6 | // Copyright © 2016年 charles. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /ZCNetworking/ZCNetworking/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /ZCNetworking/ZCNetworking/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /ZCNetworking/ZCNetworking/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /ZCNetworking/ZCNetworking/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | NSAppTransportSecurity 26 | 27 | NSAllowsArbitraryLoads 28 | 29 | 30 | UILaunchStoryboardName 31 | LaunchScreen 32 | UIMainStoryboardFile 33 | Main 34 | UIRequiredDeviceCapabilities 35 | 36 | armv7 37 | 38 | UISupportedInterfaceOrientations 39 | 40 | UIInterfaceOrientationPortrait 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | UISupportedInterfaceOrientations~ipad 45 | 46 | UIInterfaceOrientationPortrait 47 | UIInterfaceOrientationPortraitUpsideDown 48 | UIInterfaceOrientationLandscapeLeft 49 | UIInterfaceOrientationLandscapeRight 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /ZCNetworking/ZCNetworking/Sources/ZCApiAction.h: -------------------------------------------------------------------------------- 1 | // 2 | // ZCApiAction.h 3 | // ZCNetworking 4 | // 5 | // Created by charles on 16/4/15. 6 | // Copyright © 2016年 charles. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "ZCBlockDefine.h" 11 | 12 | typedef NS_ENUM(NSInteger, HttpMethod) { 13 | httpGet = 1, 14 | HttpPost, 15 | HttpPut, 16 | HttpDelete, 17 | HttpHead 18 | }; 19 | 20 | 21 | @interface ZCApiAction : NSObject 22 | 23 | /** 24 | * 参数,只读. 25 | 已初始化,可以直接使用. 26 | */ 27 | @property (nonatomic, strong, readonly) NSMutableDictionary *params; 28 | /** 29 | * Http methods,默认Get.只读. 30 | 修改使用setHttpMethod:方法 31 | */ 32 | @property (nonatomic, copy, readonly) NSString *method; 33 | 34 | /** 35 | * 相对url,不包含domain 36 | */ 37 | @property (nonatomic, copy) NSString *url; 38 | 39 | /** 40 | * 超时时间,默认180s 41 | */ 42 | @property (nonatomic, assign) NSTimeInterval timeout; 43 | 44 | /** 45 | * Http headers 46 | */ 47 | @property (nonatomic, strong) NSDictionary *headers; 48 | 49 | /** 50 | * Http请求log,建议调试的时候打开 51 | */ 52 | @property (nonatomic, assign) BOOL showLog; 53 | 54 | /** 55 | * 请求即将执行时候的回调,可用于启动hud等 56 | */ 57 | @property (nonatomic, copy) ZCVoidBlock actionWillInvokeBlock; 58 | 59 | /** 60 | * 请求执行完毕的回调,可用于关闭hud等.包含参数isSuccess,表示请求是否执行成功. 61 | */ 62 | @property (nonatomic, copy) ZCActionComplation actionDidInvokeBlock; 63 | 64 | /** 65 | * 标志.执行batch操作的时候,优先通过identifier来汇总结果.如果没有,则通过url来汇总. 66 | */ 67 | @property (nonatomic, copy) NSString *identifier; 68 | 69 | - (instancetype)initWithURL:(NSString *)url; 70 | - (void)setHttpMethod:(enum HttpMethod)method; 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /ZCNetworking/ZCNetworking/Sources/ZCApiAction.m: -------------------------------------------------------------------------------- 1 | // 2 | // ZCApiAction.m 3 | // ZCNetworking 4 | // 5 | // Created by charles on 16/4/15. 6 | // Copyright © 2016年 charles. All rights reserved. 7 | // 8 | 9 | #import "ZCApiAction.h" 10 | 11 | @interface ZCApiAction () 12 | 13 | @property (nonatomic, strong, readwrite) NSMutableDictionary *params; 14 | @property (nonatomic, copy, readwrite) NSString *method; 15 | 16 | @end 17 | 18 | @implementation ZCApiAction 19 | 20 | #pragma mark - life cycle 21 | 22 | - (instancetype)init { 23 | if (self = [super init]) { 24 | _method = @"GET"; 25 | _params = [NSMutableDictionary dictionary]; 26 | _timeout = 180; 27 | } 28 | return self; 29 | } 30 | 31 | - (instancetype)initWithURL:(NSString *)url { 32 | self = [self init]; 33 | _url = url; 34 | return self; 35 | } 36 | 37 | - (void)setHttpMethod:(enum HttpMethod)method { 38 | switch (method) { 39 | case httpGet: 40 | self.method = @"GET"; 41 | break; 42 | case HttpPost: 43 | self.method = @"POST"; 44 | break; 45 | case HttpDelete: 46 | self.method = @"DELETE"; 47 | break; 48 | case HttpPut: 49 | self.method = @"PUT"; 50 | break; 51 | default: 52 | break; 53 | } 54 | } 55 | 56 | @end 57 | -------------------------------------------------------------------------------- /ZCNetworking/ZCNetworking/Sources/ZCApiDownloadAction.h: -------------------------------------------------------------------------------- 1 | // 2 | // ZCApiDownloadAction.h 3 | // ZCNetworking 4 | // 5 | // Created by charles on 16/4/21. 6 | // Copyright © 2016年 charles. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "ZCApiAction.h" 11 | 12 | @interface ZCApiDownloadAction : ZCApiAction 13 | 14 | @property (nonatomic, copy) NSString *path; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /ZCNetworking/ZCNetworking/Sources/ZCApiDownloadAction.m: -------------------------------------------------------------------------------- 1 | // 2 | // ZCApiDownloadAction.m 3 | // ZCNetworking 4 | // 5 | // Created by charles on 16/4/21. 6 | // Copyright © 2016年 charles. All rights reserved. 7 | // 8 | 9 | #import "ZCApiDownloadAction.h" 10 | 11 | @implementation ZCApiDownloadAction 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ZCNetworking/ZCNetworking/Sources/ZCApiLauncher.h: -------------------------------------------------------------------------------- 1 | // 2 | // ZCApiLauncher.h 3 | // ZCNetworking 4 | // 5 | // Created by charles on 16/4/21. 6 | // Copyright © 2016年 charles. All rights reserved. 7 | // 8 | 9 | #import "ZCNetworking.h" 10 | #import "ZCApiRunner.h" 11 | #import "ZCApiAction.h" 12 | #import "ZCApiUploadAction.h" 13 | #import "ZCApiDownloadAction.h" 14 | #import "ZCChainProcessor.h" 15 | -------------------------------------------------------------------------------- /ZCNetworking/ZCNetworking/Sources/ZCApiRunner.h: -------------------------------------------------------------------------------- 1 | // 2 | // ZCApiRunner.h 3 | // ZCNetworking 4 | // 5 | // Created by charles on 16/4/15. 6 | // Copyright © 2016年 charles. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "ZCBlockDefine.h" 11 | 12 | @class ZCApiAction; 13 | @class ZCApiUploadAction; 14 | @class ZCApiDownloadAction; 15 | 16 | @interface ZCApiRunner : NSObject 17 | 18 | /** 19 | * 强制使用domain,而非根据编译环境 20 | */ 21 | @property (nonatomic, copy) NSString *forceDomain; 22 | 23 | /** 24 | * 全局参数,例如version/platform等 25 | */ 26 | @property (nonatomic, strong) NSDictionary *globleParams; 27 | 28 | /** 29 | * 单例 30 | * 31 | * @return ZCApiRunner 32 | */ 33 | + (instancetype)sharedInstance; 34 | 35 | /** 36 | * 根据编译环境配置host,使得不会因为疏忽导致服务器错误 37 | * 38 | * @param debug 测试服务器host 39 | * @param release 正式服务器host 40 | */ 41 | - (void)startWithDebugDomain:(NSString *)debug releaseDomain:(NSString *)release; 42 | 43 | /** 44 | * 获取当前host 45 | * 46 | * @return 当前host 47 | */ 48 | - (NSString *)currentDomain; 49 | 50 | /** 51 | * 是否为测试服务器host 52 | * 53 | * @return 是否为测试服务器host 54 | */ 55 | - (BOOL)isDebugDomain; 56 | 57 | /** 58 | * 添加请求的http header 59 | * 60 | * @param dict http header 61 | */ 62 | - (void)headerForSessionConfiguration:(NSDictionary *)dict; 63 | 64 | /** 65 | * 添加请求的http header 66 | * 67 | * @param value value 68 | * @param key key 69 | */ 70 | - (void)addValue:(id)value forHeaderKey:(NSString *)key; 71 | 72 | /** 73 | * 删除请求的header 74 | * 75 | * @param key key 76 | */ 77 | - (void)removeHeaderKey:(NSString *)key; 78 | 79 | /** 80 | * 请求逻辑成功标志,不设置则默认所有请求物理成功(http 200)则逻辑也成功 81 | * 82 | * @param key 逻辑成功标志 83 | */ 84 | - (void)codeKey:(NSString *)key; 85 | 86 | /** 87 | * 请求逻辑成功codes 88 | * 89 | * @param codes 逻辑成功codes 90 | */ 91 | - (void)successCodes:(NSArray *)codes; 92 | 93 | /** 94 | * 请求逻辑失败后,一些典型/公共codes以及处理回调.例如登录失效 95 | * 96 | * @param codes 逻辑失败codes 97 | * @param handler 逻辑失败回调 98 | */ 99 | - (void)warningReturnCodes:(NSArray *)codes withHandler:(void (^) (NSString *code))handler; 100 | 101 | /** 102 | * 通过action进行数据任务 103 | * 104 | * @param action ZCApiAction 105 | * @param success 成功回调(物理&&逻辑成功) 106 | * @param failure 失败回调(物理||逻辑失败) 107 | * 108 | * @return NSURLSessionDataTask 109 | */ 110 | - (NSURLSessionDataTask *)runAction:(ZCApiAction *)action success:(ZCTypeBlock)success failure:(ZCErrorBlock)failure; 111 | 112 | /** 113 | * 通过action进行上传任务 114 | * 115 | * @param action ZCApiUploadAction 116 | @param action NSProgress 117 | * @param success 成功回调(物理&&逻辑成功) 118 | * @param failure 失败回调(物理||逻辑失败) 119 | * 120 | * @return NSURLSessionUploadTask 121 | */ 122 | - (NSURLSessionUploadTask *)uploadAction:(ZCApiUploadAction *)action progress:(void (^) (NSProgress *uploadProgress))progress success:(ZCTypeBlock)success failure:(ZCErrorBlock)failure; 123 | 124 | /** 125 | * 通过action进行下载任务 126 | * 127 | * @param action ZCApiDownloadAction 128 | * @param progress NSProgress 129 | * @param success 成功回调 130 | * @param failure 失败回调 131 | * 132 | * @return NSURLSessionDownloadTask 133 | */ 134 | - (NSURLSessionDownloadTask *)downloadAction:(ZCApiDownloadAction *)action progress:(void (^) (NSProgress *downloadProgress))progress success:(ZCVoidBlock)success failure:(ZCErrorBlock)failure; 135 | 136 | /** 137 | * 批量请求,顺序为止,所有请求成功后执行success,某个请求失败后立即执行failure 138 | * 139 | * @param actions 请求列表 140 | * @param success 成功回调 141 | * @param failure 失败回调 142 | */ 143 | - (void)batchTasksWithActions:(NSArray *)actions success:(ZCDictBlock)success failure:(ZCErrorBlock)failure; 144 | 145 | - (void)chainTasksWithActions:(NSArray *)actions success:(ZCDictBlock)success failure:(ZCErrorBlock)failure; 146 | 147 | @end 148 | -------------------------------------------------------------------------------- /ZCNetworking/ZCNetworking/Sources/ZCApiUploadAction.h: -------------------------------------------------------------------------------- 1 | // 2 | // ZCApiUploadAction.h 3 | // MeClassManager 4 | // 5 | // Created by charleszhang on 15/9/14. 6 | // Copyright (c) 2015年 com.meclass. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "ZCApiAction.h" 11 | 12 | @interface ZCApiUploadAction : ZCApiAction 13 | 14 | /** 15 | * 这两组值是互斥的,为了方便单个Object上传任务和多个Object上传任务 16 | 如果每次均以数组的形式上传单个文件,则在实际使用过程中(大部分为单个文件上传,例如上传头像等)会显得麻烦 17 | */ 18 | 19 | @property (nonatomic, strong) NSData *data; 20 | @property (nonatomic, copy) NSString *uploadName; 21 | @property (nonatomic, copy) NSString *fileName; 22 | @property (nonatomic, copy) NSString *mimeType; 23 | 24 | @property (nonatomic, strong) NSArray *dataArray; 25 | @property (nonatomic, strong) NSArray *uploadNameArray; 26 | @property (nonatomic, strong) NSArray *fileNameArray; 27 | @property (nonatomic, strong) NSArray *mimeTypeArray; 28 | 29 | /** 30 | * 检查是否为合格的多个组件Object上传action 31 | * 必须相关的array count相同并且大于0 32 | */ 33 | - (BOOL)isValidMultiObjectUploadAction; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /ZCNetworking/ZCNetworking/Sources/ZCApiUploadAction.m: -------------------------------------------------------------------------------- 1 | // 2 | // ZCApiUploadAction.m 3 | // MeClassManager 4 | // 5 | // Created by charleszhang on 15/9/14. 6 | // Copyright (c) 2015年 com.meclass. All rights reserved. 7 | // 8 | 9 | #import "ZCApiUploadAction.h" 10 | 11 | @implementation ZCApiUploadAction 12 | 13 | - (BOOL)isValidMultiObjectUploadAction { 14 | BOOL flag = NO; 15 | NSInteger dataArrayCount = [self.dataArray count]; 16 | if ([self.dataArray count] > 0) { 17 | if (dataArrayCount == [self.uploadNameArray count] && dataArrayCount == [self.fileNameArray count] && [self.mimeTypeArray count] > 0) { 18 | flag = YES; 19 | } 20 | } 21 | return flag; 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /ZCNetworking/ZCNetworking/Sources/ZCBlockDefine.h: -------------------------------------------------------------------------------- 1 | // 2 | // ZCBlockDefine.h 3 | // ZCNetworking 4 | // 5 | // Created by charles on 16/4/15. 6 | // Copyright © 2016年 charles. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef void (^ZCVoidBlock) (void); 12 | typedef void (^ZCArrayBlock) (NSArray *array); 13 | typedef void (^ZCDictBlock) (NSDictionary *dict); 14 | typedef void (^ZCErrorBlock) (NSError *error); 15 | typedef void (^ZCTypeBlock) (id object); 16 | typedef void (^ZCImageBlock) (UIImage *image); 17 | typedef void (^ZCWarningCodesHandler) (NSString *code); 18 | typedef void (^ZCActionComplation) (BOOL isSuccess); -------------------------------------------------------------------------------- /ZCNetworking/ZCNetworking/Sources/ZCChainProcessor.h: -------------------------------------------------------------------------------- 1 | // 2 | // ZCChainProcessor.h 3 | // ZCNetworking 4 | // 5 | // Created by charles on 16/6/5. 6 | // Copyright © 2016年 charles. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "ZCApiAction.h" 11 | #import "ZCBlockDefine.h" 12 | 13 | @interface ZCChainProcessor : NSObject 14 | 15 | - (instancetype)initWithActions:(NSArray *)actions; 16 | - (void)startWithSuccess:(ZCDictBlock)success failure:(ZCErrorBlock)failure; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /ZCNetworking/ZCNetworking/Sources/ZCChainProcessor.m: -------------------------------------------------------------------------------- 1 | // 2 | // ZCChainProcessor.m 3 | // ZCNetworking 4 | // 5 | // Created by charles on 16/6/5. 6 | // Copyright © 2016年 charles. All rights reserved. 7 | // 8 | 9 | #import "ZCChainProcessor.h" 10 | #import "ZCApiRunner.h" 11 | 12 | @interface ZCChainProcessor () 13 | 14 | @property (nonatomic, strong) NSArray *actions; 15 | @property (nonatomic, assign) NSInteger currentIndex; 16 | @property (nonatomic, strong) NSMutableDictionary *resultDict; 17 | @property (nonatomic, copy) ZCDictBlock success; 18 | @property (nonatomic, copy) ZCErrorBlock failure; 19 | 20 | @end 21 | 22 | @implementation ZCChainProcessor 23 | 24 | - (instancetype)initWithActions:(NSArray *)actions { 25 | if (self = [super init]) { 26 | _actions = actions; 27 | _resultDict = @{}.mutableCopy; 28 | [self addObserver:self forKeyPath:@"currentIndex" options:NSKeyValueObservingOptionNew context:nil]; 29 | } 30 | return self; 31 | } 32 | 33 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { 34 | if (_currentIndex > 0 && _currentIndex < _actions.count) { 35 | [self runActions]; 36 | } 37 | } 38 | 39 | - (NSError *)valiedate { 40 | if (_actions.count == 0) { 41 | return [NSError errorWithDomain:@"No Actions" code:-500 userInfo:nil]; 42 | } 43 | 44 | if (_currentIndex < 0 || _currentIndex > _actions.count - 1) { 45 | return [NSError errorWithDomain:@"Inner Error" code:600 userInfo:nil]; 46 | } 47 | 48 | return nil; 49 | } 50 | 51 | - (void)startWithSuccess:(ZCDictBlock)success failure:(ZCErrorBlock)failure { 52 | _success = success; 53 | _failure = failure; 54 | 55 | NSError *error = [self valiedate]; 56 | if (!error) { 57 | [self runActions]; 58 | } 59 | else { 60 | !failure ? : failure(error); 61 | } 62 | } 63 | 64 | - (void)runActions { 65 | ZCApiAction *action = _actions[_currentIndex]; 66 | __weak typeof(self) weakSelf = self; 67 | [[ZCApiRunner sharedInstance] runAction:action success:^(id object) { 68 | weakSelf.resultDict[@(weakSelf.currentIndex)] = object; 69 | if (weakSelf.currentIndex == weakSelf.actions.count - 1) { 70 | !weakSelf.success? : weakSelf.success(weakSelf.resultDict); 71 | } 72 | else { 73 | weakSelf.currentIndex++; 74 | } 75 | } failure:^(NSError *error) { 76 | !weakSelf.failure ? : weakSelf.failure(error); 77 | }]; 78 | } 79 | 80 | @end 81 | -------------------------------------------------------------------------------- /ZCNetworking/ZCNetworking/Sources/ZCNetworking.h: -------------------------------------------------------------------------------- 1 | // 2 | // ZCNetworking.h 3 | // ZCNetworking 4 | // 5 | // Created by charles on 16/4/15. 6 | // Copyright © 2016年 charles. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "ZCBlockDefine.h" 12 | 13 | @class AFHTTPSessionManager; 14 | 15 | typedef NS_ENUM(NSInteger, ZCConnectionType){ 16 | ZCConnectionTypeWifi = 0, 17 | ZCConnectionTypeWWAN, 18 | ZCConnectionTypeNone 19 | }; 20 | 21 | @interface ZCNetworking : NSObject 22 | 23 | @property (nonatomic, strong, readonly) NSURLSessionConfiguration *defaultConfigration; 24 | 25 | /** 26 | * 单例 27 | * 28 | * @return ZCNetworking instance 29 | */ 30 | + (instancetype)sharedInstance; 31 | 32 | /** 33 | * 获取当前网络状态 34 | * 35 | * @return ZCConnectionType 36 | */ 37 | - (enum ZCConnectionType)getConnectionType; 38 | 39 | /** 40 | * 通过url获取cookie 41 | * 42 | * @param url url 43 | * 44 | * @return 包含cookie的字典 45 | */ 46 | - (NSDictionary *)cookieForURL:(NSString *)url; 47 | 48 | /** 49 | * 通过url删除cookie 50 | * 51 | * @param url url 52 | */ 53 | - (void)deleteCookieWithURL:(NSString *)url; 54 | 55 | /** 56 | * 设置默认的NSURLSessionConfiguration 57 | * 58 | * @param configuration NSURLSessionConfiguration 59 | */ 60 | - (void)setDefaultSessionConfiguration:(NSURLSessionConfiguration *)configuration; 61 | 62 | /** 63 | * 默认状态,通过url,method,params发送request 64 | url为包含host的绝对路径,例如:http://www.baidu.com/action=user?uid=10 65 | methods:get/post/delete/put/head/patch 66 | * 67 | * @param url url:包含host 68 | * @param method method:get/post/delete/put/head/patch 69 | * @param params 参数 70 | * @param success 包含id类型的block 71 | * @param failure 包含NSError类型的block 72 | * 73 | * @return NSURLSessionDataTask 74 | */ 75 | - (NSURLSessionDataTask *)sendRequestWithURL:(NSString *)url method:(NSString *)method params:(NSDictionary *)params success:(ZCTypeBlock)success failure:(ZCErrorBlock)failure; 76 | 77 | /** 78 | * 自定义状态,通过configuration,url,method,params发送request 79 | configuration:NSURLSessionConfigurationr,自定义configuration 80 | url为包含host的绝对路径,例如:http://www.baidu.com/action=user?uid=10 81 | methods:get/post/delete/put/head/patch 82 | * 83 | * @param configuration NSURLSessionConfiguration 84 | * @param url url:包含host 85 | * @param method method:get/post/delete/put/head/patch 86 | * @param params 参数 87 | * @param success 包含id类型的block 88 | * @param failure 包含NSError类型的block 89 | * 90 | * @return NSURLSessionDataTask 91 | */ 92 | - (NSURLSessionDataTask *)sendRequestWithConfiguration:(NSURLSessionConfiguration *)configuration url:(NSString *)url method:(NSString *)method params:(NSDictionary *)params success:(ZCTypeBlock)success failure:(ZCErrorBlock)failure; 93 | 94 | /** 95 | * 默认状态,通过url获取图片 96 | * 97 | * @param url url为包含host的绝对路径 98 | * @param success 包含UIImage类型的block 99 | * @param failure 包含NSError类型的block 100 | * 101 | * @return NSURLSessionDataTask 102 | */ 103 | - (NSURLSessionDataTask *)loadImageWithURL:(NSString *)url success:(ZCImageBlock)success failure:(ZCErrorBlock)failure; 104 | 105 | /** 106 | * 自定义状态,可自定义request的header/cache policy等 107 | * 108 | * @param request NSURLRequest 109 | * @param success 包含UIImage类型的block 110 | * @param failure 包含NSError类型的block 111 | * 112 | * @return NSURLSessionDataTask 113 | */ 114 | - (NSURLSessionDataTask *)loadImageWithRequest:(NSURLRequest *)request success:(ZCImageBlock)success failure:(ZCErrorBlock)failure; 115 | 116 | /** 117 | * 默认状态,下载文件 118 | * 119 | * @param url url 120 | * @param path 文件保存地址 121 | * @param process 文件下载进度 122 | * @param success 下载完毕block 123 | * @param failure 包含NSError类型的block 124 | * 125 | * @return NSURLSessionDownloadTask 126 | */ 127 | - (NSURLSessionDownloadTask *)downloadFileByURL:(NSString *)url savePath:(NSString *)path process:(void (^) (NSProgress *downloadProgress))process success:(ZCVoidBlock)success failure:(ZCErrorBlock)failure; 128 | 129 | /** 130 | * 自定义状态下载文件 131 | * 132 | * @param configuration NSURLSessionConfiguration 133 | * @param request NSURLRequest 134 | * @param path 文件保存地址 135 | * @param process 文件下载进度 136 | * @param success 下载完毕block 137 | * @param failure 包含NSError类型的block 138 | * 139 | * @return NSURLSessionDownloadTask 140 | */ 141 | - (NSURLSessionDownloadTask *)downloadFileWithConfiguration:(NSURLSessionConfiguration *)configuration request:(NSURLRequest *)request savePath:(NSString *)path process:(void (^) (NSProgress *downloadProgress))process success:(ZCVoidBlock)success failure:(ZCErrorBlock)failure; 142 | 143 | /** 144 | * 默认状态,上传文件,data存放于http的body stream 145 | * 146 | * @param request NSURLRequest 147 | * @param process 文件上传进度 148 | * @param success 上传完毕block 149 | * @param failure 包含NSError类型的block 150 | * 151 | * @return NSURLSessionUploadTask 152 | */ 153 | - (NSURLSessionUploadTask *)uploadTaskByRequest:(NSURLRequest *)request process:(void (^) (NSProgress *uploadProgress))process success:(ZCTypeBlock)success failure:(ZCErrorBlock)failure; 154 | 155 | /** 156 | * 自定义状态上传文件 157 | * 158 | * @param configuration NSURLSessionConfiguration 159 | * @param request NSURLRequest 160 | * @param process 文件上传进度 161 | * @param success 上传完毕block 162 | * @param failure 包含NSError类型的block 163 | * 164 | * @return NSURLSessionUploadTask 165 | */ 166 | - (NSURLSessionUploadTask *)uploadTaskWithConfiguration:(NSURLSessionConfiguration *)configuration request:(NSURLRequest *)request process:(void (^) (NSProgress *uploadProgress))process success:(ZCTypeBlock)success failure:(ZCErrorBlock)failure; 167 | 168 | @end 169 | -------------------------------------------------------------------------------- /ZCNetworking/ZCNetworking/Sources/ZCNetworking.m: -------------------------------------------------------------------------------- 1 | // 2 | // ZCNetworking.m 3 | // ZCNetworking 4 | // 5 | // Created by charles on 16/4/15. 6 | // Copyright © 2016年 charles. All rights reserved. 7 | // 8 | 9 | #import "ZCNetworking.h" 10 | #import "AFNetworking.h" 11 | #import "AFImageDownloader.h" 12 | 13 | @interface ZCNetworking () 14 | 15 | @property (nonatomic, strong) AFHTTPSessionManager *manager; 16 | @property (nonatomic, assign) BOOL needToResetManager; 17 | 18 | @property (nonatomic, strong, readwrite) NSURLSessionConfiguration *defaultConfigration; 19 | 20 | @end 21 | 22 | @implementation ZCNetworking 23 | 24 | #pragma mark - life cycle 25 | 26 | + (instancetype)sharedInstance { 27 | static ZCNetworking *zcNetworking; 28 | static dispatch_once_t networkToken; 29 | dispatch_once(&networkToken, ^{ 30 | zcNetworking = [[ZCNetworking alloc] init]; 31 | NSURLCache *cache = [[NSURLCache alloc] initWithMemoryCapacity:4 * 1024 * 1024 diskCapacity:20 * 1024 * 1024 diskPath:nil]; 32 | [NSURLCache setSharedURLCache:cache]; 33 | }); 34 | return zcNetworking; 35 | } 36 | 37 | #pragma mark - utils 38 | 39 | - (enum ZCConnectionType)getConnectionType { 40 | AFNetworkReachabilityManager *manager = [AFNetworkReachabilityManager sharedManager]; 41 | enum ZCConnectionType type; 42 | if([manager isReachable]){ 43 | if([manager isReachableViaWiFi]){ 44 | type = ZCConnectionTypeWifi; 45 | } 46 | else{ 47 | type = ZCConnectionTypeWWAN; 48 | } 49 | } 50 | else{ 51 | type = ZCConnectionTypeNone; 52 | } 53 | return type; 54 | } 55 | 56 | - (NSDictionary *)cookieForURL:(NSString *)url { 57 | NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; 58 | storage.cookieAcceptPolicy = NSHTTPCookieAcceptPolicyAlways; 59 | NSArray *cookieStorage = [storage cookiesForURL:[NSURL URLWithString:url]]; 60 | NSDictionary *cookieHeaders = [NSHTTPCookie requestHeaderFieldsWithCookies:cookieStorage]; 61 | return cookieHeaders; 62 | } 63 | 64 | - (void)deleteCookieWithURL:(NSString *)url { 65 | NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; 66 | NSArray *cookieStorage = [storage cookiesForURL:[NSURL URLWithString:url]]; 67 | for (NSHTTPCookie *cookie in cookieStorage) { 68 | [storage deleteCookie:cookie]; 69 | } 70 | } 71 | 72 | - (void)setDefaultSessionConfiguration:(NSURLSessionConfiguration *)configuration { 73 | _defaultConfigration = configuration; 74 | } 75 | 76 | - (NSURLSessionConfiguration *)defaultConfigration { 77 | if (!_defaultConfigration) { 78 | return [NSURLSessionConfiguration defaultSessionConfiguration]; 79 | } 80 | else { 81 | return _defaultConfigration; 82 | } 83 | } 84 | 85 | - (NSString *)validURL:(NSString *)url { 86 | url = url.lowercaseString; 87 | if ([url hasPrefix:@"http"]) { 88 | return url; 89 | } 90 | else { 91 | return [NSString stringWithFormat:@"http://%@",url]; 92 | } 93 | return nil; 94 | } 95 | 96 | #pragma mark - actions 97 | 98 | - (NSURLSessionDataTask *)sendRequestWithURL:(NSString *)url method:(NSString *)method params:(NSDictionary *)params success:(ZCTypeBlock)success failure:(ZCErrorBlock)failure { 99 | return [self sendRequestWithConfiguration:nil url:url method:method params:params success:success failure:failure]; 100 | } 101 | 102 | - (NSURLSessionDataTask *)sendRequestWithConfiguration:(NSURLSessionConfiguration *)configuration url:(NSString *)url method:(NSString *)method params:(NSDictionary *)params success:(ZCTypeBlock)success failure:(ZCErrorBlock)failure { 103 | url = [self validURL:url]; 104 | NSURL *fullUrl = [NSURL URLWithString:url]; 105 | if (!fullUrl.host) { 106 | failure([NSError errorWithDomain:@"Illegal URL" code:-100 userInfo:nil]); 107 | return nil; 108 | } 109 | 110 | if (!_manager || _needToResetManager) { 111 | _manager = [self defaultManager]; 112 | _needToResetManager = NO; 113 | } 114 | if (configuration) { 115 | [self copyConfiguration:configuration]; 116 | _needToResetManager = YES; 117 | } 118 | 119 | NSURLSessionDataTask *task = nil; 120 | if ([[method uppercaseString] isEqualToString:@"GET"]) { 121 | task = [_manager GET:url parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { 122 | success(responseObject); 123 | } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { 124 | failure(error); 125 | }]; 126 | } 127 | else if ([[method uppercaseString] isEqualToString:@"POST"]) { 128 | task = [_manager POST:url parameters:params progress:nil success:^(NSURLSessionDataTask *task, id responseObject) { 129 | success(responseObject); 130 | } failure:^(NSURLSessionDataTask *task, NSError *error) { 131 | failure(error); 132 | }]; 133 | } 134 | else if ([[method uppercaseString] isEqualToString:@"DELETE"]) { 135 | task = [_manager DELETE:url parameters:params success:^(NSURLSessionDataTask *task, id responseObject) { 136 | success(responseObject); 137 | } failure:^(NSURLSessionDataTask *task, NSError *error) { 138 | failure(error); 139 | }]; 140 | } 141 | else if ([[method uppercaseString] isEqualToString:@"PUT"]) { 142 | task = [_manager PUT:url parameters:params success:^(NSURLSessionDataTask *task, id responseObject) { 143 | success(responseObject); 144 | } failure:^(NSURLSessionDataTask *task, NSError *error) { 145 | failure(error); 146 | }]; 147 | } 148 | else if ([[method uppercaseString] isEqualToString:@"HEAD"]) { 149 | task = [_manager HEAD:url parameters:params success:^(NSURLSessionDataTask * _Nonnull task) { 150 | success(task); 151 | } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { 152 | failure(error); 153 | }]; 154 | } 155 | return task; 156 | } 157 | 158 | - (NSURLSessionDataTask *)loadImageWithURL:(NSString *)url success:(ZCImageBlock)success failure:(ZCErrorBlock)failure { 159 | NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]]; 160 | return [self loadImageWithRequest:request success:success failure:failure]; 161 | } 162 | 163 | - (NSURLSessionDataTask *)loadImageWithRequest:(NSURLRequest *)request success:(ZCImageBlock)success failure:(ZCErrorBlock)failure { 164 | AFImageDownloadReceipt *receipt = [[AFImageDownloader defaultInstance] downloadImageForURLRequest:request success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull responseObject) { 165 | success(responseObject); 166 | } failure:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, NSError * _Nonnull error) { 167 | failure(error); 168 | }]; 169 | return receipt.task; 170 | } 171 | 172 | - (NSURLSessionDownloadTask *)downloadFileByURL:(NSString *)url savePath:(NSString *)path process:(void (^) (NSProgress *downloadProgress))process success:(ZCVoidBlock)success failure:(ZCErrorBlock)failure { 173 | NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]]; 174 | return [self downloadFileWithConfiguration:nil request:request savePath:path process:process success:success failure:failure];; 175 | } 176 | 177 | - (NSURLSessionDownloadTask *)downloadFileWithConfiguration:(NSURLSessionConfiguration *)configuration request:(NSURLRequest *)request savePath:(NSString *)path process:(void (^) (NSProgress *downloadProgress))process success:(ZCVoidBlock)success failure:(ZCErrorBlock)failure { 178 | if (!_manager || _needToResetManager) { 179 | _manager = [self defaultManager]; 180 | _needToResetManager = NO; 181 | } 182 | if (configuration) { 183 | [self copyConfiguration:configuration]; 184 | _needToResetManager = YES; 185 | } 186 | NSURLSessionDownloadTask *downloadTask = [_manager downloadTaskWithRequest:request progress:^(NSProgress * _Nonnull downloadProgress) { 187 | !process? : process(downloadProgress); 188 | } destination:^NSURL * _Nonnull(NSURL * _Nonnull targetPath, NSURLResponse * _Nonnull response) { 189 | return [NSURL fileURLWithPath:path]; 190 | } completionHandler:^(NSURLResponse * _Nonnull response, NSURL * _Nullable filePath, NSError * _Nullable error) { 191 | if (!error) { 192 | success(); 193 | } 194 | else { 195 | failure(error); 196 | } 197 | }]; 198 | [downloadTask resume]; 199 | return downloadTask; 200 | } 201 | 202 | - (NSURLSessionUploadTask *)uploadTaskByRequest:(NSURLRequest *)request process:(void (^) (NSProgress *uploadProgress))process success:(ZCTypeBlock)success failure:(ZCErrorBlock)failure { 203 | return [self uploadTaskWithConfiguration:nil request:request process:process success:success failure:failure]; 204 | } 205 | 206 | - (NSURLSessionUploadTask *)uploadTaskWithConfiguration:(NSURLSessionConfiguration *)configuration request:(NSURLRequest *)request process:(void (^) (NSProgress *uploadProgress))process success:(ZCTypeBlock)success failure:(ZCErrorBlock)failure { 207 | if (!_manager || _needToResetManager) { 208 | _manager = [self defaultManager]; 209 | _needToResetManager = NO; 210 | } 211 | if (configuration) { 212 | [self copyConfiguration:configuration]; 213 | _needToResetManager = YES; 214 | } 215 | 216 | NSURLSessionUploadTask *uploadTask = [_manager uploadTaskWithStreamedRequest:request progress:^(NSProgress * _Nonnull uploadProgress) { 217 | !process? : process(uploadProgress); 218 | } completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) { 219 | if (!error) { 220 | success(responseObject); 221 | } 222 | else { 223 | failure(error); 224 | } 225 | }]; 226 | 227 | [uploadTask resume]; 228 | return uploadTask; 229 | } 230 | 231 | #pragma mark - private methods 232 | 233 | - (void)copyConfiguration:(NSURLSessionConfiguration *)configuration { 234 | if (!_manager || !configuration) { 235 | return; 236 | } 237 | _manager.session.configuration.HTTPAdditionalHeaders = configuration.HTTPAdditionalHeaders; 238 | _manager.session.configuration.requestCachePolicy = configuration.requestCachePolicy; 239 | _manager.session.configuration.timeoutIntervalForRequest = configuration.timeoutIntervalForRequest; 240 | _manager.session.configuration.timeoutIntervalForResource = configuration.timeoutIntervalForResource; 241 | _manager.session.configuration.networkServiceType = configuration.networkServiceType; 242 | _manager.session.configuration.discretionary = configuration.discretionary; 243 | _manager.session.configuration.sharedContainerIdentifier = configuration.sharedContainerIdentifier; 244 | _manager.session.configuration.sessionSendsLaunchEvents = configuration.sessionSendsLaunchEvents; 245 | _manager.session.configuration.connectionProxyDictionary = configuration.connectionProxyDictionary; 246 | _manager.session.configuration.TLSMinimumSupportedProtocol = configuration.TLSMinimumSupportedProtocol; 247 | _manager.session.configuration.TLSMaximumSupportedProtocol = configuration.TLSMaximumSupportedProtocol; 248 | _manager.session.configuration.HTTPShouldUsePipelining = configuration.HTTPShouldUsePipelining; 249 | _manager.session.configuration.HTTPShouldSetCookies = configuration.HTTPShouldSetCookies; 250 | _manager.session.configuration.HTTPCookieAcceptPolicy = configuration.HTTPCookieAcceptPolicy; 251 | _manager.session.configuration.HTTPMaximumConnectionsPerHost = configuration.HTTPMaximumConnectionsPerHost; 252 | _manager.session.configuration.HTTPCookieStorage = configuration.HTTPCookieStorage; 253 | _manager.session.configuration.URLCredentialStorage = configuration.URLCredentialStorage; 254 | _manager.session.configuration.URLCache = configuration.URLCache; 255 | } 256 | 257 | - (AFHTTPSessionManager *)defaultManager { 258 | AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc] initWithSessionConfiguration:[self defaultConfigration]]; 259 | manager.responseSerializer = [AFHTTPResponseSerializer serializer]; 260 | return manager; 261 | } 262 | 263 | @end 264 | -------------------------------------------------------------------------------- /ZCNetworking/ZCNetworking/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // ZCNetworking 4 | // 5 | // Created by charles on 16/4/15. 6 | // Copyright © 2016年 charles. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /ZCNetworking/ZCNetworking/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // ZCNetworking 4 | // 5 | // Created by charles on 16/4/15. 6 | // Copyright © 2016年 charles. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "ZCApiLauncher.h" 11 | 12 | @interface ViewController () 13 | 14 | @end 15 | 16 | @implementation ViewController 17 | 18 | #pragma mark - life cycle 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | //在app delegate里面设置比较好,任意地点设置也没问题,不过需要在调用api之前设置 23 | [[ZCApiRunner sharedInstance] startWithDebugDomain:@"http://api.budejie.com/" releaseDomain:@"http://api.budejie.com/"]; 24 | 25 | // 可以要可以不要 26 | // [self globleSettings]; 27 | 28 | 29 | [self nomarlActionTest]; 30 | // [self uploadActionTest]; 31 | } 32 | 33 | #pragma mark - 使用说明 34 | 35 | /** 36 | * 一切全局的设置,可有可没有. 37 | 一般api会返回一个code表示api逻辑是否成功. 38 | 如果有设置了codekey,则需要设置成功code.当api返回时,会根据code key和success code的设置进行判定进入success还是failure回调 39 | 是否成功仅仅依赖success codes,不依赖warning codes. 40 | 对于一些全局的warning codes,可以设置handler.比如登录失效,可以设置一个handler进行登录. 41 | */ 42 | - (void)globleSettings { 43 | [[ZCApiRunner sharedInstance] codeKey:@"code"]; 44 | [[ZCApiRunner sharedInstance] successCodes:@[@"0"]]; 45 | [[ZCApiRunner sharedInstance] warningReturnCodes:@[@"-1"] withHandler:^(NSString *code) { 46 | if ([code isEqualToString:@"-1"]) { 47 | //做自己的操作,例如登录等 48 | } 49 | }]; 50 | } 51 | 52 | /** 53 | * api from 百思不得姐,随时失效.请用有效的api进行测试 54 | 这是普通的api请求,获取数据.ZCApiAction中有更多的属性可以设置. 55 | */ 56 | - (void)nomarlActionTest { 57 | ZCApiAction *action = [[ZCApiAction alloc] initWithURL:@"api/api_open.php"]; 58 | //参数 59 | action.params[@"a"] = @"user_login_report"; 60 | action.params[@"appname"] = @"baisishequ"; 61 | action.params[@"c"] = @"user"; 62 | action.params[@"client"] = @"iphone"; 63 | 64 | //可选属性 65 | action.showLog = YES; 66 | action.actionWillInvokeBlock = ^{ 67 | NSLog(@"will start"); 68 | }; 69 | 70 | action.actionDidInvokeBlock = ^(BOOL isSuccess) { 71 | if (isSuccess) { 72 | NSLog(@"success"); 73 | } 74 | else { 75 | NSLog(@"failure"); 76 | } 77 | }; 78 | 79 | [[ZCApiRunner sharedInstance] runAction:action success:^(id object) { 80 | 81 | } failure:^(NSError *error) { 82 | 83 | }]; 84 | } 85 | 86 | /** 87 | * 没有相关的api,只能做个使用示例 88 | */ 89 | - (void)uploadActionTest { 90 | ZCApiUploadAction *action = [[ZCApiUploadAction alloc] initWithURL:@"xxx"]; 91 | //参数,同普通action一样 92 | action.params[@""] = @""; 93 | 94 | //根据上传任务调整timeout 95 | action.timeout = 300; 96 | 97 | //上传必要参数,由server端提供 98 | action.data = [NSData data]; 99 | action.fileName = @"xxx"; 100 | action.uploadName = @"xxx"; 101 | action.mimeType = @"xxx"; 102 | 103 | /* 104 | 如果是多data上传(例如一个身份证上传api,需要上传身份证正反面) 105 | 可以使用数组形式的参数,不过单个data上传和多个data上传需要互斥 106 | 并且多个data上传,需要统一,也就是data/filename/uploadname/mimetype的数组数量一致 107 | 因为是通过index来进行匹配的. 108 | */ 109 | // action.dataArray = @[]; 110 | // action.uploadNameArray = @[]; 111 | // action.fileNameArray = @[]; 112 | // action.mimeTypeArray = @[]; 113 | 114 | [[ZCApiRunner sharedInstance] uploadAction:action progress:nil success:^(id object) { 115 | 116 | } failure:^(NSError *error) { 117 | 118 | }]; 119 | } 120 | 121 | @end 122 | -------------------------------------------------------------------------------- /ZCNetworking/ZCNetworking/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // ZCNetworking 4 | // 5 | // Created by charles on 16/4/15. 6 | // Copyright © 2016年 charles. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ZCNetworking/ZCNetworkingTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /ZCNetworking/ZCNetworkingTests/ZCNetworkingTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // ZCNetworkingTests.m 3 | // ZCNetworkingTests 4 | // 5 | // Created by charles on 16/4/15. 6 | // Copyright © 2016年 charles. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "ZCApiLauncher.h" 11 | 12 | @interface ZCNetworkingTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation ZCNetworkingTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | } 21 | 22 | - (void)tearDown { 23 | [super tearDown]; 24 | } 25 | 26 | - (void)testGetFromBaidu { 27 | 28 | } 29 | 30 | 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /ZCNetworking/ZCNetworkingUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /ZCNetworking/ZCNetworkingUITests/ZCNetworkingUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // ZCNetworkingUITests.m 3 | // ZCNetworkingUITests 4 | // 5 | // Created by charles on 16/4/15. 6 | // Copyright © 2016年 charles. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ZCNetworkingUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation ZCNetworkingUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | --------------------------------------------------------------------------------