Commit 0a37a6ad95be738a23d321e88b47230da4adb0ea

Authored by yinqiaojuan
1 parent bd62e535

0.0.2

Showing 63 changed files with 10752 additions and 269 deletions
CNLivePublishContent.podspec
1 1 Pod::Spec.new do |s|
2 2 s.name = 'CNLivePublishContent'
3   - s.version = '0.0.1'
  3 + s.version = '0.0.2'
4 4 s.summary = '测试组件化'
5 5  
6 6  
... ...
Example/CNLivePublishContent.xcodeproj/project.pbxproj
... ... @@ -208,6 +208,7 @@
208 208 6003F587195388D20070C39A /* Frameworks */,
209 209 6003F588195388D20070C39A /* Resources */,
210 210 E302593251286FBA8CFF57A6 /* [CP] Embed Pods Frameworks */,
  211 + 4E04560221B7E14700A2D934 /* ShellScript */,
211 212 );
212 213 buildRules = (
213 214 );
... ... @@ -226,6 +227,7 @@
226 227 6003F5AA195388D20070C39A /* Sources */,
227 228 6003F5AB195388D20070C39A /* Frameworks */,
228 229 6003F5AC195388D20070C39A /* Resources */,
  230 + ADC5C89582652F91856C3EAB /* [CP] Embed Pods Frameworks */,
229 231 );
230 232 buildRules = (
231 233 );
... ... @@ -319,6 +321,23 @@
319 321 shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
320 322 showEnvVarsInLog = 0;
321 323 };
  324 + 4E04560221B7E14700A2D934 /* ShellScript */ = {
  325 + isa = PBXShellScriptBuildPhase;
  326 + buildActionMask = 2147483647;
  327 + files = (
  328 + );
  329 + inputFileListPaths = (
  330 + );
  331 + inputPaths = (
  332 + );
  333 + outputFileListPaths = (
  334 + );
  335 + outputPaths = (
  336 + );
  337 + runOnlyForDeploymentPostprocessing = 0;
  338 + shellPath = /bin/sh;
  339 + shellScript = "if [ \"${ACTION}\" = \"build\" ]\nthen\nINSTALL_DIR=${SRCROOT}/Products/${PROJECT_NAME}.framework\n\nDEVICE_DIR=${SRCROOT}/\"build\"/Debug-iphoneos/${PROJECT_NAME}/${PROJECT_NAME}.framework\n\nSIMULATOR_DIR=${SRCROOT}/\"build\"/Debug-iphonesimulator/${PROJECT_NAME}/${PROJECT_NAME}.framework\n\nif [ -d \"${INSTALL_DIR}\" ]\nthen\nrm -rf \"${INSTALL_DIR}\"\nfi\n\nmkdir -p \"${INSTALL_DIR}\"\n\ncp -R \"${DEVICE_DIR}/\" \"${INSTALL_DIR}/\"\n\nlipo -create \"${DEVICE_DIR}/${PROJECT_NAME}\" \"${SIMULATOR_DIR}/${PROJECT_NAME}\" -output \"${INSTALL_DIR}/${PROJECT_NAME}\"\n\nopen \"${SRCROOT}/Products\"\nfi\n";
  340 + };
322 341 8D85A13192C701AB99C6DF5B /* [CP] Check Pods Manifest.lock */ = {
323 342 isa = PBXShellScriptBuildPhase;
324 343 buildActionMask = 2147483647;
... ... @@ -341,6 +360,28 @@
341 360 shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
342 361 showEnvVarsInLog = 0;
343 362 };
  363 + ADC5C89582652F91856C3EAB /* [CP] Embed Pods Frameworks */ = {
  364 + isa = PBXShellScriptBuildPhase;
  365 + buildActionMask = 2147483647;
  366 + files = (
  367 + );
  368 + inputFileListPaths = (
  369 + );
  370 + inputPaths = (
  371 + "${SRCROOT}/Pods/Target Support Files/Pods-CNLivePublishContent_Tests/Pods-CNLivePublishContent_Tests-frameworks.sh",
  372 + "${BUILT_PRODUCTS_DIR}/AFNetworking/AFNetworking.framework",
  373 + );
  374 + name = "[CP] Embed Pods Frameworks";
  375 + outputFileListPaths = (
  376 + );
  377 + outputPaths = (
  378 + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AFNetworking.framework",
  379 + );
  380 + runOnlyForDeploymentPostprocessing = 0;
  381 + shellPath = /bin/sh;
  382 + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-CNLivePublishContent_Tests/Pods-CNLivePublishContent_Tests-frameworks.sh\"\n";
  383 + showEnvVarsInLog = 0;
  384 + };
344 385 E302593251286FBA8CFF57A6 /* [CP] Embed Pods Frameworks */ = {
345 386 isa = PBXShellScriptBuildPhase;
346 387 buildActionMask = 2147483647;
... ... @@ -350,12 +391,14 @@
350 391 );
351 392 inputPaths = (
352 393 "${SRCROOT}/Pods/Target Support Files/Pods-CNLivePublishContent_Example/Pods-CNLivePublishContent_Example-frameworks.sh",
  394 + "${BUILT_PRODUCTS_DIR}/AFNetworking/AFNetworking.framework",
353 395 "${BUILT_PRODUCTS_DIR}/CNLivePublishContent/CNLivePublishContent.framework",
354 396 );
355 397 name = "[CP] Embed Pods Frameworks";
356 398 outputFileListPaths = (
357 399 );
358 400 outputPaths = (
  401 + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AFNetworking.framework",
359 402 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLivePublishContent.framework",
360 403 );
361 404 runOnlyForDeploymentPostprocessing = 0;
... ...
Example/Podfile
1 1 use_frameworks!
2 2  
3   -platform :ios, '8.0'
  3 +platform :ios, '9.0'
4 4  
5 5 target 'CNLivePublishContent_Example' do
6 6 pod 'CNLivePublishContent', :path => '../'
  7 + pod 'AFNetworking'
7 8  
8 9 target 'CNLivePublishContent_Tests' do
9 10 inherit! :search_paths
10   -
  11 + pod 'AFNetworking'
11 12  
12 13 end
13 14 end
... ...
Example/Podfile.lock
1 1 PODS:
2   - - CNLivePublishContent (0.1.0)
  2 + - AFNetworking (3.2.1):
  3 + - AFNetworking/NSURLSession (= 3.2.1)
  4 + - AFNetworking/Reachability (= 3.2.1)
  5 + - AFNetworking/Security (= 3.2.1)
  6 + - AFNetworking/Serialization (= 3.2.1)
  7 + - AFNetworking/UIKit (= 3.2.1)
  8 + - AFNetworking/NSURLSession (3.2.1):
  9 + - AFNetworking/Reachability
  10 + - AFNetworking/Security
  11 + - AFNetworking/Serialization
  12 + - AFNetworking/Reachability (3.2.1)
  13 + - AFNetworking/Security (3.2.1)
  14 + - AFNetworking/Serialization (3.2.1)
  15 + - AFNetworking/UIKit (3.2.1):
  16 + - AFNetworking/NSURLSession
  17 + - CNLivePublishContent (0.0.1):
  18 + - AFNetworking
3 19  
4 20 DEPENDENCIES:
  21 + - AFNetworking
5 22 - CNLivePublishContent (from `../`)
6 23  
  24 +SPEC REPOS:
  25 + https://github.com/cocoapods/specs.git:
  26 + - AFNetworking
  27 +
7 28 EXTERNAL SOURCES:
8 29 CNLivePublishContent:
9 30 :path: "../"
10 31  
11 32 SPEC CHECKSUMS:
12   - CNLivePublishContent: efc4d0c9e97d82c10cbb9a0f46c529746aba9a16
  33 + AFNetworking: b6f891fdfaed196b46c7a83cf209e09697b94057
  34 + CNLivePublishContent: 150e8b7a22533392991c94cb1f48c29ce636ffa2
13 35  
14   -PODFILE CHECKSUM: efac94bc6984e6197fee85d997a2f2e01b62a039
  36 +PODFILE CHECKSUM: 63184c0b0bc99c2f33e9180bc374c50d728e4a35
15 37  
16 38 COCOAPODS: 1.5.3
... ...
Example/Pods/AFNetworking/AFNetworking/AFCompatibilityMacros.h 0 → 100644
  1 +// AFCompatibilityMacros.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 +#ifndef AFCompatibilityMacros_h
  23 +#define AFCompatibilityMacros_h
  24 +
  25 +#ifdef API_UNAVAILABLE
  26 + #define AF_API_UNAVAILABLE(x) API_UNAVAILABLE(x)
  27 +#else
  28 + #define AF_API_UNAVAILABLE(x)
  29 +#endif // API_UNAVAILABLE
  30 +
  31 +#if __has_warning("-Wunguarded-availability-new")
  32 + #define AF_CAN_USE_AT_AVAILABLE 1
  33 +#else
  34 + #define AF_CAN_USE_AT_AVAILABLE 0
  35 +#endif
  36 +
  37 +#endif /* AFCompatibilityMacros_h */
... ...
Example/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.h 0 → 100644
  1 +// AFHTTPSessionManager.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 <Foundation/Foundation.h>
  23 +#if !TARGET_OS_WATCH
  24 +#import <SystemConfiguration/SystemConfiguration.h>
  25 +#endif
  26 +#import <TargetConditionals.h>
  27 +
  28 +#if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV
  29 +#import <MobileCoreServices/MobileCoreServices.h>
  30 +#else
  31 +#import <CoreServices/CoreServices.h>
  32 +#endif
  33 +
  34 +#import "AFURLSessionManager.h"
  35 +
  36 +/**
  37 + `AFHTTPSessionManager` is a subclass of `AFURLSessionManager` with convenience methods for making HTTP requests. When a `baseURL` is provided, requests made with the `GET` / `POST` / et al. convenience methods can be made with relative paths.
  38 +
  39 + ## Subclassing Notes
  40 +
  41 + Developers targeting iOS 7 or Mac OS X 10.9 or later that deal extensively with a web service are encouraged to subclass `AFHTTPSessionManager`, providing a class method that returns a shared singleton object on which authentication and other configuration can be shared across the application.
  42 +
  43 + For developers targeting iOS 6 or Mac OS X 10.8 or earlier, `AFHTTPRequestOperationManager` may be used to similar effect.
  44 +
  45 + ## Methods to Override
  46 +
  47 + To change the behavior of all data task operation construction, which is also used in the `GET` / `POST` / et al. convenience methods, override `dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:`.
  48 +
  49 + ## Serialization
  50 +
  51 + Requests created by an HTTP client will contain default headers and encode parameters according to the `requestSerializer` property, which is an object conforming to `<AFURLRequestSerialization>`.
  52 +
  53 + Responses received from the server are automatically validated and serialized by the `responseSerializers` property, which is an object conforming to `<AFURLResponseSerialization>`
  54 +
  55 + ## URL Construction Using Relative Paths
  56 +
  57 + For HTTP convenience methods, the request serializer constructs URLs from the path relative to the `-baseURL`, using `NSURL +URLWithString:relativeToURL:`, when provided. If `baseURL` is `nil`, `path` needs to resolve to a valid `NSURL` object using `NSURL +URLWithString:`.
  58 +
  59 + Below are a few examples of how `baseURL` and relative paths interact:
  60 +
  61 + NSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"];
  62 + [NSURL URLWithString:@"foo" relativeToURL:baseURL]; // http://example.com/v1/foo
  63 + [NSURL URLWithString:@"foo?bar=baz" relativeToURL:baseURL]; // http://example.com/v1/foo?bar=baz
  64 + [NSURL URLWithString:@"/foo" relativeToURL:baseURL]; // http://example.com/foo
  65 + [NSURL URLWithString:@"foo/" relativeToURL:baseURL]; // http://example.com/v1/foo
  66 + [NSURL URLWithString:@"/foo/" relativeToURL:baseURL]; // http://example.com/foo/
  67 + [NSURL URLWithString:@"http://example2.com/" relativeToURL:baseURL]; // http://example2.com/
  68 +
  69 + Also important to note is that a trailing slash will be added to any `baseURL` without one. This would otherwise cause unexpected behavior when constructing URLs using paths without a leading slash.
  70 +
  71 + @warning Managers for background sessions must be owned for the duration of their use. This can be accomplished by creating an application-wide or shared singleton instance.
  72 + */
  73 +
  74 +NS_ASSUME_NONNULL_BEGIN
  75 +
  76 +@interface AFHTTPSessionManager : AFURLSessionManager <NSSecureCoding, NSCopying>
  77 +
  78 +/**
  79 + The URL used to construct requests from relative paths in methods like `requestWithMethod:URLString:parameters:`, and the `GET` / `POST` / et al. convenience methods.
  80 + */
  81 +@property (readonly, nonatomic, strong, nullable) NSURL *baseURL;
  82 +
  83 +/**
  84 + Requests created with `requestWithMethod:URLString:parameters:` & `multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:` are constructed with a set of default headers using a parameter serialization specified by this property. By default, this is set to an instance of `AFHTTPRequestSerializer`, which serializes query string parameters for `GET`, `HEAD`, and `DELETE` requests, or otherwise URL-form-encodes HTTP message bodies.
  85 +
  86 + @warning `requestSerializer` must not be `nil`.
  87 + */
  88 +@property (nonatomic, strong) AFHTTPRequestSerializer <AFURLRequestSerialization> * requestSerializer;
  89 +
  90 +/**
  91 + Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an instance of `AFJSONResponseSerializer`.
  92 +
  93 + @warning `responseSerializer` must not be `nil`.
  94 + */
  95 +@property (nonatomic, strong) AFHTTPResponseSerializer <AFURLResponseSerialization> * responseSerializer;
  96 +
  97 +///-------------------------------
  98 +/// @name Managing Security Policy
  99 +///-------------------------------
  100 +
  101 +/**
  102 + The security policy used by created session to evaluate server trust for secure connections. `AFURLSessionManager` uses the `defaultPolicy` unless otherwise specified. A security policy configured with `AFSSLPinningModePublicKey` or `AFSSLPinningModeCertificate` can only be applied on a session manager initialized with a secure base URL (i.e. https). Applying a security policy with pinning enabled on an insecure session manager throws an `Invalid Security Policy` exception.
  103 + */
  104 +@property (nonatomic, strong) AFSecurityPolicy *securityPolicy;
  105 +
  106 +///---------------------
  107 +/// @name Initialization
  108 +///---------------------
  109 +
  110 +/**
  111 + Creates and returns an `AFHTTPSessionManager` object.
  112 + */
  113 ++ (instancetype)manager;
  114 +
  115 +/**
  116 + Initializes an `AFHTTPSessionManager` object with the specified base URL.
  117 +
  118 + @param url The base URL for the HTTP client.
  119 +
  120 + @return The newly-initialized HTTP client
  121 + */
  122 +- (instancetype)initWithBaseURL:(nullable NSURL *)url;
  123 +
  124 +/**
  125 + Initializes an `AFHTTPSessionManager` object with the specified base URL.
  126 +
  127 + This is the designated initializer.
  128 +
  129 + @param url The base URL for the HTTP client.
  130 + @param configuration The configuration used to create the managed session.
  131 +
  132 + @return The newly-initialized HTTP client
  133 + */
  134 +- (instancetype)initWithBaseURL:(nullable NSURL *)url
  135 + sessionConfiguration:(nullable NSURLSessionConfiguration *)configuration NS_DESIGNATED_INITIALIZER;
  136 +
  137 +///---------------------------
  138 +/// @name Making HTTP Requests
  139 +///---------------------------
  140 +
  141 +/**
  142 + Creates and runs an `NSURLSessionDataTask` with a `GET` request.
  143 +
  144 + @param URLString The URL string used to create the request URL.
  145 + @param parameters The parameters to be encoded according to the client request serializer.
  146 + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
  147 + @param failure A block object to be executed when the 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 two arguments: the data task and the error describing the network or parsing error that occurred.
  148 +
  149 + @see -dataTaskWithRequest:completionHandler:
  150 + */
  151 +- (nullable NSURLSessionDataTask *)GET:(NSString *)URLString
  152 + parameters:(nullable id)parameters
  153 + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
  154 + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE;
  155 +
  156 +
  157 +/**
  158 + Creates and runs an `NSURLSessionDataTask` with a `GET` request.
  159 +
  160 + @param URLString The URL string used to create the request URL.
  161 + @param parameters The parameters to be encoded according to the client request serializer.
  162 + @param downloadProgress A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue.
  163 + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
  164 + @param failure A block object to be executed when the 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 two arguments: the data task and the error describing the network or parsing error that occurred.
  165 +
  166 + @see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:
  167 + */
  168 +- (nullable NSURLSessionDataTask *)GET:(NSString *)URLString
  169 + parameters:(nullable id)parameters
  170 + progress:(nullable void (^)(NSProgress *downloadProgress))downloadProgress
  171 + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
  172 + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
  173 +
  174 +/**
  175 + Creates and runs an `NSURLSessionDataTask` with a `HEAD` request.
  176 +
  177 + @param URLString The URL string used to create the request URL.
  178 + @param parameters The parameters to be encoded according to the client request serializer.
  179 + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes a single arguments: the data task.
  180 + @param failure A block object to be executed when the 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 two arguments: the data task and the error describing the network or parsing error that occurred.
  181 +
  182 + @see -dataTaskWithRequest:completionHandler:
  183 + */
  184 +- (nullable NSURLSessionDataTask *)HEAD:(NSString *)URLString
  185 + parameters:(nullable id)parameters
  186 + success:(nullable void (^)(NSURLSessionDataTask *task))success
  187 + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
  188 +
  189 +/**
  190 + Creates and runs an `NSURLSessionDataTask` with a `POST` request.
  191 +
  192 + @param URLString The URL string used to create the request URL.
  193 + @param parameters The parameters to be encoded according to the client request serializer.
  194 + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
  195 + @param failure A block object to be executed when the 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 two arguments: the data task and the error describing the network or parsing error that occurred.
  196 +
  197 + @see -dataTaskWithRequest:completionHandler:
  198 + */
  199 +- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString
  200 + parameters:(nullable id)parameters
  201 + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
  202 + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE;
  203 +
  204 +/**
  205 + Creates and runs an `NSURLSessionDataTask` with a `POST` request.
  206 +
  207 + @param URLString The URL string used to create the request URL.
  208 + @param parameters The parameters to be encoded according to the client request serializer.
  209 + @param uploadProgress A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.
  210 + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
  211 + @param failure A block object to be executed when the 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 two arguments: the data task and the error describing the network or parsing error that occurred.
  212 +
  213 + @see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:
  214 + */
  215 +- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString
  216 + parameters:(nullable id)parameters
  217 + progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgress
  218 + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
  219 + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
  220 +
  221 +/**
  222 + Creates and runs an `NSURLSessionDataTask` with a multipart `POST` request.
  223 +
  224 + @param URLString The URL string used to create the request URL.
  225 + @param parameters The parameters to be encoded according to the client request serializer.
  226 + @param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol.
  227 + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
  228 + @param failure A block object to be executed when the 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 two arguments: the data task and the error describing the network or parsing error that occurred.
  229 +
  230 + @see -dataTaskWithRequest:completionHandler:
  231 + */
  232 +- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString
  233 + parameters:(nullable id)parameters
  234 + constructingBodyWithBlock:(nullable void (^)(id <AFMultipartFormData> formData))block
  235 + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
  236 + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE;
  237 +
  238 +/**
  239 + Creates and runs an `NSURLSessionDataTask` with a multipart `POST` request.
  240 +
  241 + @param URLString The URL string used to create the request URL.
  242 + @param parameters The parameters to be encoded according to the client request serializer.
  243 + @param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol.
  244 + @param uploadProgress A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.
  245 + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
  246 + @param failure A block object to be executed when the 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 two arguments: the data task and the error describing the network or parsing error that occurred.
  247 +
  248 + @see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:
  249 + */
  250 +- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString
  251 + parameters:(nullable id)parameters
  252 + constructingBodyWithBlock:(nullable void (^)(id <AFMultipartFormData> formData))block
  253 + progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgress
  254 + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
  255 + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
  256 +
  257 +/**
  258 + Creates and runs an `NSURLSessionDataTask` with a `PUT` request.
  259 +
  260 + @param URLString The URL string used to create the request URL.
  261 + @param parameters The parameters to be encoded according to the client request serializer.
  262 + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
  263 + @param failure A block object to be executed when the 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 two arguments: the data task and the error describing the network or parsing error that occurred.
  264 +
  265 + @see -dataTaskWithRequest:completionHandler:
  266 + */
  267 +- (nullable NSURLSessionDataTask *)PUT:(NSString *)URLString
  268 + parameters:(nullable id)parameters
  269 + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
  270 + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
  271 +
  272 +/**
  273 + Creates and runs an `NSURLSessionDataTask` with a `PATCH` request.
  274 +
  275 + @param URLString The URL string used to create the request URL.
  276 + @param parameters The parameters to be encoded according to the client request serializer.
  277 + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
  278 + @param failure A block object to be executed when the 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 two arguments: the data task and the error describing the network or parsing error that occurred.
  279 +
  280 + @see -dataTaskWithRequest:completionHandler:
  281 + */
  282 +- (nullable NSURLSessionDataTask *)PATCH:(NSString *)URLString
  283 + parameters:(nullable id)parameters
  284 + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
  285 + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
  286 +
  287 +/**
  288 + Creates and runs an `NSURLSessionDataTask` with a `DELETE` request.
  289 +
  290 + @param URLString The URL string used to create the request URL.
  291 + @param parameters The parameters to be encoded according to the client request serializer.
  292 + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
  293 + @param failure A block object to be executed when the 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 two arguments: the data task and the error describing the network or parsing error that occurred.
  294 +
  295 + @see -dataTaskWithRequest:completionHandler:
  296 + */
  297 +- (nullable NSURLSessionDataTask *)DELETE:(NSString *)URLString
  298 + parameters:(nullable id)parameters
  299 + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
  300 + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
  301 +
  302 +@end
  303 +
  304 +NS_ASSUME_NONNULL_END
... ...
Example/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.m 0 → 100644
  1 +// AFHTTPSessionManager.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 "AFHTTPSessionManager.h"
  23 +
  24 +#import "AFURLRequestSerialization.h"
  25 +#import "AFURLResponseSerialization.h"
  26 +
  27 +#import <Availability.h>
  28 +#import <TargetConditionals.h>
  29 +#import <Security/Security.h>
  30 +
  31 +#import <netinet/in.h>
  32 +#import <netinet6/in6.h>
  33 +#import <arpa/inet.h>
  34 +#import <ifaddrs.h>
  35 +#import <netdb.h>
  36 +
  37 +#if TARGET_OS_IOS || TARGET_OS_TV
  38 +#import <UIKit/UIKit.h>
  39 +#elif TARGET_OS_WATCH
  40 +#import <WatchKit/WatchKit.h>
  41 +#endif
  42 +
  43 +@interface AFHTTPSessionManager ()
  44 +@property (readwrite, nonatomic, strong) NSURL *baseURL;
  45 +@end
  46 +
  47 +@implementation AFHTTPSessionManager
  48 +@dynamic responseSerializer;
  49 +
  50 ++ (instancetype)manager {
  51 + return [[[self class] alloc] initWithBaseURL:nil];
  52 +}
  53 +
  54 +- (instancetype)init {
  55 + return [self initWithBaseURL:nil];
  56 +}
  57 +
  58 +- (instancetype)initWithBaseURL:(NSURL *)url {
  59 + return [self initWithBaseURL:url sessionConfiguration:nil];
  60 +}
  61 +
  62 +- (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration {
  63 + return [self initWithBaseURL:nil sessionConfiguration:configuration];
  64 +}
  65 +
  66 +- (instancetype)initWithBaseURL:(NSURL *)url
  67 + sessionConfiguration:(NSURLSessionConfiguration *)configuration
  68 +{
  69 + self = [super initWithSessionConfiguration:configuration];
  70 + if (!self) {
  71 + return nil;
  72 + }
  73 +
  74 + // Ensure terminal slash for baseURL path, so that NSURL +URLWithString:relativeToURL: works as expected
  75 + if ([[url path] length] > 0 && ![[url absoluteString] hasSuffix:@"/"]) {
  76 + url = [url URLByAppendingPathComponent:@""];
  77 + }
  78 +
  79 + self.baseURL = url;
  80 +
  81 + self.requestSerializer = [AFHTTPRequestSerializer serializer];
  82 + self.responseSerializer = [AFJSONResponseSerializer serializer];
  83 +
  84 + return self;
  85 +}
  86 +
  87 +#pragma mark -
  88 +
  89 +- (void)setRequestSerializer:(AFHTTPRequestSerializer <AFURLRequestSerialization> *)requestSerializer {
  90 + NSParameterAssert(requestSerializer);
  91 +
  92 + _requestSerializer = requestSerializer;
  93 +}
  94 +
  95 +- (void)setResponseSerializer:(AFHTTPResponseSerializer <AFURLResponseSerialization> *)responseSerializer {
  96 + NSParameterAssert(responseSerializer);
  97 +
  98 + [super setResponseSerializer:responseSerializer];
  99 +}
  100 +
  101 +@dynamic securityPolicy;
  102 +
  103 +- (void)setSecurityPolicy:(AFSecurityPolicy *)securityPolicy {
  104 + if (securityPolicy.SSLPinningMode != AFSSLPinningModeNone && ![self.baseURL.scheme isEqualToString:@"https"]) {
  105 + NSString *pinningMode = @"Unknown Pinning Mode";
  106 + switch (securityPolicy.SSLPinningMode) {
  107 + case AFSSLPinningModeNone: pinningMode = @"AFSSLPinningModeNone"; break;
  108 + case AFSSLPinningModeCertificate: pinningMode = @"AFSSLPinningModeCertificate"; break;
  109 + case AFSSLPinningModePublicKey: pinningMode = @"AFSSLPinningModePublicKey"; break;
  110 + }
  111 + NSString *reason = [NSString stringWithFormat:@"A security policy configured with `%@` can only be applied on a manager with a secure base URL (i.e. https)", pinningMode];
  112 + @throw [NSException exceptionWithName:@"Invalid Security Policy" reason:reason userInfo:nil];
  113 + }
  114 +
  115 + [super setSecurityPolicy:securityPolicy];
  116 +}
  117 +
  118 +#pragma mark -
  119 +
  120 +- (NSURLSessionDataTask *)GET:(NSString *)URLString
  121 + parameters:(id)parameters
  122 + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
  123 + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
  124 +{
  125 +
  126 + return [self GET:URLString parameters:parameters progress:nil success:success failure:failure];
  127 +}
  128 +
  129 +- (NSURLSessionDataTask *)GET:(NSString *)URLString
  130 + parameters:(id)parameters
  131 + progress:(void (^)(NSProgress * _Nonnull))downloadProgress
  132 + success:(void (^)(NSURLSessionDataTask * _Nonnull, id _Nullable))success
  133 + failure:(void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure
  134 +{
  135 +
  136 + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"GET"
  137 + URLString:URLString
  138 + parameters:parameters
  139 + uploadProgress:nil
  140 + downloadProgress:downloadProgress
  141 + success:success
  142 + failure:failure];
  143 +
  144 + [dataTask resume];
  145 +
  146 + return dataTask;
  147 +}
  148 +
  149 +- (NSURLSessionDataTask *)HEAD:(NSString *)URLString
  150 + parameters:(id)parameters
  151 + success:(void (^)(NSURLSessionDataTask *task))success
  152 + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
  153 +{
  154 + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"HEAD" URLString:URLString parameters:parameters uploadProgress:nil downloadProgress:nil success:^(NSURLSessionDataTask *task, __unused id responseObject) {
  155 + if (success) {
  156 + success(task);
  157 + }
  158 + } failure:failure];
  159 +
  160 + [dataTask resume];
  161 +
  162 + return dataTask;
  163 +}
  164 +
  165 +- (NSURLSessionDataTask *)POST:(NSString *)URLString
  166 + parameters:(id)parameters
  167 + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
  168 + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
  169 +{
  170 + return [self POST:URLString parameters:parameters progress:nil success:success failure:failure];
  171 +}
  172 +
  173 +- (NSURLSessionDataTask *)POST:(NSString *)URLString
  174 + parameters:(id)parameters
  175 + progress:(void (^)(NSProgress * _Nonnull))uploadProgress
  176 + success:(void (^)(NSURLSessionDataTask * _Nonnull, id _Nullable))success
  177 + failure:(void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure
  178 +{
  179 + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"POST" URLString:URLString parameters:parameters uploadProgress:uploadProgress downloadProgress:nil success:success failure:failure];
  180 +
  181 + [dataTask resume];
  182 +
  183 + return dataTask;
  184 +}
  185 +
  186 +- (NSURLSessionDataTask *)POST:(NSString *)URLString
  187 + parameters:(nullable id)parameters
  188 + constructingBodyWithBlock:(nullable void (^)(id<AFMultipartFormData> _Nonnull))block
  189 + success:(nullable void (^)(NSURLSessionDataTask * _Nonnull, id _Nullable))success
  190 + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure
  191 +{
  192 + return [self POST:URLString parameters:parameters constructingBodyWithBlock:block progress:nil success:success failure:failure];
  193 +}
  194 +
  195 +- (NSURLSessionDataTask *)POST:(NSString *)URLString
  196 + parameters:(id)parameters
  197 + constructingBodyWithBlock:(void (^)(id <AFMultipartFormData> formData))block
  198 + progress:(nullable void (^)(NSProgress * _Nonnull))uploadProgress
  199 + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
  200 + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
  201 +{
  202 + NSError *serializationError = nil;
  203 + NSMutableURLRequest *request = [self.requestSerializer multipartFormRequestWithMethod:@"POST" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters constructingBodyWithBlock:block error:&serializationError];
  204 + if (serializationError) {
  205 + if (failure) {
  206 + dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{
  207 + failure(nil, serializationError);
  208 + });
  209 + }
  210 +
  211 + return nil;
  212 + }
  213 +
  214 + __block NSURLSessionDataTask *task = [self uploadTaskWithStreamedRequest:request progress:uploadProgress completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) {
  215 + if (error) {
  216 + if (failure) {
  217 + failure(task, error);
  218 + }
  219 + } else {
  220 + if (success) {
  221 + success(task, responseObject);
  222 + }
  223 + }
  224 + }];
  225 +
  226 + [task resume];
  227 +
  228 + return task;
  229 +}
  230 +
  231 +- (NSURLSessionDataTask *)PUT:(NSString *)URLString
  232 + parameters:(id)parameters
  233 + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
  234 + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
  235 +{
  236 + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"PUT" URLString:URLString parameters:parameters uploadProgress:nil downloadProgress:nil success:success failure:failure];
  237 +
  238 + [dataTask resume];
  239 +
  240 + return dataTask;
  241 +}
  242 +
  243 +- (NSURLSessionDataTask *)PATCH:(NSString *)URLString
  244 + parameters:(id)parameters
  245 + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
  246 + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
  247 +{
  248 + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"PATCH" URLString:URLString parameters:parameters uploadProgress:nil downloadProgress:nil success:success failure:failure];
  249 +
  250 + [dataTask resume];
  251 +
  252 + return dataTask;
  253 +}
  254 +
  255 +- (NSURLSessionDataTask *)DELETE:(NSString *)URLString
  256 + parameters:(id)parameters
  257 + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
  258 + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
  259 +{
  260 + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"DELETE" URLString:URLString parameters:parameters uploadProgress:nil downloadProgress:nil success:success failure:failure];
  261 +
  262 + [dataTask resume];
  263 +
  264 + return dataTask;
  265 +}
  266 +
  267 +- (NSURLSessionDataTask *)dataTaskWithHTTPMethod:(NSString *)method
  268 + URLString:(NSString *)URLString
  269 + parameters:(id)parameters
  270 + uploadProgress:(nullable void (^)(NSProgress *uploadProgress)) uploadProgress
  271 + downloadProgress:(nullable void (^)(NSProgress *downloadProgress)) downloadProgress
  272 + success:(void (^)(NSURLSessionDataTask *, id))success
  273 + failure:(void (^)(NSURLSessionDataTask *, NSError *))failure
  274 +{
  275 + NSError *serializationError = nil;
  276 + NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:method URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:&serializationError];
  277 + if (serializationError) {
  278 + if (failure) {
  279 + dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{
  280 + failure(nil, serializationError);
  281 + });
  282 + }
  283 +
  284 + return nil;
  285 + }
  286 +
  287 + __block NSURLSessionDataTask *dataTask = nil;
  288 + dataTask = [self dataTaskWithRequest:request
  289 + uploadProgress:uploadProgress
  290 + downloadProgress:downloadProgress
  291 + completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) {
  292 + if (error) {
  293 + if (failure) {
  294 + failure(dataTask, error);
  295 + }
  296 + } else {
  297 + if (success) {
  298 + success(dataTask, responseObject);
  299 + }
  300 + }
  301 + }];
  302 +
  303 + return dataTask;
  304 +}
  305 +
  306 +#pragma mark - NSObject
  307 +
  308 +- (NSString *)description {
  309 + return [NSString stringWithFormat:@"<%@: %p, baseURL: %@, session: %@, operationQueue: %@>", NSStringFromClass([self class]), self, [self.baseURL absoluteString], self.session, self.operationQueue];
  310 +}
  311 +
  312 +#pragma mark - NSSecureCoding
  313 +
  314 ++ (BOOL)supportsSecureCoding {
  315 + return YES;
  316 +}
  317 +
  318 +- (instancetype)initWithCoder:(NSCoder *)decoder {
  319 + NSURL *baseURL = [decoder decodeObjectOfClass:[NSURL class] forKey:NSStringFromSelector(@selector(baseURL))];
  320 + NSURLSessionConfiguration *configuration = [decoder decodeObjectOfClass:[NSURLSessionConfiguration class] forKey:@"sessionConfiguration"];
  321 + if (!configuration) {
  322 + NSString *configurationIdentifier = [decoder decodeObjectOfClass:[NSString class] forKey:@"identifier"];
  323 + if (configurationIdentifier) {
  324 +#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1100)
  325 + configuration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:configurationIdentifier];
  326 +#else
  327 + configuration = [NSURLSessionConfiguration backgroundSessionConfiguration:configurationIdentifier];
  328 +#endif
  329 + }
  330 + }
  331 +
  332 + self = [self initWithBaseURL:baseURL sessionConfiguration:configuration];
  333 + if (!self) {
  334 + return nil;
  335 + }
  336 +
  337 + self.requestSerializer = [decoder decodeObjectOfClass:[AFHTTPRequestSerializer class] forKey:NSStringFromSelector(@selector(requestSerializer))];
  338 + self.responseSerializer = [decoder decodeObjectOfClass:[AFHTTPResponseSerializer class] forKey:NSStringFromSelector(@selector(responseSerializer))];
  339 + AFSecurityPolicy *decodedPolicy = [decoder decodeObjectOfClass:[AFSecurityPolicy class] forKey:NSStringFromSelector(@selector(securityPolicy))];
  340 + if (decodedPolicy) {
  341 + self.securityPolicy = decodedPolicy;
  342 + }
  343 +
  344 + return self;
  345 +}
  346 +
  347 +- (void)encodeWithCoder:(NSCoder *)coder {
  348 + [super encodeWithCoder:coder];
  349 +
  350 + [coder encodeObject:self.baseURL forKey:NSStringFromSelector(@selector(baseURL))];
  351 + if ([self.session.configuration conformsToProtocol:@protocol(NSCoding)]) {
  352 + [coder encodeObject:self.session.configuration forKey:@"sessionConfiguration"];
  353 + } else {
  354 + [coder encodeObject:self.session.configuration.identifier forKey:@"identifier"];
  355 + }
  356 + [coder encodeObject:self.requestSerializer forKey:NSStringFromSelector(@selector(requestSerializer))];
  357 + [coder encodeObject:self.responseSerializer forKey:NSStringFromSelector(@selector(responseSerializer))];
  358 + [coder encodeObject:self.securityPolicy forKey:NSStringFromSelector(@selector(securityPolicy))];
  359 +}
  360 +
  361 +#pragma mark - NSCopying
  362 +
  363 +- (instancetype)copyWithZone:(NSZone *)zone {
  364 + AFHTTPSessionManager *HTTPClient = [[[self class] allocWithZone:zone] initWithBaseURL:self.baseURL sessionConfiguration:self.session.configuration];
  365 +
  366 + HTTPClient.requestSerializer = [self.requestSerializer copyWithZone:zone];
  367 + HTTPClient.responseSerializer = [self.responseSerializer copyWithZone:zone];
  368 + HTTPClient.securityPolicy = [self.securityPolicy copyWithZone:zone];
  369 + return HTTPClient;
  370 +}
  371 +
  372 +@end
... ...
Example/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.h 0 → 100644
  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 <Foundation/Foundation.h>
  23 +
  24 +#if !TARGET_OS_WATCH
  25 +#import <SystemConfiguration/SystemConfiguration.h>
  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 + * Unavailable initializer
  112 + */
  113 ++ (instancetype)new NS_UNAVAILABLE;
  114 +
  115 +/**
  116 + * Unavailable initializer
  117 + */
  118 +- (instancetype)init NS_UNAVAILABLE;
  119 +
  120 +///--------------------------------------------------
  121 +/// @name Starting & Stopping Reachability Monitoring
  122 +///--------------------------------------------------
  123 +
  124 +/**
  125 + Starts monitoring for changes in network reachability status.
  126 + */
  127 +- (void)startMonitoring;
  128 +
  129 +/**
  130 + Stops monitoring for changes in network reachability status.
  131 + */
  132 +- (void)stopMonitoring;
  133 +
  134 +///-------------------------------------------------
  135 +/// @name Getting Localized Reachability Description
  136 +///-------------------------------------------------
  137 +
  138 +/**
  139 + Returns a localized string representation of the current network reachability status.
  140 + */
  141 +- (NSString *)localizedNetworkReachabilityStatusString;
  142 +
  143 +///---------------------------------------------------
  144 +/// @name Setting Network Reachability Change Callback
  145 +///---------------------------------------------------
  146 +
  147 +/**
  148 + Sets a callback to be executed when the network availability of the `baseURL` host changes.
  149 +
  150 + @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`.
  151 + */
  152 +- (void)setReachabilityStatusChangeBlock:(nullable void (^)(AFNetworkReachabilityStatus status))block;
  153 +
  154 +@end
  155 +
  156 +///----------------
  157 +/// @name Constants
  158 +///----------------
  159 +
  160 +/**
  161 + ## Network Reachability
  162 +
  163 + The following constants are provided by `AFNetworkReachabilityManager` as possible network reachability statuses.
  164 +
  165 + enum {
  166 + AFNetworkReachabilityStatusUnknown,
  167 + AFNetworkReachabilityStatusNotReachable,
  168 + AFNetworkReachabilityStatusReachableViaWWAN,
  169 + AFNetworkReachabilityStatusReachableViaWiFi,
  170 + }
  171 +
  172 + `AFNetworkReachabilityStatusUnknown`
  173 + The `baseURL` host reachability is not known.
  174 +
  175 + `AFNetworkReachabilityStatusNotReachable`
  176 + The `baseURL` host cannot be reached.
  177 +
  178 + `AFNetworkReachabilityStatusReachableViaWWAN`
  179 + The `baseURL` host can be reached via a cellular connection, such as EDGE or GPRS.
  180 +
  181 + `AFNetworkReachabilityStatusReachableViaWiFi`
  182 + The `baseURL` host can be reached via a Wi-Fi connection.
  183 +
  184 + ### Keys for Notification UserInfo Dictionary
  185 +
  186 + Strings that are used as keys in a `userInfo` dictionary in a network reachability status change notification.
  187 +
  188 + `AFNetworkingReachabilityNotificationStatusItem`
  189 + A key in the userInfo dictionary in a `AFNetworkingReachabilityDidChangeNotification` notification.
  190 + The corresponding value is an `NSNumber` object representing the `AFNetworkReachabilityStatus` value for the current reachability status.
  191 + */
  192 +
  193 +///--------------------
  194 +/// @name Notifications
  195 +///--------------------
  196 +
  197 +/**
  198 + Posted when network reachability changes.
  199 + 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.
  200 +
  201 + @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 <SystemConfiguration/SystemConfiguration.h>` to the header prefix of the project (`Prefix.pch`).
  202 + */
  203 +FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityDidChangeNotification;
  204 +FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityNotificationStatusItem;
  205 +
  206 +///--------------------
  207 +/// @name Functions
  208 +///--------------------
  209 +
  210 +/**
  211 + Returns a localized string representation of an `AFNetworkReachabilityStatus` value.
  212 + */
  213 +FOUNDATION_EXPORT NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status);
  214 +
  215 +NS_ASSUME_NONNULL_END
  216 +#endif
... ...
Example/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.m 0 → 100644
  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 <netinet/in.h>
  26 +#import <netinet6/in6.h>
  27 +#import <arpa/inet.h>
  28 +#import <ifaddrs.h>
  29 +#import <netdb.h>
  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
  174 +{
  175 + @throw [NSException exceptionWithName:NSGenericException
  176 + reason:@"`-init` unavailable. Use `-initWithReachability:` instead"
  177 + userInfo:nil];
  178 + return nil;
  179 +}
  180 +
  181 +- (void)dealloc {
  182 + [self stopMonitoring];
  183 +
  184 + if (_networkReachability != NULL) {
  185 + CFRelease(_networkReachability);
  186 + }
  187 +}
  188 +
  189 +#pragma mark -
  190 +
  191 +- (BOOL)isReachable {
  192 + return [self isReachableViaWWAN] || [self isReachableViaWiFi];
  193 +}
  194 +
  195 +- (BOOL)isReachableViaWWAN {
  196 + return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWWAN;
  197 +}
  198 +
  199 +- (BOOL)isReachableViaWiFi {
  200 + return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWiFi;
  201 +}
  202 +
  203 +#pragma mark -
  204 +
  205 +- (void)startMonitoring {
  206 + [self stopMonitoring];
  207 +
  208 + if (!self.networkReachability) {
  209 + return;
  210 + }
  211 +
  212 + __weak __typeof(self)weakSelf = self;
  213 + AFNetworkReachabilityStatusBlock callback = ^(AFNetworkReachabilityStatus status) {
  214 + __strong __typeof(weakSelf)strongSelf = weakSelf;
  215 +
  216 + strongSelf.networkReachabilityStatus = status;
  217 + if (strongSelf.networkReachabilityStatusBlock) {
  218 + strongSelf.networkReachabilityStatusBlock(status);
  219 + }
  220 +
  221 + };
  222 +
  223 + SCNetworkReachabilityContext context = {0, (__bridge void *)callback, AFNetworkReachabilityRetainCallback, AFNetworkReachabilityReleaseCallback, NULL};
  224 + SCNetworkReachabilitySetCallback(self.networkReachability, AFNetworkReachabilityCallback, &context);
  225 + SCNetworkReachabilityScheduleWithRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes);
  226 +
  227 + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0),^{
  228 + SCNetworkReachabilityFlags flags;
  229 + if (SCNetworkReachabilityGetFlags(self.networkReachability, &flags)) {
  230 + AFPostReachabilityStatusChange(flags, callback);
  231 + }
  232 + });
  233 +}
  234 +
  235 +- (void)stopMonitoring {
  236 + if (!self.networkReachability) {
  237 + return;
  238 + }
  239 +
  240 + SCNetworkReachabilityUnscheduleFromRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes);
  241 +}
  242 +
  243 +#pragma mark -
  244 +
  245 +- (NSString *)localizedNetworkReachabilityStatusString {
  246 + return AFStringFromNetworkReachabilityStatus(self.networkReachabilityStatus);
  247 +}
  248 +
  249 +#pragma mark -
  250 +
  251 +- (void)setReachabilityStatusChangeBlock:(void (^)(AFNetworkReachabilityStatus status))block {
  252 + self.networkReachabilityStatusBlock = block;
  253 +}
  254 +
  255 +#pragma mark - NSKeyValueObserving
  256 +
  257 ++ (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key {
  258 + if ([key isEqualToString:@"reachable"] || [key isEqualToString:@"reachableViaWWAN"] || [key isEqualToString:@"reachableViaWiFi"]) {
  259 + return [NSSet setWithObject:@"networkReachabilityStatus"];
  260 + }
  261 +
  262 + return [super keyPathsForValuesAffectingValueForKey:key];
  263 +}
  264 +
  265 +@end
  266 +#endif
... ...
Example/Pods/AFNetworking/AFNetworking/AFNetworking.h 0 → 100644
  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 <Foundation/Foundation.h>
  24 +#import <Availability.h>
  25 +#import <TargetConditionals.h>
  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_ */
... ...
Example/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.h 0 → 100644
  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 <Foundation/Foundation.h>
  23 +#import <Security/Security.h>
  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 <NSSecureCoding, NSCopying>
  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 <NSData *> *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 <NSData *> *)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 <NSData *> *)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 +*/
... ...
Example/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.m 0 → 100644
  1 +// AFSecurityPolicy.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 "AFSecurityPolicy.h"
  23 +
  24 +#import <AssertMacros.h>
  25 +
  26 +#if !TARGET_OS_IOS && !TARGET_OS_WATCH && !TARGET_OS_TV
  27 +static NSData * AFSecKeyGetData(SecKeyRef key) {
  28 + CFDataRef data = NULL;
  29 +
  30 + __Require_noErr_Quiet(SecItemExport(key, kSecFormatUnknown, kSecItemPemArmour, NULL, &data), _out);
  31 +
  32 + return (__bridge_transfer NSData *)data;
  33 +
  34 +_out:
  35 + if (data) {
  36 + CFRelease(data);
  37 + }
  38 +
  39 + return nil;
  40 +}
  41 +#endif
  42 +
  43 +static BOOL AFSecKeyIsEqualToKey(SecKeyRef key1, SecKeyRef key2) {
  44 +#if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV
  45 + return [(__bridge id)key1 isEqual:(__bridge id)key2];
  46 +#else
  47 + return [AFSecKeyGetData(key1) isEqual:AFSecKeyGetData(key2)];
  48 +#endif
  49 +}
  50 +
  51 +static id AFPublicKeyForCertificate(NSData *certificate) {
  52 + id allowedPublicKey = nil;
  53 + SecCertificateRef allowedCertificate;
  54 + SecPolicyRef policy = nil;
  55 + SecTrustRef allowedTrust = nil;
  56 + SecTrustResultType result;
  57 +
  58 + allowedCertificate = SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificate);
  59 + __Require_Quiet(allowedCertificate != NULL, _out);
  60 +
  61 + policy = SecPolicyCreateBasicX509();
  62 + __Require_noErr_Quiet(SecTrustCreateWithCertificates(allowedCertificate, policy, &allowedTrust), _out);
  63 + __Require_noErr_Quiet(SecTrustEvaluate(allowedTrust, &result), _out);
  64 +
  65 + allowedPublicKey = (__bridge_transfer id)SecTrustCopyPublicKey(allowedTrust);
  66 +
  67 +_out:
  68 + if (allowedTrust) {
  69 + CFRelease(allowedTrust);
  70 + }
  71 +
  72 + if (policy) {
  73 + CFRelease(policy);
  74 + }
  75 +
  76 + if (allowedCertificate) {
  77 + CFRelease(allowedCertificate);
  78 + }
  79 +
  80 + return allowedPublicKey;
  81 +}
  82 +
  83 +static BOOL AFServerTrustIsValid(SecTrustRef serverTrust) {
  84 + BOOL isValid = NO;
  85 + SecTrustResultType result;
  86 + __Require_noErr_Quiet(SecTrustEvaluate(serverTrust, &result), _out);
  87 +
  88 + isValid = (result == kSecTrustResultUnspecified || result == kSecTrustResultProceed);
  89 +
  90 +_out:
  91 + return isValid;
  92 +}
  93 +
  94 +static NSArray * AFCertificateTrustChainForServerTrust(SecTrustRef serverTrust) {
  95 + CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust);
  96 + NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount];
  97 +
  98 + for (CFIndex i = 0; i < certificateCount; i++) {
  99 + SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i);
  100 + [trustChain addObject:(__bridge_transfer NSData *)SecCertificateCopyData(certificate)];
  101 + }
  102 +
  103 + return [NSArray arrayWithArray:trustChain];
  104 +}
  105 +
  106 +static NSArray * AFPublicKeyTrustChainForServerTrust(SecTrustRef serverTrust) {
  107 + SecPolicyRef policy = SecPolicyCreateBasicX509();
  108 + CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust);
  109 + NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount];
  110 + for (CFIndex i = 0; i < certificateCount; i++) {
  111 + SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i);
  112 +
  113 + SecCertificateRef someCertificates[] = {certificate};
  114 + CFArrayRef certificates = CFArrayCreate(NULL, (const void **)someCertificates, 1, NULL);
  115 +
  116 + SecTrustRef trust;
  117 + __Require_noErr_Quiet(SecTrustCreateWithCertificates(certificates, policy, &trust), _out);
  118 +
  119 + SecTrustResultType result;
  120 + __Require_noErr_Quiet(SecTrustEvaluate(trust, &result), _out);
  121 +
  122 + [trustChain addObject:(__bridge_transfer id)SecTrustCopyPublicKey(trust)];
  123 +
  124 + _out:
  125 + if (trust) {
  126 + CFRelease(trust);
  127 + }
  128 +
  129 + if (certificates) {
  130 + CFRelease(certificates);
  131 + }
  132 +
  133 + continue;
  134 + }
  135 + CFRelease(policy);
  136 +
  137 + return [NSArray arrayWithArray:trustChain];
  138 +}
  139 +
  140 +#pragma mark -
  141 +
  142 +@interface AFSecurityPolicy()
  143 +@property (readwrite, nonatomic, assign) AFSSLPinningMode SSLPinningMode;
  144 +@property (readwrite, nonatomic, strong) NSSet *pinnedPublicKeys;
  145 +@end
  146 +
  147 +@implementation AFSecurityPolicy
  148 +
  149 ++ (NSSet *)certificatesInBundle:(NSBundle *)bundle {
  150 + NSArray *paths = [bundle pathsForResourcesOfType:@"cer" inDirectory:@"."];
  151 +
  152 + NSMutableSet *certificates = [NSMutableSet setWithCapacity:[paths count]];
  153 + for (NSString *path in paths) {
  154 + NSData *certificateData = [NSData dataWithContentsOfFile:path];
  155 + [certificates addObject:certificateData];
  156 + }
  157 +
  158 + return [NSSet setWithSet:certificates];
  159 +}
  160 +
  161 ++ (NSSet *)defaultPinnedCertificates {
  162 + static NSSet *_defaultPinnedCertificates = nil;
  163 + static dispatch_once_t onceToken;
  164 + dispatch_once(&onceToken, ^{
  165 + NSBundle *bundle = [NSBundle bundleForClass:[self class]];
  166 + _defaultPinnedCertificates = [self certificatesInBundle:bundle];
  167 + });
  168 +
  169 + return _defaultPinnedCertificates;
  170 +}
  171 +
  172 ++ (instancetype)defaultPolicy {
  173 + AFSecurityPolicy *securityPolicy = [[self alloc] init];
  174 + securityPolicy.SSLPinningMode = AFSSLPinningModeNone;
  175 +
  176 + return securityPolicy;
  177 +}
  178 +
  179 ++ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode {
  180 + return [self policyWithPinningMode:pinningMode withPinnedCertificates:[self defaultPinnedCertificates]];
  181 +}
  182 +
  183 ++ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode withPinnedCertificates:(NSSet *)pinnedCertificates {
  184 + AFSecurityPolicy *securityPolicy = [[self alloc] init];
  185 + securityPolicy.SSLPinningMode = pinningMode;
  186 +
  187 + [securityPolicy setPinnedCertificates:pinnedCertificates];
  188 +
  189 + return securityPolicy;
  190 +}
  191 +
  192 +- (instancetype)init {
  193 + self = [super init];
  194 + if (!self) {
  195 + return nil;
  196 + }
  197 +
  198 + self.validatesDomainName = YES;
  199 +
  200 + return self;
  201 +}
  202 +
  203 +- (void)setPinnedCertificates:(NSSet *)pinnedCertificates {
  204 + _pinnedCertificates = pinnedCertificates;
  205 +
  206 + if (self.pinnedCertificates) {
  207 + NSMutableSet *mutablePinnedPublicKeys = [NSMutableSet setWithCapacity:[self.pinnedCertificates count]];
  208 + for (NSData *certificate in self.pinnedCertificates) {
  209 + id publicKey = AFPublicKeyForCertificate(certificate);
  210 + if (!publicKey) {
  211 + continue;
  212 + }
  213 + [mutablePinnedPublicKeys addObject:publicKey];
  214 + }
  215 + self.pinnedPublicKeys = [NSSet setWithSet:mutablePinnedPublicKeys];
  216 + } else {
  217 + self.pinnedPublicKeys = nil;
  218 + }
  219 +}
  220 +
  221 +#pragma mark -
  222 +
  223 +- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust
  224 + forDomain:(NSString *)domain
  225 +{
  226 + if (domain && self.allowInvalidCertificates && self.validatesDomainName && (self.SSLPinningMode == AFSSLPinningModeNone || [self.pinnedCertificates count] == 0)) {
  227 + // https://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/NetworkingTopics/Articles/OverridingSSLChainValidationCorrectly.html
  228 + // According to the docs, you should only trust your provided certs for evaluation.
  229 + // Pinned certificates are added to the trust. Without pinned certificates,
  230 + // there is nothing to evaluate against.
  231 + //
  232 + // From Apple Docs:
  233 + // "Do not implicitly trust self-signed certificates as anchors (kSecTrustOptionImplicitAnchors).
  234 + // Instead, add your own (self-signed) CA certificate to the list of trusted anchors."
  235 + NSLog(@"In order to validate a domain name for self signed certificates, you MUST use pinning.");
  236 + return NO;
  237 + }
  238 +
  239 + NSMutableArray *policies = [NSMutableArray array];
  240 + if (self.validatesDomainName) {
  241 + [policies addObject:(__bridge_transfer id)SecPolicyCreateSSL(true, (__bridge CFStringRef)domain)];
  242 + } else {
  243 + [policies addObject:(__bridge_transfer id)SecPolicyCreateBasicX509()];
  244 + }
  245 +
  246 + SecTrustSetPolicies(serverTrust, (__bridge CFArrayRef)policies);
  247 +
  248 + if (self.SSLPinningMode == AFSSLPinningModeNone) {
  249 + return self.allowInvalidCertificates || AFServerTrustIsValid(serverTrust);
  250 + } else if (!AFServerTrustIsValid(serverTrust) && !self.allowInvalidCertificates) {
  251 + return NO;
  252 + }
  253 +
  254 + switch (self.SSLPinningMode) {
  255 + case AFSSLPinningModeNone:
  256 + default:
  257 + return NO;
  258 + case AFSSLPinningModeCertificate: {
  259 + NSMutableArray *pinnedCertificates = [NSMutableArray array];
  260 + for (NSData *certificateData in self.pinnedCertificates) {
  261 + [pinnedCertificates addObject:(__bridge_transfer id)SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificateData)];
  262 + }
  263 + SecTrustSetAnchorCertificates(serverTrust, (__bridge CFArrayRef)pinnedCertificates);
  264 +
  265 + if (!AFServerTrustIsValid(serverTrust)) {
  266 + return NO;
  267 + }
  268 +
  269 + // obtain the chain after being validated, which *should* contain the pinned certificate in the last position (if it's the Root CA)
  270 + NSArray *serverCertificates = AFCertificateTrustChainForServerTrust(serverTrust);
  271 +
  272 + for (NSData *trustChainCertificate in [serverCertificates reverseObjectEnumerator]) {
  273 + if ([self.pinnedCertificates containsObject:trustChainCertificate]) {
  274 + return YES;
  275 + }
  276 + }
  277 +
  278 + return NO;
  279 + }
  280 + case AFSSLPinningModePublicKey: {
  281 + NSUInteger trustedPublicKeyCount = 0;
  282 + NSArray *publicKeys = AFPublicKeyTrustChainForServerTrust(serverTrust);
  283 +
  284 + for (id trustChainPublicKey in publicKeys) {
  285 + for (id pinnedPublicKey in self.pinnedPublicKeys) {
  286 + if (AFSecKeyIsEqualToKey((__bridge SecKeyRef)trustChainPublicKey, (__bridge SecKeyRef)pinnedPublicKey)) {
  287 + trustedPublicKeyCount += 1;
  288 + }
  289 + }
  290 + }
  291 + return trustedPublicKeyCount > 0;
  292 + }
  293 + }
  294 +
  295 + return NO;
  296 +}
  297 +
  298 +#pragma mark - NSKeyValueObserving
  299 +
  300 ++ (NSSet *)keyPathsForValuesAffectingPinnedPublicKeys {
  301 + return [NSSet setWithObject:@"pinnedCertificates"];
  302 +}
  303 +
  304 +#pragma mark - NSSecureCoding
  305 +
  306 ++ (BOOL)supportsSecureCoding {
  307 + return YES;
  308 +}
  309 +
  310 +- (instancetype)initWithCoder:(NSCoder *)decoder {
  311 +
  312 + self = [self init];
  313 + if (!self) {
  314 + return nil;
  315 + }
  316 +
  317 + self.SSLPinningMode = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(SSLPinningMode))] unsignedIntegerValue];
  318 + self.allowInvalidCertificates = [decoder decodeBoolForKey:NSStringFromSelector(@selector(allowInvalidCertificates))];
  319 + self.validatesDomainName = [decoder decodeBoolForKey:NSStringFromSelector(@selector(validatesDomainName))];
  320 + self.pinnedCertificates = [decoder decodeObjectOfClass:[NSArray class] forKey:NSStringFromSelector(@selector(pinnedCertificates))];
  321 +
  322 + return self;
  323 +}
  324 +
  325 +- (void)encodeWithCoder:(NSCoder *)coder {
  326 + [coder encodeObject:[NSNumber numberWithUnsignedInteger:self.SSLPinningMode] forKey:NSStringFromSelector(@selector(SSLPinningMode))];
  327 + [coder encodeBool:self.allowInvalidCertificates forKey:NSStringFromSelector(@selector(allowInvalidCertificates))];
  328 + [coder encodeBool:self.validatesDomainName forKey:NSStringFromSelector(@selector(validatesDomainName))];
  329 + [coder encodeObject:self.pinnedCertificates forKey:NSStringFromSelector(@selector(pinnedCertificates))];
  330 +}
  331 +
  332 +#pragma mark - NSCopying
  333 +
  334 +- (instancetype)copyWithZone:(NSZone *)zone {
  335 + AFSecurityPolicy *securityPolicy = [[[self class] allocWithZone:zone] init];
  336 + securityPolicy.SSLPinningMode = self.SSLPinningMode;
  337 + securityPolicy.allowInvalidCertificates = self.allowInvalidCertificates;
  338 + securityPolicy.validatesDomainName = self.validatesDomainName;
  339 + securityPolicy.pinnedCertificates = [self.pinnedCertificates copyWithZone:zone];
  340 +
  341 + return securityPolicy;
  342 +}
  343 +
  344 +@end
... ...
Example/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.h 0 → 100644
  1 +// AFURLRequestSerialization.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 <Foundation/Foundation.h>
  23 +#import <TargetConditionals.h>
  24 +
  25 +#if TARGET_OS_IOS || TARGET_OS_TV
  26 +#import <UIKit/UIKit.h>
  27 +#elif TARGET_OS_WATCH
  28 +#import <WatchKit/WatchKit.h>
  29 +#endif
  30 +
  31 +NS_ASSUME_NONNULL_BEGIN
  32 +
  33 +/**
  34 + Returns a percent-escaped string following RFC 3986 for a query string key or value.
  35 + RFC 3986 states that the following characters are "reserved" characters.
  36 + - General Delimiters: ":", "#", "[", "]", "@", "?", "/"
  37 + - Sub-Delimiters: "!", "$", "&", "'", "(", ")", "*", "+", ",", ";", "="
  38 +
  39 + In RFC 3986 - Section 3.4, it states that the "?" and "/" characters should not be escaped to allow
  40 + query strings to include a URL. Therefore, all "reserved" characters with the exception of "?" and "/"
  41 + should be percent-escaped in the query string.
  42 +
  43 + @param string The string to be percent-escaped.
  44 +
  45 + @return The percent-escaped string.
  46 + */
  47 +FOUNDATION_EXPORT NSString * AFPercentEscapedStringFromString(NSString *string);
  48 +
  49 +/**
  50 + A helper method to generate encoded url query parameters for appending to the end of a URL.
  51 +
  52 + @param parameters A dictionary of key/values to be encoded.
  53 +
  54 + @return A url encoded query string
  55 + */
  56 +FOUNDATION_EXPORT NSString * AFQueryStringFromParameters(NSDictionary *parameters);
  57 +
  58 +/**
  59 + The `AFURLRequestSerialization` protocol is adopted by an object that encodes parameters for a specified HTTP requests. Request serializers may encode parameters as query strings, HTTP bodies, setting the appropriate HTTP header fields as necessary.
  60 +
  61 + For example, a JSON request serializer may set the HTTP body of the request to a JSON representation, and set the `Content-Type` HTTP header field value to `application/json`.
  62 + */
  63 +@protocol AFURLRequestSerialization <NSObject, NSSecureCoding, NSCopying>
  64 +
  65 +/**
  66 + Returns a request with the specified parameters encoded into a copy of the original request.
  67 +
  68 + @param request The original request.
  69 + @param parameters The parameters to be encoded.
  70 + @param error The error that occurred while attempting to encode the request parameters.
  71 +
  72 + @return A serialized request.
  73 + */
  74 +- (nullable NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request
  75 + withParameters:(nullable id)parameters
  76 + error:(NSError * _Nullable __autoreleasing *)error NS_SWIFT_NOTHROW;
  77 +
  78 +@end
  79 +
  80 +#pragma mark -
  81 +
  82 +/**
  83 +
  84 + */
  85 +typedef NS_ENUM(NSUInteger, AFHTTPRequestQueryStringSerializationStyle) {
  86 + AFHTTPRequestQueryStringDefaultStyle = 0,
  87 +};
  88 +
  89 +@protocol AFMultipartFormData;
  90 +
  91 +/**
  92 + `AFHTTPRequestSerializer` conforms to the `AFURLRequestSerialization` & `AFURLResponseSerialization` protocols, offering a concrete base implementation of query string / URL form-encoded parameter serialization and default request headers, as well as response status code and content type validation.
  93 +
  94 + Any request or response serializer dealing with HTTP is encouraged to subclass `AFHTTPRequestSerializer` in order to ensure consistent default behavior.
  95 + */
  96 +@interface AFHTTPRequestSerializer : NSObject <AFURLRequestSerialization>
  97 +
  98 +/**
  99 + The string encoding used to serialize parameters. `NSUTF8StringEncoding` by default.
  100 + */
  101 +@property (nonatomic, assign) NSStringEncoding stringEncoding;
  102 +
  103 +/**
  104 + Whether created requests can use the device’s cellular radio (if present). `YES` by default.
  105 +
  106 + @see NSMutableURLRequest -setAllowsCellularAccess:
  107 + */
  108 +@property (nonatomic, assign) BOOL allowsCellularAccess;
  109 +
  110 +/**
  111 + The cache policy of created requests. `NSURLRequestUseProtocolCachePolicy` by default.
  112 +
  113 + @see NSMutableURLRequest -setCachePolicy:
  114 + */
  115 +@property (nonatomic, assign) NSURLRequestCachePolicy cachePolicy;
  116 +
  117 +/**
  118 + Whether created requests should use the default cookie handling. `YES` by default.
  119 +
  120 + @see NSMutableURLRequest -setHTTPShouldHandleCookies:
  121 + */
  122 +@property (nonatomic, assign) BOOL HTTPShouldHandleCookies;
  123 +
  124 +/**
  125 + Whether created requests can continue transmitting data before receiving a response from an earlier transmission. `NO` by default
  126 +
  127 + @see NSMutableURLRequest -setHTTPShouldUsePipelining:
  128 + */
  129 +@property (nonatomic, assign) BOOL HTTPShouldUsePipelining;
  130 +
  131 +/**
  132 + The network service type for created requests. `NSURLNetworkServiceTypeDefault` by default.
  133 +
  134 + @see NSMutableURLRequest -setNetworkServiceType:
  135 + */
  136 +@property (nonatomic, assign) NSURLRequestNetworkServiceType networkServiceType;
  137 +
  138 +/**
  139 + The timeout interval, in seconds, for created requests. The default timeout interval is 60 seconds.
  140 +
  141 + @see NSMutableURLRequest -setTimeoutInterval:
  142 + */
  143 +@property (nonatomic, assign) NSTimeInterval timeoutInterval;
  144 +
  145 +///---------------------------------------
  146 +/// @name Configuring HTTP Request Headers
  147 +///---------------------------------------
  148 +
  149 +/**
  150 + Default HTTP header field values to be applied to serialized requests. By default, these include the following:
  151 +
  152 + - `Accept-Language` with the contents of `NSLocale +preferredLanguages`
  153 + - `User-Agent` with the contents of various bundle identifiers and OS designations
  154 +
  155 + @discussion To add or remove default request headers, use `setValue:forHTTPHeaderField:`.
  156 + */
  157 +@property (readonly, nonatomic, strong) NSDictionary <NSString *, NSString *> *HTTPRequestHeaders;
  158 +
  159 +/**
  160 + Creates and returns a serializer with default configuration.
  161 + */
  162 ++ (instancetype)serializer;
  163 +
  164 +/**
  165 + Sets the value for the HTTP headers set in request objects made by the HTTP client. If `nil`, removes the existing value for that header.
  166 +
  167 + @param field The HTTP header to set a default value for
  168 + @param value The value set as default for the specified header, or `nil`
  169 + */
  170 +- (void)setValue:(nullable NSString *)value
  171 +forHTTPHeaderField:(NSString *)field;
  172 +
  173 +/**
  174 + Returns the value for the HTTP headers set in the request serializer.
  175 +
  176 + @param field The HTTP header to retrieve the default value for
  177 +
  178 + @return The value set as default for the specified header, or `nil`
  179 + */
  180 +- (nullable NSString *)valueForHTTPHeaderField:(NSString *)field;
  181 +
  182 +/**
  183 + Sets the "Authorization" HTTP header set in request objects made by the HTTP client to a basic authentication value with Base64-encoded username and password. This overwrites any existing value for this header.
  184 +
  185 + @param username The HTTP basic auth username
  186 + @param password The HTTP basic auth password
  187 + */
  188 +- (void)setAuthorizationHeaderFieldWithUsername:(NSString *)username
  189 + password:(NSString *)password;
  190 +
  191 +/**
  192 + Clears any existing value for the "Authorization" HTTP header.
  193 + */
  194 +- (void)clearAuthorizationHeader;
  195 +
  196 +///-------------------------------------------------------
  197 +/// @name Configuring Query String Parameter Serialization
  198 +///-------------------------------------------------------
  199 +
  200 +/**
  201 + HTTP methods for which serialized requests will encode parameters as a query string. `GET`, `HEAD`, and `DELETE` by default.
  202 + */
  203 +@property (nonatomic, strong) NSSet <NSString *> *HTTPMethodsEncodingParametersInURI;
  204 +
  205 +/**
  206 + Set the method of query string serialization according to one of the pre-defined styles.
  207 +
  208 + @param style The serialization style.
  209 +
  210 + @see AFHTTPRequestQueryStringSerializationStyle
  211 + */
  212 +- (void)setQueryStringSerializationWithStyle:(AFHTTPRequestQueryStringSerializationStyle)style;
  213 +
  214 +/**
  215 + Set the a custom method of query string serialization according to the specified block.
  216 +
  217 + @param block A block that defines a process of encoding parameters into a query string. This block returns the query string and takes three arguments: the request, the parameters to encode, and the error that occurred when attempting to encode parameters for the given request.
  218 + */
  219 +- (void)setQueryStringSerializationWithBlock:(nullable NSString * (^)(NSURLRequest *request, id parameters, NSError * __autoreleasing *error))block;
  220 +
  221 +///-------------------------------
  222 +/// @name Creating Request Objects
  223 +///-------------------------------
  224 +
  225 +/**
  226 + Creates an `NSMutableURLRequest` object with the specified HTTP method and URL string.
  227 +
  228 + If the HTTP method is `GET`, `HEAD`, or `DELETE`, the parameters will be used to construct a url-encoded query string that is appended to the request's URL. Otherwise, the parameters will be encoded according to the value of the `parameterEncoding` property, and set as the request body.
  229 +
  230 + @param method The HTTP method for the request, such as `GET`, `POST`, `PUT`, or `DELETE`. This parameter must not be `nil`.
  231 + @param URLString The URL string used to create the request URL.
  232 + @param parameters The parameters to be either set as a query string for `GET` requests, or the request HTTP body.
  233 + @param error The error that occurred while constructing the request.
  234 +
  235 + @return An `NSMutableURLRequest` object.
  236 + */
  237 +- (NSMutableURLRequest *)requestWithMethod:(NSString *)method
  238 + URLString:(NSString *)URLString
  239 + parameters:(nullable id)parameters
  240 + error:(NSError * _Nullable __autoreleasing *)error;
  241 +
  242 +/**
  243 + Creates an `NSMutableURLRequest` object with the specified HTTP method and URLString, and constructs a `multipart/form-data` HTTP body, using the specified parameters and multipart form data block. See http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.2
  244 +
  245 + Multipart form requests are automatically streamed, reading files directly from disk along with in-memory data in a single HTTP body. The resulting `NSMutableURLRequest` object has an `HTTPBodyStream` property, so refrain from setting `HTTPBodyStream` or `HTTPBody` on this request object, as it will clear out the multipart form body stream.
  246 +
  247 + @param method The HTTP method for the request. This parameter must not be `GET` or `HEAD`, or `nil`.
  248 + @param URLString The URL string used to create the request URL.
  249 + @param parameters The parameters to be encoded and set in the request HTTP body.
  250 + @param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol.
  251 + @param error The error that occurred while constructing the request.
  252 +
  253 + @return An `NSMutableURLRequest` object
  254 + */
  255 +- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method
  256 + URLString:(NSString *)URLString
  257 + parameters:(nullable NSDictionary <NSString *, id> *)parameters
  258 + constructingBodyWithBlock:(nullable void (^)(id <AFMultipartFormData> formData))block
  259 + error:(NSError * _Nullable __autoreleasing *)error;
  260 +
  261 +/**
  262 + Creates an `NSMutableURLRequest` by removing the `HTTPBodyStream` from a request, and asynchronously writing its contents into the specified file, invoking the completion handler when finished.
  263 +
  264 + @param request The multipart form request. The `HTTPBodyStream` property of `request` must not be `nil`.
  265 + @param fileURL The file URL to write multipart form contents to.
  266 + @param handler A handler block to execute.
  267 +
  268 + @discussion There is a bug in `NSURLSessionTask` that causes requests to not send a `Content-Length` header when streaming contents from an HTTP body, which is notably problematic when interacting with the Amazon S3 webservice. As a workaround, this method takes a request constructed with `multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:error:`, or any other request with an `HTTPBodyStream`, writes the contents to the specified file and returns a copy of the original request with the `HTTPBodyStream` property set to `nil`. From here, the file can either be passed to `AFURLSessionManager -uploadTaskWithRequest:fromFile:progress:completionHandler:`, or have its contents read into an `NSData` that's assigned to the `HTTPBody` property of the request.
  269 +
  270 + @see https://github.com/AFNetworking/AFNetworking/issues/1398
  271 + */
  272 +- (NSMutableURLRequest *)requestWithMultipartFormRequest:(NSURLRequest *)request
  273 + writingStreamContentsToFile:(NSURL *)fileURL
  274 + completionHandler:(nullable void (^)(NSError * _Nullable error))handler;
  275 +
  276 +@end
  277 +
  278 +#pragma mark -
  279 +
  280 +/**
  281 + The `AFMultipartFormData` protocol defines the methods supported by the parameter in the block argument of `AFHTTPRequestSerializer -multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:`.
  282 + */
  283 +@protocol AFMultipartFormData
  284 +
  285 +/**
  286 + Appends the HTTP header `Content-Disposition: file; filename=#{generated filename}; name=#{name}"` and `Content-Type: #{generated mimeType}`, followed by the encoded file data and the multipart form boundary.
  287 +
  288 + The filename and MIME type for this data in the form will be automatically generated, using the last path component of the `fileURL` and system associated MIME type for the `fileURL` extension, respectively.
  289 +
  290 + @param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`.
  291 + @param name The name to be associated with the specified data. This parameter must not be `nil`.
  292 + @param error If an error occurs, upon return contains an `NSError` object that describes the problem.
  293 +
  294 + @return `YES` if the file data was successfully appended, otherwise `NO`.
  295 + */
  296 +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL
  297 + name:(NSString *)name
  298 + error:(NSError * _Nullable __autoreleasing *)error;
  299 +
  300 +/**
  301 + Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary.
  302 +
  303 + @param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`.
  304 + @param name The name to be associated with the specified data. This parameter must not be `nil`.
  305 + @param fileName The file name to be used in the `Content-Disposition` header. This parameter must not be `nil`.
  306 + @param mimeType The declared MIME type of the file data. This parameter must not be `nil`.
  307 + @param error If an error occurs, upon return contains an `NSError` object that describes the problem.
  308 +
  309 + @return `YES` if the file data was successfully appended otherwise `NO`.
  310 + */
  311 +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL
  312 + name:(NSString *)name
  313 + fileName:(NSString *)fileName
  314 + mimeType:(NSString *)mimeType
  315 + error:(NSError * _Nullable __autoreleasing *)error;
  316 +
  317 +/**
  318 + Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the data from the input stream and the multipart form boundary.
  319 +
  320 + @param inputStream The input stream to be appended to the form data
  321 + @param name The name to be associated with the specified input stream. This parameter must not be `nil`.
  322 + @param fileName The filename to be associated with the specified input stream. This parameter must not be `nil`.
  323 + @param length The length of the specified input stream in bytes.
  324 + @param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`.
  325 + */
  326 +- (void)appendPartWithInputStream:(nullable NSInputStream *)inputStream
  327 + name:(NSString *)name
  328 + fileName:(NSString *)fileName
  329 + length:(int64_t)length
  330 + mimeType:(NSString *)mimeType;
  331 +
  332 +/**
  333 + Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary.
  334 +
  335 + @param data The data to be encoded and appended to the form data.
  336 + @param name The name to be associated with the specified data. This parameter must not be `nil`.
  337 + @param fileName The filename to be associated with the specified data. This parameter must not be `nil`.
  338 + @param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`.
  339 + */
  340 +- (void)appendPartWithFileData:(NSData *)data
  341 + name:(NSString *)name
  342 + fileName:(NSString *)fileName
  343 + mimeType:(NSString *)mimeType;
  344 +
  345 +/**
  346 + Appends the HTTP headers `Content-Disposition: form-data; name=#{name}"`, followed by the encoded data and the multipart form boundary.
  347 +
  348 + @param data The data to be encoded and appended to the form data.
  349 + @param name The name to be associated with the specified data. This parameter must not be `nil`.
  350 + */
  351 +
  352 +- (void)appendPartWithFormData:(NSData *)data
  353 + name:(NSString *)name;
  354 +
  355 +
  356 +/**
  357 + Appends HTTP headers, followed by the encoded data and the multipart form boundary.
  358 +
  359 + @param headers The HTTP headers to be appended to the form data.
  360 + @param body The data to be encoded and appended to the form data. This parameter must not be `nil`.
  361 + */
  362 +- (void)appendPartWithHeaders:(nullable NSDictionary <NSString *, NSString *> *)headers
  363 + body:(NSData *)body;
  364 +
  365 +/**
  366 + Throttles request bandwidth by limiting the packet size and adding a delay for each chunk read from the upload stream.
  367 +
  368 + When uploading over a 3G or EDGE connection, requests may fail with "request body stream exhausted". Setting a maximum packet size and delay according to the recommended values (`kAFUploadStream3GSuggestedPacketSize` and `kAFUploadStream3GSuggestedDelay`) lowers the risk of the input stream exceeding its allocated bandwidth. Unfortunately, there is no definite way to distinguish between a 3G, EDGE, or LTE connection over `NSURLConnection`. As such, it is not recommended that you throttle bandwidth based solely on network reachability. Instead, you should consider checking for the "request body stream exhausted" in a failure block, and then retrying the request with throttled bandwidth.
  369 +
  370 + @param numberOfBytes Maximum packet size, in number of bytes. The default packet size for an input stream is 16kb.
  371 + @param delay Duration of delay each time a packet is read. By default, no delay is set.
  372 + */
  373 +- (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes
  374 + delay:(NSTimeInterval)delay;
  375 +
  376 +@end
  377 +
  378 +#pragma mark -
  379 +
  380 +/**
  381 + `AFJSONRequestSerializer` is a subclass of `AFHTTPRequestSerializer` that encodes parameters as JSON using `NSJSONSerialization`, setting the `Content-Type` of the encoded request to `application/json`.
  382 + */
  383 +@interface AFJSONRequestSerializer : AFHTTPRequestSerializer
  384 +
  385 +/**
  386 + Options for writing the request JSON data from Foundation objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONWritingOptions". `0` by default.
  387 + */
  388 +@property (nonatomic, assign) NSJSONWritingOptions writingOptions;
  389 +
  390 +/**
  391 + Creates and returns a JSON serializer with specified reading and writing options.
  392 +
  393 + @param writingOptions The specified JSON writing options.
  394 + */
  395 ++ (instancetype)serializerWithWritingOptions:(NSJSONWritingOptions)writingOptions;
  396 +
  397 +@end
  398 +
  399 +#pragma mark -
  400 +
  401 +/**
  402 + `AFPropertyListRequestSerializer` is a subclass of `AFHTTPRequestSerializer` that encodes parameters as JSON using `NSPropertyListSerializer`, setting the `Content-Type` of the encoded request to `application/x-plist`.
  403 + */
  404 +@interface AFPropertyListRequestSerializer : AFHTTPRequestSerializer
  405 +
  406 +/**
  407 + The property list format. Possible values are described in "NSPropertyListFormat".
  408 + */
  409 +@property (nonatomic, assign) NSPropertyListFormat format;
  410 +
  411 +/**
  412 + @warning The `writeOptions` property is currently unused.
  413 + */
  414 +@property (nonatomic, assign) NSPropertyListWriteOptions writeOptions;
  415 +
  416 +/**
  417 + Creates and returns a property list serializer with a specified format, read options, and write options.
  418 +
  419 + @param format The property list format.
  420 + @param writeOptions The property list write options.
  421 +
  422 + @warning The `writeOptions` property is currently unused.
  423 + */
  424 ++ (instancetype)serializerWithFormat:(NSPropertyListFormat)format
  425 + writeOptions:(NSPropertyListWriteOptions)writeOptions;
  426 +
  427 +@end
  428 +
  429 +#pragma mark -
  430 +
  431 +///----------------
  432 +/// @name Constants
  433 +///----------------
  434 +
  435 +/**
  436 + ## Error Domains
  437 +
  438 + The following error domain is predefined.
  439 +
  440 + - `NSString * const AFURLRequestSerializationErrorDomain`
  441 +
  442 + ### Constants
  443 +
  444 + `AFURLRequestSerializationErrorDomain`
  445 + AFURLRequestSerializer errors. Error codes for `AFURLRequestSerializationErrorDomain` correspond to codes in `NSURLErrorDomain`.
  446 + */
  447 +FOUNDATION_EXPORT NSString * const AFURLRequestSerializationErrorDomain;
  448 +
  449 +/**
  450 + ## User info dictionary keys
  451 +
  452 + These keys may exist in the user info dictionary, in addition to those defined for NSError.
  453 +
  454 + - `NSString * const AFNetworkingOperationFailingURLRequestErrorKey`
  455 +
  456 + ### Constants
  457 +
  458 + `AFNetworkingOperationFailingURLRequestErrorKey`
  459 + The corresponding value is an `NSURLRequest` containing the request of the operation associated with an error. This key is only present in the `AFURLRequestSerializationErrorDomain`.
  460 + */
  461 +FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLRequestErrorKey;
  462 +
  463 +/**
  464 + ## Throttling Bandwidth for HTTP Request Input Streams
  465 +
  466 + @see -throttleBandwidthWithPacketSize:delay:
  467 +
  468 + ### Constants
  469 +
  470 + `kAFUploadStream3GSuggestedPacketSize`
  471 + Maximum packet size, in number of bytes. Equal to 16kb.
  472 +
  473 + `kAFUploadStream3GSuggestedDelay`
  474 + Duration of delay each time a packet is read. Equal to 0.2 seconds.
  475 + */
  476 +FOUNDATION_EXPORT NSUInteger const kAFUploadStream3GSuggestedPacketSize;
  477 +FOUNDATION_EXPORT NSTimeInterval const kAFUploadStream3GSuggestedDelay;
  478 +
  479 +NS_ASSUME_NONNULL_END
... ...
Example/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.m 0 → 100644
  1 +// AFURLRequestSerialization.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 "AFURLRequestSerialization.h"
  23 +
  24 +#if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV
  25 +#import <MobileCoreServices/MobileCoreServices.h>
  26 +#else
  27 +#import <CoreServices/CoreServices.h>
  28 +#endif
  29 +
  30 +NSString * const AFURLRequestSerializationErrorDomain = @"com.alamofire.error.serialization.request";
  31 +NSString * const AFNetworkingOperationFailingURLRequestErrorKey = @"com.alamofire.serialization.request.error.response";
  32 +
  33 +typedef NSString * (^AFQueryStringSerializationBlock)(NSURLRequest *request, id parameters, NSError *__autoreleasing *error);
  34 +
  35 +/**
  36 + Returns a percent-escaped string following RFC 3986 for a query string key or value.
  37 + RFC 3986 states that the following characters are "reserved" characters.
  38 + - General Delimiters: ":", "#", "[", "]", "@", "?", "/"
  39 + - Sub-Delimiters: "!", "$", "&", "'", "(", ")", "*", "+", ",", ";", "="
  40 +
  41 + In RFC 3986 - Section 3.4, it states that the "?" and "/" characters should not be escaped to allow
  42 + query strings to include a URL. Therefore, all "reserved" characters with the exception of "?" and "/"
  43 + should be percent-escaped in the query string.
  44 + - parameter string: The string to be percent-escaped.
  45 + - returns: The percent-escaped string.
  46 + */
  47 +NSString * AFPercentEscapedStringFromString(NSString *string) {
  48 + static NSString * const kAFCharactersGeneralDelimitersToEncode = @":#[]@"; // does not include "?" or "/" due to RFC 3986 - Section 3.4
  49 + static NSString * const kAFCharactersSubDelimitersToEncode = @"!$&'()*+,;=";
  50 +
  51 + NSMutableCharacterSet * allowedCharacterSet = [[NSCharacterSet URLQueryAllowedCharacterSet] mutableCopy];
  52 + [allowedCharacterSet removeCharactersInString:[kAFCharactersGeneralDelimitersToEncode stringByAppendingString:kAFCharactersSubDelimitersToEncode]];
  53 +
  54 + // FIXME: https://github.com/AFNetworking/AFNetworking/pull/3028
  55 + // return [string stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacterSet];
  56 +
  57 + static NSUInteger const batchSize = 50;
  58 +
  59 + NSUInteger index = 0;
  60 + NSMutableString *escaped = @"".mutableCopy;
  61 +
  62 + while (index < string.length) {
  63 + NSUInteger length = MIN(string.length - index, batchSize);
  64 + NSRange range = NSMakeRange(index, length);
  65 +
  66 + // To avoid breaking up character sequences such as 👴🏻👮🏽
  67 + range = [string rangeOfComposedCharacterSequencesForRange:range];
  68 +
  69 + NSString *substring = [string substringWithRange:range];
  70 + NSString *encoded = [substring stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacterSet];
  71 + [escaped appendString:encoded];
  72 +
  73 + index += range.length;
  74 + }
  75 +
  76 + return escaped;
  77 +}
  78 +
  79 +#pragma mark -
  80 +
  81 +@interface AFQueryStringPair : NSObject
  82 +@property (readwrite, nonatomic, strong) id field;
  83 +@property (readwrite, nonatomic, strong) id value;
  84 +
  85 +- (instancetype)initWithField:(id)field value:(id)value;
  86 +
  87 +- (NSString *)URLEncodedStringValue;
  88 +@end
  89 +
  90 +@implementation AFQueryStringPair
  91 +
  92 +- (instancetype)initWithField:(id)field value:(id)value {
  93 + self = [super init];
  94 + if (!self) {
  95 + return nil;
  96 + }
  97 +
  98 + self.field = field;
  99 + self.value = value;
  100 +
  101 + return self;
  102 +}
  103 +
  104 +- (NSString *)URLEncodedStringValue {
  105 + if (!self.value || [self.value isEqual:[NSNull null]]) {
  106 + return AFPercentEscapedStringFromString([self.field description]);
  107 + } else {
  108 + return [NSString stringWithFormat:@"%@=%@", AFPercentEscapedStringFromString([self.field description]), AFPercentEscapedStringFromString([self.value description])];
  109 + }
  110 +}
  111 +
  112 +@end
  113 +
  114 +#pragma mark -
  115 +
  116 +FOUNDATION_EXPORT NSArray * AFQueryStringPairsFromDictionary(NSDictionary *dictionary);
  117 +FOUNDATION_EXPORT NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value);
  118 +
  119 +NSString * AFQueryStringFromParameters(NSDictionary *parameters) {
  120 + NSMutableArray *mutablePairs = [NSMutableArray array];
  121 + for (AFQueryStringPair *pair in AFQueryStringPairsFromDictionary(parameters)) {
  122 + [mutablePairs addObject:[pair URLEncodedStringValue]];
  123 + }
  124 +
  125 + return [mutablePairs componentsJoinedByString:@"&"];
  126 +}
  127 +
  128 +NSArray * AFQueryStringPairsFromDictionary(NSDictionary *dictionary) {
  129 + return AFQueryStringPairsFromKeyAndValue(nil, dictionary);
  130 +}
  131 +
  132 +NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value) {
  133 + NSMutableArray *mutableQueryStringComponents = [NSMutableArray array];
  134 +
  135 + NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"description" ascending:YES selector:@selector(compare:)];
  136 +
  137 + if ([value isKindOfClass:[NSDictionary class]]) {
  138 + NSDictionary *dictionary = value;
  139 + // Sort dictionary keys to ensure consistent ordering in query string, which is important when deserializing potentially ambiguous sequences, such as an array of dictionaries
  140 + for (id nestedKey in [dictionary.allKeys sortedArrayUsingDescriptors:@[ sortDescriptor ]]) {
  141 + id nestedValue = dictionary[nestedKey];
  142 + if (nestedValue) {
  143 + [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue((key ? [NSString stringWithFormat:@"%@[%@]", key, nestedKey] : nestedKey), nestedValue)];
  144 + }
  145 + }
  146 + } else if ([value isKindOfClass:[NSArray class]]) {
  147 + NSArray *array = value;
  148 + for (id nestedValue in array) {
  149 + [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue([NSString stringWithFormat:@"%@[]", key], nestedValue)];
  150 + }
  151 + } else if ([value isKindOfClass:[NSSet class]]) {
  152 + NSSet *set = value;
  153 + for (id obj in [set sortedArrayUsingDescriptors:@[ sortDescriptor ]]) {
  154 + [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue(key, obj)];
  155 + }
  156 + } else {
  157 + [mutableQueryStringComponents addObject:[[AFQueryStringPair alloc] initWithField:key value:value]];
  158 + }
  159 +
  160 + return mutableQueryStringComponents;
  161 +}
  162 +
  163 +#pragma mark -
  164 +
  165 +@interface AFStreamingMultipartFormData : NSObject <AFMultipartFormData>
  166 +- (instancetype)initWithURLRequest:(NSMutableURLRequest *)urlRequest
  167 + stringEncoding:(NSStringEncoding)encoding;
  168 +
  169 +- (NSMutableURLRequest *)requestByFinalizingMultipartFormData;
  170 +@end
  171 +
  172 +#pragma mark -
  173 +
  174 +static NSArray * AFHTTPRequestSerializerObservedKeyPaths() {
  175 + static NSArray *_AFHTTPRequestSerializerObservedKeyPaths = nil;
  176 + static dispatch_once_t onceToken;
  177 + dispatch_once(&onceToken, ^{
  178 + _AFHTTPRequestSerializerObservedKeyPaths = @[NSStringFromSelector(@selector(allowsCellularAccess)), NSStringFromSelector(@selector(cachePolicy)), NSStringFromSelector(@selector(HTTPShouldHandleCookies)), NSStringFromSelector(@selector(HTTPShouldUsePipelining)), NSStringFromSelector(@selector(networkServiceType)), NSStringFromSelector(@selector(timeoutInterval))];
  179 + });
  180 +
  181 + return _AFHTTPRequestSerializerObservedKeyPaths;
  182 +}
  183 +
  184 +static void *AFHTTPRequestSerializerObserverContext = &AFHTTPRequestSerializerObserverContext;
  185 +
  186 +@interface AFHTTPRequestSerializer ()
  187 +@property (readwrite, nonatomic, strong) NSMutableSet *mutableObservedChangedKeyPaths;
  188 +@property (readwrite, nonatomic, strong) NSMutableDictionary *mutableHTTPRequestHeaders;
  189 +@property (readwrite, nonatomic, strong) dispatch_queue_t requestHeaderModificationQueue;
  190 +@property (readwrite, nonatomic, assign) AFHTTPRequestQueryStringSerializationStyle queryStringSerializationStyle;
  191 +@property (readwrite, nonatomic, copy) AFQueryStringSerializationBlock queryStringSerialization;
  192 +@end
  193 +
  194 +@implementation AFHTTPRequestSerializer
  195 +
  196 ++ (instancetype)serializer {
  197 + return [[self alloc] init];
  198 +}
  199 +
  200 +- (instancetype)init {
  201 + self = [super init];
  202 + if (!self) {
  203 + return nil;
  204 + }
  205 +
  206 + self.stringEncoding = NSUTF8StringEncoding;
  207 +
  208 + self.mutableHTTPRequestHeaders = [NSMutableDictionary dictionary];
  209 + self.requestHeaderModificationQueue = dispatch_queue_create("requestHeaderModificationQueue", DISPATCH_QUEUE_CONCURRENT);
  210 +
  211 + // Accept-Language HTTP Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4
  212 + NSMutableArray *acceptLanguagesComponents = [NSMutableArray array];
  213 + [[NSLocale preferredLanguages] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
  214 + float q = 1.0f - (idx * 0.1f);
  215 + [acceptLanguagesComponents addObject:[NSString stringWithFormat:@"%@;q=%0.1g", obj, q]];
  216 + *stop = q <= 0.5f;
  217 + }];
  218 + [self setValue:[acceptLanguagesComponents componentsJoinedByString:@", "] forHTTPHeaderField:@"Accept-Language"];
  219 +
  220 + NSString *userAgent = nil;
  221 +#if TARGET_OS_IOS
  222 + // User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43
  223 + userAgent = [NSString stringWithFormat:@"%@/%@ (%@; iOS %@; Scale/%0.2f)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion], [[UIScreen mainScreen] scale]];
  224 +#elif TARGET_OS_WATCH
  225 + // User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43
  226 + userAgent = [NSString stringWithFormat:@"%@/%@ (%@; watchOS %@; Scale/%0.2f)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[WKInterfaceDevice currentDevice] model], [[WKInterfaceDevice currentDevice] systemVersion], [[WKInterfaceDevice currentDevice] screenScale]];
  227 +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
  228 + userAgent = [NSString stringWithFormat:@"%@/%@ (Mac OS X %@)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[NSProcessInfo processInfo] operatingSystemVersionString]];
  229 +#endif
  230 + if (userAgent) {
  231 + if (![userAgent canBeConvertedToEncoding:NSASCIIStringEncoding]) {
  232 + NSMutableString *mutableUserAgent = [userAgent mutableCopy];
  233 + if (CFStringTransform((__bridge CFMutableStringRef)(mutableUserAgent), NULL, (__bridge CFStringRef)@"Any-Latin; Latin-ASCII; [:^ASCII:] Remove", false)) {
  234 + userAgent = mutableUserAgent;
  235 + }
  236 + }
  237 + [self setValue:userAgent forHTTPHeaderField:@"User-Agent"];
  238 + }
  239 +
  240 + // HTTP Method Definitions; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html
  241 + self.HTTPMethodsEncodingParametersInURI = [NSSet setWithObjects:@"GET", @"HEAD", @"DELETE", nil];
  242 +
  243 + self.mutableObservedChangedKeyPaths = [NSMutableSet set];
  244 + for (NSString *keyPath in AFHTTPRequestSerializerObservedKeyPaths()) {
  245 + if ([self respondsToSelector:NSSelectorFromString(keyPath)]) {
  246 + [self addObserver:self forKeyPath:keyPath options:NSKeyValueObservingOptionNew context:AFHTTPRequestSerializerObserverContext];
  247 + }
  248 + }
  249 +
  250 + return self;
  251 +}
  252 +
  253 +- (void)dealloc {
  254 + for (NSString *keyPath in AFHTTPRequestSerializerObservedKeyPaths()) {
  255 + if ([self respondsToSelector:NSSelectorFromString(keyPath)]) {
  256 + [self removeObserver:self forKeyPath:keyPath context:AFHTTPRequestSerializerObserverContext];
  257 + }
  258 + }
  259 +}
  260 +
  261 +#pragma mark -
  262 +
  263 +// Workarounds for crashing behavior using Key-Value Observing with XCTest
  264 +// See https://github.com/AFNetworking/AFNetworking/issues/2523
  265 +
  266 +- (void)setAllowsCellularAccess:(BOOL)allowsCellularAccess {
  267 + [self willChangeValueForKey:NSStringFromSelector(@selector(allowsCellularAccess))];
  268 + _allowsCellularAccess = allowsCellularAccess;
  269 + [self didChangeValueForKey:NSStringFromSelector(@selector(allowsCellularAccess))];
  270 +}
  271 +
  272 +- (void)setCachePolicy:(NSURLRequestCachePolicy)cachePolicy {
  273 + [self willChangeValueForKey:NSStringFromSelector(@selector(cachePolicy))];
  274 + _cachePolicy = cachePolicy;
  275 + [self didChangeValueForKey:NSStringFromSelector(@selector(cachePolicy))];
  276 +}
  277 +
  278 +- (void)setHTTPShouldHandleCookies:(BOOL)HTTPShouldHandleCookies {
  279 + [self willChangeValueForKey:NSStringFromSelector(@selector(HTTPShouldHandleCookies))];
  280 + _HTTPShouldHandleCookies = HTTPShouldHandleCookies;
  281 + [self didChangeValueForKey:NSStringFromSelector(@selector(HTTPShouldHandleCookies))];
  282 +}
  283 +
  284 +- (void)setHTTPShouldUsePipelining:(BOOL)HTTPShouldUsePipelining {
  285 + [self willChangeValueForKey:NSStringFromSelector(@selector(HTTPShouldUsePipelining))];
  286 + _HTTPShouldUsePipelining = HTTPShouldUsePipelining;
  287 + [self didChangeValueForKey:NSStringFromSelector(@selector(HTTPShouldUsePipelining))];
  288 +}
  289 +
  290 +- (void)setNetworkServiceType:(NSURLRequestNetworkServiceType)networkServiceType {
  291 + [self willChangeValueForKey:NSStringFromSelector(@selector(networkServiceType))];
  292 + _networkServiceType = networkServiceType;
  293 + [self didChangeValueForKey:NSStringFromSelector(@selector(networkServiceType))];
  294 +}
  295 +
  296 +- (void)setTimeoutInterval:(NSTimeInterval)timeoutInterval {
  297 + [self willChangeValueForKey:NSStringFromSelector(@selector(timeoutInterval))];
  298 + _timeoutInterval = timeoutInterval;
  299 + [self didChangeValueForKey:NSStringFromSelector(@selector(timeoutInterval))];
  300 +}
  301 +
  302 +#pragma mark -
  303 +
  304 +- (NSDictionary *)HTTPRequestHeaders {
  305 + NSDictionary __block *value;
  306 + dispatch_sync(self.requestHeaderModificationQueue, ^{
  307 + value = [NSDictionary dictionaryWithDictionary:self.mutableHTTPRequestHeaders];
  308 + });
  309 + return value;
  310 +}
  311 +
  312 +- (void)setValue:(NSString *)value
  313 +forHTTPHeaderField:(NSString *)field
  314 +{
  315 + dispatch_barrier_async(self.requestHeaderModificationQueue, ^{
  316 + [self.mutableHTTPRequestHeaders setValue:value forKey:field];
  317 + });
  318 +}
  319 +
  320 +- (NSString *)valueForHTTPHeaderField:(NSString *)field {
  321 + NSString __block *value;
  322 + dispatch_sync(self.requestHeaderModificationQueue, ^{
  323 + value = [self.mutableHTTPRequestHeaders valueForKey:field];
  324 + });
  325 + return value;
  326 +}
  327 +
  328 +- (void)setAuthorizationHeaderFieldWithUsername:(NSString *)username
  329 + password:(NSString *)password
  330 +{
  331 + NSData *basicAuthCredentials = [[NSString stringWithFormat:@"%@:%@", username, password] dataUsingEncoding:NSUTF8StringEncoding];
  332 + NSString *base64AuthCredentials = [basicAuthCredentials base64EncodedStringWithOptions:(NSDataBase64EncodingOptions)0];
  333 + [self setValue:[NSString stringWithFormat:@"Basic %@", base64AuthCredentials] forHTTPHeaderField:@"Authorization"];
  334 +}
  335 +
  336 +- (void)clearAuthorizationHeader {
  337 + dispatch_barrier_async(self.requestHeaderModificationQueue, ^{
  338 + [self.mutableHTTPRequestHeaders removeObjectForKey:@"Authorization"];
  339 + });
  340 +}
  341 +
  342 +#pragma mark -
  343 +
  344 +- (void)setQueryStringSerializationWithStyle:(AFHTTPRequestQueryStringSerializationStyle)style {
  345 + self.queryStringSerializationStyle = style;
  346 + self.queryStringSerialization = nil;
  347 +}
  348 +
  349 +- (void)setQueryStringSerializationWithBlock:(NSString *(^)(NSURLRequest *, id, NSError *__autoreleasing *))block {
  350 + self.queryStringSerialization = block;
  351 +}
  352 +
  353 +#pragma mark -
  354 +
  355 +- (NSMutableURLRequest *)requestWithMethod:(NSString *)method
  356 + URLString:(NSString *)URLString
  357 + parameters:(id)parameters
  358 + error:(NSError *__autoreleasing *)error
  359 +{
  360 + NSParameterAssert(method);
  361 + NSParameterAssert(URLString);
  362 +
  363 + NSURL *url = [NSURL URLWithString:URLString];
  364 +
  365 + NSParameterAssert(url);
  366 +
  367 + NSMutableURLRequest *mutableRequest = [[NSMutableURLRequest alloc] initWithURL:url];
  368 + mutableRequest.HTTPMethod = method;
  369 +
  370 + for (NSString *keyPath in AFHTTPRequestSerializerObservedKeyPaths()) {
  371 + if ([self.mutableObservedChangedKeyPaths containsObject:keyPath]) {
  372 + [mutableRequest setValue:[self valueForKeyPath:keyPath] forKey:keyPath];
  373 + }
  374 + }
  375 +
  376 + mutableRequest = [[self requestBySerializingRequest:mutableRequest withParameters:parameters error:error] mutableCopy];
  377 +
  378 + return mutableRequest;
  379 +}
  380 +
  381 +- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method
  382 + URLString:(NSString *)URLString
  383 + parameters:(NSDictionary *)parameters
  384 + constructingBodyWithBlock:(void (^)(id <AFMultipartFormData> formData))block
  385 + error:(NSError *__autoreleasing *)error
  386 +{
  387 + NSParameterAssert(method);
  388 + NSParameterAssert(![method isEqualToString:@"GET"] && ![method isEqualToString:@"HEAD"]);
  389 +
  390 + NSMutableURLRequest *mutableRequest = [self requestWithMethod:method URLString:URLString parameters:nil error:error];
  391 +
  392 + __block AFStreamingMultipartFormData *formData = [[AFStreamingMultipartFormData alloc] initWithURLRequest:mutableRequest stringEncoding:NSUTF8StringEncoding];
  393 +
  394 + if (parameters) {
  395 + for (AFQueryStringPair *pair in AFQueryStringPairsFromDictionary(parameters)) {
  396 + NSData *data = nil;
  397 + if ([pair.value isKindOfClass:[NSData class]]) {
  398 + data = pair.value;
  399 + } else if ([pair.value isEqual:[NSNull null]]) {
  400 + data = [NSData data];
  401 + } else {
  402 + data = [[pair.value description] dataUsingEncoding:self.stringEncoding];
  403 + }
  404 +
  405 + if (data) {
  406 + [formData appendPartWithFormData:data name:[pair.field description]];
  407 + }
  408 + }
  409 + }
  410 +
  411 + if (block) {
  412 + block(formData);
  413 + }
  414 +
  415 + return [formData requestByFinalizingMultipartFormData];
  416 +}
  417 +
  418 +- (NSMutableURLRequest *)requestWithMultipartFormRequest:(NSURLRequest *)request
  419 + writingStreamContentsToFile:(NSURL *)fileURL
  420 + completionHandler:(void (^)(NSError *error))handler
  421 +{
  422 + NSParameterAssert(request.HTTPBodyStream);
  423 + NSParameterAssert([fileURL isFileURL]);
  424 +
  425 + NSInputStream *inputStream = request.HTTPBodyStream;
  426 + NSOutputStream *outputStream = [[NSOutputStream alloc] initWithURL:fileURL append:NO];
  427 + __block NSError *error = nil;
  428 +
  429 + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  430 + [inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
  431 + [outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
  432 +
  433 + [inputStream open];
  434 + [outputStream open];
  435 +
  436 + while ([inputStream hasBytesAvailable] && [outputStream hasSpaceAvailable]) {
  437 + uint8_t buffer[1024];
  438 +
  439 + NSInteger bytesRead = [inputStream read:buffer maxLength:1024];
  440 + if (inputStream.streamError || bytesRead < 0) {
  441 + error = inputStream.streamError;
  442 + break;
  443 + }
  444 +
  445 + NSInteger bytesWritten = [outputStream write:buffer maxLength:(NSUInteger)bytesRead];
  446 + if (outputStream.streamError || bytesWritten < 0) {
  447 + error = outputStream.streamError;
  448 + break;
  449 + }
  450 +
  451 + if (bytesRead == 0 && bytesWritten == 0) {
  452 + break;
  453 + }
  454 + }
  455 +
  456 + [outputStream close];
  457 + [inputStream close];
  458 +
  459 + if (handler) {
  460 + dispatch_async(dispatch_get_main_queue(), ^{
  461 + handler(error);
  462 + });
  463 + }
  464 + });
  465 +
  466 + NSMutableURLRequest *mutableRequest = [request mutableCopy];
  467 + mutableRequest.HTTPBodyStream = nil;
  468 +
  469 + return mutableRequest;
  470 +}
  471 +
  472 +#pragma mark - AFURLRequestSerialization
  473 +
  474 +- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request
  475 + withParameters:(id)parameters
  476 + error:(NSError *__autoreleasing *)error
  477 +{
  478 + NSParameterAssert(request);
  479 +
  480 + NSMutableURLRequest *mutableRequest = [request mutableCopy];
  481 +
  482 + [self.HTTPRequestHeaders enumerateKeysAndObjectsUsingBlock:^(id field, id value, BOOL * __unused stop) {
  483 + if (![request valueForHTTPHeaderField:field]) {
  484 + [mutableRequest setValue:value forHTTPHeaderField:field];
  485 + }
  486 + }];
  487 +
  488 + NSString *query = nil;
  489 + if (parameters) {
  490 + if (self.queryStringSerialization) {
  491 + NSError *serializationError;
  492 + query = self.queryStringSerialization(request, parameters, &serializationError);
  493 +
  494 + if (serializationError) {
  495 + if (error) {
  496 + *error = serializationError;
  497 + }
  498 +
  499 + return nil;
  500 + }
  501 + } else {
  502 + switch (self.queryStringSerializationStyle) {
  503 + case AFHTTPRequestQueryStringDefaultStyle:
  504 + query = AFQueryStringFromParameters(parameters);
  505 + break;
  506 + }
  507 + }
  508 + }
  509 +
  510 + if ([self.HTTPMethodsEncodingParametersInURI containsObject:[[request HTTPMethod] uppercaseString]]) {
  511 + if (query && query.length > 0) {
  512 + mutableRequest.URL = [NSURL URLWithString:[[mutableRequest.URL absoluteString] stringByAppendingFormat:mutableRequest.URL.query ? @"&%@" : @"?%@", query]];
  513 + }
  514 + } else {
  515 + // #2864: an empty string is a valid x-www-form-urlencoded payload
  516 + if (!query) {
  517 + query = @"";
  518 + }
  519 + if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) {
  520 + [mutableRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
  521 + }
  522 + [mutableRequest setHTTPBody:[query dataUsingEncoding:self.stringEncoding]];
  523 + }
  524 +
  525 + return mutableRequest;
  526 +}
  527 +
  528 +#pragma mark - NSKeyValueObserving
  529 +
  530 ++ (BOOL)automaticallyNotifiesObserversForKey:(NSString *)key {
  531 + if ([AFHTTPRequestSerializerObservedKeyPaths() containsObject:key]) {
  532 + return NO;
  533 + }
  534 +
  535 + return [super automaticallyNotifiesObserversForKey:key];
  536 +}
  537 +
  538 +- (void)observeValueForKeyPath:(NSString *)keyPath
  539 + ofObject:(__unused id)object
  540 + change:(NSDictionary *)change
  541 + context:(void *)context
  542 +{
  543 + if (context == AFHTTPRequestSerializerObserverContext) {
  544 + if ([change[NSKeyValueChangeNewKey] isEqual:[NSNull null]]) {
  545 + [self.mutableObservedChangedKeyPaths removeObject:keyPath];
  546 + } else {
  547 + [self.mutableObservedChangedKeyPaths addObject:keyPath];
  548 + }
  549 + }
  550 +}
  551 +
  552 +#pragma mark - NSSecureCoding
  553 +
  554 ++ (BOOL)supportsSecureCoding {
  555 + return YES;
  556 +}
  557 +
  558 +- (instancetype)initWithCoder:(NSCoder *)decoder {
  559 + self = [self init];
  560 + if (!self) {
  561 + return nil;
  562 + }
  563 +
  564 + self.mutableHTTPRequestHeaders = [[decoder decodeObjectOfClass:[NSDictionary class] forKey:NSStringFromSelector(@selector(mutableHTTPRequestHeaders))] mutableCopy];
  565 + self.queryStringSerializationStyle = (AFHTTPRequestQueryStringSerializationStyle)[[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(queryStringSerializationStyle))] unsignedIntegerValue];
  566 +
  567 + return self;
  568 +}
  569 +
  570 +- (void)encodeWithCoder:(NSCoder *)coder {
  571 + dispatch_sync(self.requestHeaderModificationQueue, ^{
  572 + [coder encodeObject:self.mutableHTTPRequestHeaders forKey:NSStringFromSelector(@selector(mutableHTTPRequestHeaders))];
  573 + });
  574 + [coder encodeInteger:self.queryStringSerializationStyle forKey:NSStringFromSelector(@selector(queryStringSerializationStyle))];
  575 +}
  576 +
  577 +#pragma mark - NSCopying
  578 +
  579 +- (instancetype)copyWithZone:(NSZone *)zone {
  580 + AFHTTPRequestSerializer *serializer = [[[self class] allocWithZone:zone] init];
  581 + dispatch_sync(self.requestHeaderModificationQueue, ^{
  582 + serializer.mutableHTTPRequestHeaders = [self.mutableHTTPRequestHeaders mutableCopyWithZone:zone];
  583 + });
  584 + serializer.queryStringSerializationStyle = self.queryStringSerializationStyle;
  585 + serializer.queryStringSerialization = self.queryStringSerialization;
  586 +
  587 + return serializer;
  588 +}
  589 +
  590 +@end
  591 +
  592 +#pragma mark -
  593 +
  594 +static NSString * AFCreateMultipartFormBoundary() {
  595 + return [NSString stringWithFormat:@"Boundary+%08X%08X", arc4random(), arc4random()];
  596 +}
  597 +
  598 +static NSString * const kAFMultipartFormCRLF = @"\r\n";
  599 +
  600 +static inline NSString * AFMultipartFormInitialBoundary(NSString *boundary) {
  601 + return [NSString stringWithFormat:@"--%@%@", boundary, kAFMultipartFormCRLF];
  602 +}
  603 +
  604 +static inline NSString * AFMultipartFormEncapsulationBoundary(NSString *boundary) {
  605 + return [NSString stringWithFormat:@"%@--%@%@", kAFMultipartFormCRLF, boundary, kAFMultipartFormCRLF];
  606 +}
  607 +
  608 +static inline NSString * AFMultipartFormFinalBoundary(NSString *boundary) {
  609 + return [NSString stringWithFormat:@"%@--%@--%@", kAFMultipartFormCRLF, boundary, kAFMultipartFormCRLF];
  610 +}
  611 +
  612 +static inline NSString * AFContentTypeForPathExtension(NSString *extension) {
  613 + NSString *UTI = (__bridge_transfer NSString *)UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)extension, NULL);
  614 + NSString *contentType = (__bridge_transfer NSString *)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)UTI, kUTTagClassMIMEType);
  615 + if (!contentType) {
  616 + return @"application/octet-stream";
  617 + } else {
  618 + return contentType;
  619 + }
  620 +}
  621 +
  622 +NSUInteger const kAFUploadStream3GSuggestedPacketSize = 1024 * 16;
  623 +NSTimeInterval const kAFUploadStream3GSuggestedDelay = 0.2;
  624 +
  625 +@interface AFHTTPBodyPart : NSObject
  626 +@property (nonatomic, assign) NSStringEncoding stringEncoding;
  627 +@property (nonatomic, strong) NSDictionary *headers;
  628 +@property (nonatomic, copy) NSString *boundary;
  629 +@property (nonatomic, strong) id body;
  630 +@property (nonatomic, assign) unsigned long long bodyContentLength;
  631 +@property (nonatomic, strong) NSInputStream *inputStream;
  632 +
  633 +@property (nonatomic, assign) BOOL hasInitialBoundary;
  634 +@property (nonatomic, assign) BOOL hasFinalBoundary;
  635 +
  636 +@property (readonly, nonatomic, assign, getter = hasBytesAvailable) BOOL bytesAvailable;
  637 +@property (readonly, nonatomic, assign) unsigned long long contentLength;
  638 +
  639 +- (NSInteger)read:(uint8_t *)buffer
  640 + maxLength:(NSUInteger)length;
  641 +@end
  642 +
  643 +@interface AFMultipartBodyStream : NSInputStream <NSStreamDelegate>
  644 +@property (nonatomic, assign) NSUInteger numberOfBytesInPacket;
  645 +@property (nonatomic, assign) NSTimeInterval delay;
  646 +@property (nonatomic, strong) NSInputStream *inputStream;
  647 +@property (readonly, nonatomic, assign) unsigned long long contentLength;
  648 +@property (readonly, nonatomic, assign, getter = isEmpty) BOOL empty;
  649 +
  650 +- (instancetype)initWithStringEncoding:(NSStringEncoding)encoding;
  651 +- (void)setInitialAndFinalBoundaries;
  652 +- (void)appendHTTPBodyPart:(AFHTTPBodyPart *)bodyPart;
  653 +@end
  654 +
  655 +#pragma mark -
  656 +
  657 +@interface AFStreamingMultipartFormData ()
  658 +@property (readwrite, nonatomic, copy) NSMutableURLRequest *request;
  659 +@property (readwrite, nonatomic, assign) NSStringEncoding stringEncoding;
  660 +@property (readwrite, nonatomic, copy) NSString *boundary;
  661 +@property (readwrite, nonatomic, strong) AFMultipartBodyStream *bodyStream;
  662 +@end
  663 +
  664 +@implementation AFStreamingMultipartFormData
  665 +
  666 +- (instancetype)initWithURLRequest:(NSMutableURLRequest *)urlRequest
  667 + stringEncoding:(NSStringEncoding)encoding
  668 +{
  669 + self = [super init];
  670 + if (!self) {
  671 + return nil;
  672 + }
  673 +
  674 + self.request = urlRequest;
  675 + self.stringEncoding = encoding;
  676 + self.boundary = AFCreateMultipartFormBoundary();
  677 + self.bodyStream = [[AFMultipartBodyStream alloc] initWithStringEncoding:encoding];
  678 +
  679 + return self;
  680 +}
  681 +
  682 +- (void)setRequest:(NSMutableURLRequest *)request
  683 +{
  684 + _request = [request mutableCopy];
  685 +}
  686 +
  687 +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL
  688 + name:(NSString *)name
  689 + error:(NSError * __autoreleasing *)error
  690 +{
  691 + NSParameterAssert(fileURL);
  692 + NSParameterAssert(name);
  693 +
  694 + NSString *fileName = [fileURL lastPathComponent];
  695 + NSString *mimeType = AFContentTypeForPathExtension([fileURL pathExtension]);
  696 +
  697 + return [self appendPartWithFileURL:fileURL name:name fileName:fileName mimeType:mimeType error:error];
  698 +}
  699 +
  700 +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL
  701 + name:(NSString *)name
  702 + fileName:(NSString *)fileName
  703 + mimeType:(NSString *)mimeType
  704 + error:(NSError * __autoreleasing *)error
  705 +{
  706 + NSParameterAssert(fileURL);
  707 + NSParameterAssert(name);
  708 + NSParameterAssert(fileName);
  709 + NSParameterAssert(mimeType);
  710 +
  711 + if (![fileURL isFileURL]) {
  712 + NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey: NSLocalizedStringFromTable(@"Expected URL to be a file URL", @"AFNetworking", nil)};
  713 + if (error) {
  714 + *error = [[NSError alloc] initWithDomain:AFURLRequestSerializationErrorDomain code:NSURLErrorBadURL userInfo:userInfo];
  715 + }
  716 +
  717 + return NO;
  718 + } else if ([fileURL checkResourceIsReachableAndReturnError:error] == NO) {
  719 + NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey: NSLocalizedStringFromTable(@"File URL not reachable.", @"AFNetworking", nil)};
  720 + if (error) {
  721 + *error = [[NSError alloc] initWithDomain:AFURLRequestSerializationErrorDomain code:NSURLErrorBadURL userInfo:userInfo];
  722 + }
  723 +
  724 + return NO;
  725 + }
  726 +
  727 + NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:[fileURL path] error:error];
  728 + if (!fileAttributes) {
  729 + return NO;
  730 + }
  731 +
  732 + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary];
  733 + [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"];
  734 + [mutableHeaders setValue:mimeType forKey:@"Content-Type"];
  735 +
  736 + AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init];
  737 + bodyPart.stringEncoding = self.stringEncoding;
  738 + bodyPart.headers = mutableHeaders;
  739 + bodyPart.boundary = self.boundary;
  740 + bodyPart.body = fileURL;
  741 + bodyPart.bodyContentLength = [fileAttributes[NSFileSize] unsignedLongLongValue];
  742 + [self.bodyStream appendHTTPBodyPart:bodyPart];
  743 +
  744 + return YES;
  745 +}
  746 +
  747 +- (void)appendPartWithInputStream:(NSInputStream *)inputStream
  748 + name:(NSString *)name
  749 + fileName:(NSString *)fileName
  750 + length:(int64_t)length
  751 + mimeType:(NSString *)mimeType
  752 +{
  753 + NSParameterAssert(name);
  754 + NSParameterAssert(fileName);
  755 + NSParameterAssert(mimeType);
  756 +
  757 + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary];
  758 + [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"];
  759 + [mutableHeaders setValue:mimeType forKey:@"Content-Type"];
  760 +
  761 + AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init];
  762 + bodyPart.stringEncoding = self.stringEncoding;
  763 + bodyPart.headers = mutableHeaders;
  764 + bodyPart.boundary = self.boundary;
  765 + bodyPart.body = inputStream;
  766 +
  767 + bodyPart.bodyContentLength = (unsigned long long)length;
  768 +
  769 + [self.bodyStream appendHTTPBodyPart:bodyPart];
  770 +}
  771 +
  772 +- (void)appendPartWithFileData:(NSData *)data
  773 + name:(NSString *)name
  774 + fileName:(NSString *)fileName
  775 + mimeType:(NSString *)mimeType
  776 +{
  777 + NSParameterAssert(name);
  778 + NSParameterAssert(fileName);
  779 + NSParameterAssert(mimeType);
  780 +
  781 + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary];
  782 + [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"];
  783 + [mutableHeaders setValue:mimeType forKey:@"Content-Type"];
  784 +
  785 + [self appendPartWithHeaders:mutableHeaders body:data];
  786 +}
  787 +
  788 +- (void)appendPartWithFormData:(NSData *)data
  789 + name:(NSString *)name
  790 +{
  791 + NSParameterAssert(name);
  792 +
  793 + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary];
  794 + [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"", name] forKey:@"Content-Disposition"];
  795 +
  796 + [self appendPartWithHeaders:mutableHeaders body:data];
  797 +}
  798 +
  799 +- (void)appendPartWithHeaders:(NSDictionary *)headers
  800 + body:(NSData *)body
  801 +{
  802 + NSParameterAssert(body);
  803 +
  804 + AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init];
  805 + bodyPart.stringEncoding = self.stringEncoding;
  806 + bodyPart.headers = headers;
  807 + bodyPart.boundary = self.boundary;
  808 + bodyPart.bodyContentLength = [body length];
  809 + bodyPart.body = body;
  810 +
  811 + [self.bodyStream appendHTTPBodyPart:bodyPart];
  812 +}
  813 +
  814 +- (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes
  815 + delay:(NSTimeInterval)delay
  816 +{
  817 + self.bodyStream.numberOfBytesInPacket = numberOfBytes;
  818 + self.bodyStream.delay = delay;
  819 +}
  820 +
  821 +- (NSMutableURLRequest *)requestByFinalizingMultipartFormData {
  822 + if ([self.bodyStream isEmpty]) {
  823 + return self.request;
  824 + }
  825 +
  826 + // Reset the initial and final boundaries to ensure correct Content-Length
  827 + [self.bodyStream setInitialAndFinalBoundaries];
  828 + [self.request setHTTPBodyStream:self.bodyStream];
  829 +
  830 + [self.request setValue:[NSString stringWithFormat:@"multipart/form-data; boundary=%@", self.boundary] forHTTPHeaderField:@"Content-Type"];
  831 + [self.request setValue:[NSString stringWithFormat:@"%llu", [self.bodyStream contentLength]] forHTTPHeaderField:@"Content-Length"];
  832 +
  833 + return self.request;
  834 +}
  835 +
  836 +@end
  837 +
  838 +#pragma mark -
  839 +
  840 +@interface NSStream ()
  841 +@property (readwrite) NSStreamStatus streamStatus;
  842 +@property (readwrite, copy) NSError *streamError;
  843 +@end
  844 +
  845 +@interface AFMultipartBodyStream () <NSCopying>
  846 +@property (readwrite, nonatomic, assign) NSStringEncoding stringEncoding;
  847 +@property (readwrite, nonatomic, strong) NSMutableArray *HTTPBodyParts;
  848 +@property (readwrite, nonatomic, strong) NSEnumerator *HTTPBodyPartEnumerator;
  849 +@property (readwrite, nonatomic, strong) AFHTTPBodyPart *currentHTTPBodyPart;
  850 +@property (readwrite, nonatomic, strong) NSOutputStream *outputStream;
  851 +@property (readwrite, nonatomic, strong) NSMutableData *buffer;
  852 +@end
  853 +
  854 +@implementation AFMultipartBodyStream
  855 +#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1100)
  856 +@synthesize delegate;
  857 +#endif
  858 +@synthesize streamStatus;
  859 +@synthesize streamError;
  860 +
  861 +- (instancetype)initWithStringEncoding:(NSStringEncoding)encoding {
  862 + self = [super init];
  863 + if (!self) {
  864 + return nil;
  865 + }
  866 +
  867 + self.stringEncoding = encoding;
  868 + self.HTTPBodyParts = [NSMutableArray array];
  869 + self.numberOfBytesInPacket = NSIntegerMax;
  870 +
  871 + return self;
  872 +}
  873 +
  874 +- (void)setInitialAndFinalBoundaries {
  875 + if ([self.HTTPBodyParts count] > 0) {
  876 + for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) {
  877 + bodyPart.hasInitialBoundary = NO;
  878 + bodyPart.hasFinalBoundary = NO;
  879 + }
  880 +
  881 + [[self.HTTPBodyParts firstObject] setHasInitialBoundary:YES];
  882 + [[self.HTTPBodyParts lastObject] setHasFinalBoundary:YES];
  883 + }
  884 +}
  885 +
  886 +- (void)appendHTTPBodyPart:(AFHTTPBodyPart *)bodyPart {
  887 + [self.HTTPBodyParts addObject:bodyPart];
  888 +}
  889 +
  890 +- (BOOL)isEmpty {
  891 + return [self.HTTPBodyParts count] == 0;
  892 +}
  893 +
  894 +#pragma mark - NSInputStream
  895 +
  896 +- (NSInteger)read:(uint8_t *)buffer
  897 + maxLength:(NSUInteger)length
  898 +{
  899 + if ([self streamStatus] == NSStreamStatusClosed) {
  900 + return 0;
  901 + }
  902 +
  903 + NSInteger totalNumberOfBytesRead = 0;
  904 +
  905 + while ((NSUInteger)totalNumberOfBytesRead < MIN(length, self.numberOfBytesInPacket)) {
  906 + if (!self.currentHTTPBodyPart || ![self.currentHTTPBodyPart hasBytesAvailable]) {
  907 + if (!(self.currentHTTPBodyPart = [self.HTTPBodyPartEnumerator nextObject])) {
  908 + break;
  909 + }
  910 + } else {
  911 + NSUInteger maxLength = MIN(length, self.numberOfBytesInPacket) - (NSUInteger)totalNumberOfBytesRead;
  912 + NSInteger numberOfBytesRead = [self.currentHTTPBodyPart read:&buffer[totalNumberOfBytesRead] maxLength:maxLength];
  913 + if (numberOfBytesRead == -1) {
  914 + self.streamError = self.currentHTTPBodyPart.inputStream.streamError;
  915 + break;
  916 + } else {
  917 + totalNumberOfBytesRead += numberOfBytesRead;
  918 +
  919 + if (self.delay > 0.0f) {
  920 + [NSThread sleepForTimeInterval:self.delay];
  921 + }
  922 + }
  923 + }
  924 + }
  925 +
  926 + return totalNumberOfBytesRead;
  927 +}
  928 +
  929 +- (BOOL)getBuffer:(__unused uint8_t **)buffer
  930 + length:(__unused NSUInteger *)len
  931 +{
  932 + return NO;
  933 +}
  934 +
  935 +- (BOOL)hasBytesAvailable {
  936 + return [self streamStatus] == NSStreamStatusOpen;
  937 +}
  938 +
  939 +#pragma mark - NSStream
  940 +
  941 +- (void)open {
  942 + if (self.streamStatus == NSStreamStatusOpen) {
  943 + return;
  944 + }
  945 +
  946 + self.streamStatus = NSStreamStatusOpen;
  947 +
  948 + [self setInitialAndFinalBoundaries];
  949 + self.HTTPBodyPartEnumerator = [self.HTTPBodyParts objectEnumerator];
  950 +}
  951 +
  952 +- (void)close {
  953 + self.streamStatus = NSStreamStatusClosed;
  954 +}
  955 +
  956 +- (id)propertyForKey:(__unused NSString *)key {
  957 + return nil;
  958 +}
  959 +
  960 +- (BOOL)setProperty:(__unused id)property
  961 + forKey:(__unused NSString *)key
  962 +{
  963 + return NO;
  964 +}
  965 +
  966 +- (void)scheduleInRunLoop:(__unused NSRunLoop *)aRunLoop
  967 + forMode:(__unused NSString *)mode
  968 +{}
  969 +
  970 +- (void)removeFromRunLoop:(__unused NSRunLoop *)aRunLoop
  971 + forMode:(__unused NSString *)mode
  972 +{}
  973 +
  974 +- (unsigned long long)contentLength {
  975 + unsigned long long length = 0;
  976 + for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) {
  977 + length += [bodyPart contentLength];
  978 + }
  979 +
  980 + return length;
  981 +}
  982 +
  983 +#pragma mark - Undocumented CFReadStream Bridged Methods
  984 +
  985 +- (void)_scheduleInCFRunLoop:(__unused CFRunLoopRef)aRunLoop
  986 + forMode:(__unused CFStringRef)aMode
  987 +{}
  988 +
  989 +- (void)_unscheduleFromCFRunLoop:(__unused CFRunLoopRef)aRunLoop
  990 + forMode:(__unused CFStringRef)aMode
  991 +{}
  992 +
  993 +- (BOOL)_setCFClientFlags:(__unused CFOptionFlags)inFlags
  994 + callback:(__unused CFReadStreamClientCallBack)inCallback
  995 + context:(__unused CFStreamClientContext *)inContext {
  996 + return NO;
  997 +}
  998 +
  999 +#pragma mark - NSCopying
  1000 +
  1001 +- (instancetype)copyWithZone:(NSZone *)zone {
  1002 + AFMultipartBodyStream *bodyStreamCopy = [[[self class] allocWithZone:zone] initWithStringEncoding:self.stringEncoding];
  1003 +
  1004 + for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) {
  1005 + [bodyStreamCopy appendHTTPBodyPart:[bodyPart copy]];
  1006 + }
  1007 +
  1008 + [bodyStreamCopy setInitialAndFinalBoundaries];
  1009 +
  1010 + return bodyStreamCopy;
  1011 +}
  1012 +
  1013 +@end
  1014 +
  1015 +#pragma mark -
  1016 +
  1017 +typedef enum {
  1018 + AFEncapsulationBoundaryPhase = 1,
  1019 + AFHeaderPhase = 2,
  1020 + AFBodyPhase = 3,
  1021 + AFFinalBoundaryPhase = 4,
  1022 +} AFHTTPBodyPartReadPhase;
  1023 +
  1024 +@interface AFHTTPBodyPart () <NSCopying> {
  1025 + AFHTTPBodyPartReadPhase _phase;
  1026 + NSInputStream *_inputStream;
  1027 + unsigned long long _phaseReadOffset;
  1028 +}
  1029 +
  1030 +- (BOOL)transitionToNextPhase;
  1031 +- (NSInteger)readData:(NSData *)data
  1032 + intoBuffer:(uint8_t *)buffer
  1033 + maxLength:(NSUInteger)length;
  1034 +@end
  1035 +
  1036 +@implementation AFHTTPBodyPart
  1037 +
  1038 +- (instancetype)init {
  1039 + self = [super init];
  1040 + if (!self) {
  1041 + return nil;
  1042 + }
  1043 +
  1044 + [self transitionToNextPhase];
  1045 +
  1046 + return self;
  1047 +}
  1048 +
  1049 +- (void)dealloc {
  1050 + if (_inputStream) {
  1051 + [_inputStream close];
  1052 + _inputStream = nil;
  1053 + }
  1054 +}
  1055 +
  1056 +- (NSInputStream *)inputStream {
  1057 + if (!_inputStream) {
  1058 + if ([self.body isKindOfClass:[NSData class]]) {
  1059 + _inputStream = [NSInputStream inputStreamWithData:self.body];
  1060 + } else if ([self.body isKindOfClass:[NSURL class]]) {
  1061 + _inputStream = [NSInputStream inputStreamWithURL:self.body];
  1062 + } else if ([self.body isKindOfClass:[NSInputStream class]]) {
  1063 + _inputStream = self.body;
  1064 + } else {
  1065 + _inputStream = [NSInputStream inputStreamWithData:[NSData data]];
  1066 + }
  1067 + }
  1068 +
  1069 + return _inputStream;
  1070 +}
  1071 +
  1072 +- (NSString *)stringForHeaders {
  1073 + NSMutableString *headerString = [NSMutableString string];
  1074 + for (NSString *field in [self.headers allKeys]) {
  1075 + [headerString appendString:[NSString stringWithFormat:@"%@: %@%@", field, [self.headers valueForKey:field], kAFMultipartFormCRLF]];
  1076 + }
  1077 + [headerString appendString:kAFMultipartFormCRLF];
  1078 +
  1079 + return [NSString stringWithString:headerString];
  1080 +}
  1081 +
  1082 +- (unsigned long long)contentLength {
  1083 + unsigned long long length = 0;
  1084 +
  1085 + NSData *encapsulationBoundaryData = [([self hasInitialBoundary] ? AFMultipartFormInitialBoundary(self.boundary) : AFMultipartFormEncapsulationBoundary(self.boundary)) dataUsingEncoding:self.stringEncoding];
  1086 + length += [encapsulationBoundaryData length];
  1087 +
  1088 + NSData *headersData = [[self stringForHeaders] dataUsingEncoding:self.stringEncoding];
  1089 + length += [headersData length];
  1090 +
  1091 + length += _bodyContentLength;
  1092 +
  1093 + NSData *closingBoundaryData = ([self hasFinalBoundary] ? [AFMultipartFormFinalBoundary(self.boundary) dataUsingEncoding:self.stringEncoding] : [NSData data]);
  1094 + length += [closingBoundaryData length];
  1095 +
  1096 + return length;
  1097 +}
  1098 +
  1099 +- (BOOL)hasBytesAvailable {
  1100 + // Allows `read:maxLength:` to be called again if `AFMultipartFormFinalBoundary` doesn't fit into the available buffer
  1101 + if (_phase == AFFinalBoundaryPhase) {
  1102 + return YES;
  1103 + }
  1104 +
  1105 + switch (self.inputStream.streamStatus) {
  1106 + case NSStreamStatusNotOpen:
  1107 + case NSStreamStatusOpening:
  1108 + case NSStreamStatusOpen:
  1109 + case NSStreamStatusReading:
  1110 + case NSStreamStatusWriting:
  1111 + return YES;
  1112 + case NSStreamStatusAtEnd:
  1113 + case NSStreamStatusClosed:
  1114 + case NSStreamStatusError:
  1115 + default:
  1116 + return NO;
  1117 + }
  1118 +}
  1119 +
  1120 +- (NSInteger)read:(uint8_t *)buffer
  1121 + maxLength:(NSUInteger)length
  1122 +{
  1123 + NSInteger totalNumberOfBytesRead = 0;
  1124 +
  1125 + if (_phase == AFEncapsulationBoundaryPhase) {
  1126 + NSData *encapsulationBoundaryData = [([self hasInitialBoundary] ? AFMultipartFormInitialBoundary(self.boundary) : AFMultipartFormEncapsulationBoundary(self.boundary)) dataUsingEncoding:self.stringEncoding];
  1127 + totalNumberOfBytesRead += [self readData:encapsulationBoundaryData intoBuffer:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)];
  1128 + }
  1129 +
  1130 + if (_phase == AFHeaderPhase) {
  1131 + NSData *headersData = [[self stringForHeaders] dataUsingEncoding:self.stringEncoding];
  1132 + totalNumberOfBytesRead += [self readData:headersData intoBuffer:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)];
  1133 + }
  1134 +
  1135 + if (_phase == AFBodyPhase) {
  1136 + NSInteger numberOfBytesRead = 0;
  1137 +
  1138 + numberOfBytesRead = [self.inputStream read:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)];
  1139 + if (numberOfBytesRead == -1) {
  1140 + return -1;
  1141 + } else {
  1142 + totalNumberOfBytesRead += numberOfBytesRead;
  1143 +
  1144 + if ([self.inputStream streamStatus] >= NSStreamStatusAtEnd) {
  1145 + [self transitionToNextPhase];
  1146 + }
  1147 + }
  1148 + }
  1149 +
  1150 + if (_phase == AFFinalBoundaryPhase) {
  1151 + NSData *closingBoundaryData = ([self hasFinalBoundary] ? [AFMultipartFormFinalBoundary(self.boundary) dataUsingEncoding:self.stringEncoding] : [NSData data]);
  1152 + totalNumberOfBytesRead += [self readData:closingBoundaryData intoBuffer:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)];
  1153 + }
  1154 +
  1155 + return totalNumberOfBytesRead;
  1156 +}
  1157 +
  1158 +- (NSInteger)readData:(NSData *)data
  1159 + intoBuffer:(uint8_t *)buffer
  1160 + maxLength:(NSUInteger)length
  1161 +{
  1162 + NSRange range = NSMakeRange((NSUInteger)_phaseReadOffset, MIN([data length] - ((NSUInteger)_phaseReadOffset), length));
  1163 + [data getBytes:buffer range:range];
  1164 +
  1165 + _phaseReadOffset += range.length;
  1166 +
  1167 + if (((NSUInteger)_phaseReadOffset) >= [data length]) {
  1168 + [self transitionToNextPhase];
  1169 + }
  1170 +
  1171 + return (NSInteger)range.length;
  1172 +}
  1173 +
  1174 +- (BOOL)transitionToNextPhase {
  1175 + if (![[NSThread currentThread] isMainThread]) {
  1176 + dispatch_sync(dispatch_get_main_queue(), ^{
  1177 + [self transitionToNextPhase];
  1178 + });
  1179 + return YES;
  1180 + }
  1181 +
  1182 + switch (_phase) {
  1183 + case AFEncapsulationBoundaryPhase:
  1184 + _phase = AFHeaderPhase;
  1185 + break;
  1186 + case AFHeaderPhase:
  1187 + [self.inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
  1188 + [self.inputStream open];
  1189 + _phase = AFBodyPhase;
  1190 + break;
  1191 + case AFBodyPhase:
  1192 + [self.inputStream close];
  1193 + _phase = AFFinalBoundaryPhase;
  1194 + break;
  1195 + case AFFinalBoundaryPhase:
  1196 + default:
  1197 + _phase = AFEncapsulationBoundaryPhase;
  1198 + break;
  1199 + }
  1200 + _phaseReadOffset = 0;
  1201 +
  1202 + return YES;
  1203 +}
  1204 +
  1205 +#pragma mark - NSCopying
  1206 +
  1207 +- (instancetype)copyWithZone:(NSZone *)zone {
  1208 + AFHTTPBodyPart *bodyPart = [[[self class] allocWithZone:zone] init];
  1209 +
  1210 + bodyPart.stringEncoding = self.stringEncoding;
  1211 + bodyPart.headers = self.headers;
  1212 + bodyPart.bodyContentLength = self.bodyContentLength;
  1213 + bodyPart.body = self.body;
  1214 + bodyPart.boundary = self.boundary;
  1215 +
  1216 + return bodyPart;
  1217 +}
  1218 +
  1219 +@end
  1220 +
  1221 +#pragma mark -
  1222 +
  1223 +@implementation AFJSONRequestSerializer
  1224 +
  1225 ++ (instancetype)serializer {
  1226 + return [self serializerWithWritingOptions:(NSJSONWritingOptions)0];
  1227 +}
  1228 +
  1229 ++ (instancetype)serializerWithWritingOptions:(NSJSONWritingOptions)writingOptions
  1230 +{
  1231 + AFJSONRequestSerializer *serializer = [[self alloc] init];
  1232 + serializer.writingOptions = writingOptions;
  1233 +
  1234 + return serializer;
  1235 +}
  1236 +
  1237 +#pragma mark - AFURLRequestSerialization
  1238 +
  1239 +- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request
  1240 + withParameters:(id)parameters
  1241 + error:(NSError *__autoreleasing *)error
  1242 +{
  1243 + NSParameterAssert(request);
  1244 +
  1245 + if ([self.HTTPMethodsEncodingParametersInURI containsObject:[[request HTTPMethod] uppercaseString]]) {
  1246 + return [super requestBySerializingRequest:request withParameters:parameters error:error];
  1247 + }
  1248 +
  1249 + NSMutableURLRequest *mutableRequest = [request mutableCopy];
  1250 +
  1251 + [self.HTTPRequestHeaders enumerateKeysAndObjectsUsingBlock:^(id field, id value, BOOL * __unused stop) {
  1252 + if (![request valueForHTTPHeaderField:field]) {
  1253 + [mutableRequest setValue:value forHTTPHeaderField:field];
  1254 + }
  1255 + }];
  1256 +
  1257 + if (parameters) {
  1258 + if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) {
  1259 + [mutableRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
  1260 + }
  1261 +
  1262 + if (![NSJSONSerialization isValidJSONObject:parameters]) {
  1263 + if (error) {
  1264 + NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey: NSLocalizedStringFromTable(@"The `parameters` argument is not valid JSON.", @"AFNetworking", nil)};
  1265 + *error = [[NSError alloc] initWithDomain:AFURLRequestSerializationErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:userInfo];
  1266 + }
  1267 + return nil;
  1268 + }
  1269 +
  1270 + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:self.writingOptions error:error];
  1271 +
  1272 + if (!jsonData) {
  1273 + return nil;
  1274 + }
  1275 +
  1276 + [mutableRequest setHTTPBody:jsonData];
  1277 + }
  1278 +
  1279 + return mutableRequest;
  1280 +}
  1281 +
  1282 +#pragma mark - NSSecureCoding
  1283 +
  1284 +- (instancetype)initWithCoder:(NSCoder *)decoder {
  1285 + self = [super initWithCoder:decoder];
  1286 + if (!self) {
  1287 + return nil;
  1288 + }
  1289 +
  1290 + self.writingOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(writingOptions))] unsignedIntegerValue];
  1291 +
  1292 + return self;
  1293 +}
  1294 +
  1295 +- (void)encodeWithCoder:(NSCoder *)coder {
  1296 + [super encodeWithCoder:coder];
  1297 +
  1298 + [coder encodeInteger:self.writingOptions forKey:NSStringFromSelector(@selector(writingOptions))];
  1299 +}
  1300 +
  1301 +#pragma mark - NSCopying
  1302 +
  1303 +- (instancetype)copyWithZone:(NSZone *)zone {
  1304 + AFJSONRequestSerializer *serializer = [super copyWithZone:zone];
  1305 + serializer.writingOptions = self.writingOptions;
  1306 +
  1307 + return serializer;
  1308 +}
  1309 +
  1310 +@end
  1311 +
  1312 +#pragma mark -
  1313 +
  1314 +@implementation AFPropertyListRequestSerializer
  1315 +
  1316 ++ (instancetype)serializer {
  1317 + return [self serializerWithFormat:NSPropertyListXMLFormat_v1_0 writeOptions:0];
  1318 +}
  1319 +
  1320 ++ (instancetype)serializerWithFormat:(NSPropertyListFormat)format
  1321 + writeOptions:(NSPropertyListWriteOptions)writeOptions
  1322 +{
  1323 + AFPropertyListRequestSerializer *serializer = [[self alloc] init];
  1324 + serializer.format = format;
  1325 + serializer.writeOptions = writeOptions;
  1326 +
  1327 + return serializer;
  1328 +}
  1329 +
  1330 +#pragma mark - AFURLRequestSerializer
  1331 +
  1332 +- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request
  1333 + withParameters:(id)parameters
  1334 + error:(NSError *__autoreleasing *)error
  1335 +{
  1336 + NSParameterAssert(request);
  1337 +
  1338 + if ([self.HTTPMethodsEncodingParametersInURI containsObject:[[request HTTPMethod] uppercaseString]]) {
  1339 + return [super requestBySerializingRequest:request withParameters:parameters error:error];
  1340 + }
  1341 +
  1342 + NSMutableURLRequest *mutableRequest = [request mutableCopy];
  1343 +
  1344 + [self.HTTPRequestHeaders enumerateKeysAndObjectsUsingBlock:^(id field, id value, BOOL * __unused stop) {
  1345 + if (![request valueForHTTPHeaderField:field]) {
  1346 + [mutableRequest setValue:value forHTTPHeaderField:field];
  1347 + }
  1348 + }];
  1349 +
  1350 + if (parameters) {
  1351 + if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) {
  1352 + [mutableRequest setValue:@"application/x-plist" forHTTPHeaderField:@"Content-Type"];
  1353 + }
  1354 +
  1355 + NSData *plistData = [NSPropertyListSerialization dataWithPropertyList:parameters format:self.format options:self.writeOptions error:error];
  1356 +
  1357 + if (!plistData) {
  1358 + return nil;
  1359 + }
  1360 +
  1361 + [mutableRequest setHTTPBody:plistData];
  1362 + }
  1363 +
  1364 + return mutableRequest;
  1365 +}
  1366 +
  1367 +#pragma mark - NSSecureCoding
  1368 +
  1369 +- (instancetype)initWithCoder:(NSCoder *)decoder {
  1370 + self = [super initWithCoder:decoder];
  1371 + if (!self) {
  1372 + return nil;
  1373 + }
  1374 +
  1375 + self.format = (NSPropertyListFormat)[[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(format))] unsignedIntegerValue];
  1376 + self.writeOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(writeOptions))] unsignedIntegerValue];
  1377 +
  1378 + return self;
  1379 +}
  1380 +
  1381 +- (void)encodeWithCoder:(NSCoder *)coder {
  1382 + [super encodeWithCoder:coder];
  1383 +
  1384 + [coder encodeInteger:self.format forKey:NSStringFromSelector(@selector(format))];
  1385 + [coder encodeObject:@(self.writeOptions) forKey:NSStringFromSelector(@selector(writeOptions))];
  1386 +}
  1387 +
  1388 +#pragma mark - NSCopying
  1389 +
  1390 +- (instancetype)copyWithZone:(NSZone *)zone {
  1391 + AFPropertyListRequestSerializer *serializer = [super copyWithZone:zone];
  1392 + serializer.format = self.format;
  1393 + serializer.writeOptions = self.writeOptions;
  1394 +
  1395 + return serializer;
  1396 +}
  1397 +
  1398 +@end
... ...
Example/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.h 0 → 100644
  1 +// AFURLResponseSerialization.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 <Foundation/Foundation.h>
  23 +#import <CoreGraphics/CoreGraphics.h>
  24 +
  25 +NS_ASSUME_NONNULL_BEGIN
  26 +
  27 +/**
  28 + The `AFURLResponseSerialization` protocol is adopted by an object that decodes data into a more useful object representation, according to details in the server response. Response serializers may additionally perform validation on the incoming response and data.
  29 +
  30 + For example, a JSON response serializer may check for an acceptable status code (`2XX` range) and content type (`application/json`), decoding a valid JSON response into an object.
  31 + */
  32 +@protocol AFURLResponseSerialization <NSObject, NSSecureCoding, NSCopying>
  33 +
  34 +/**
  35 + The response object decoded from the data associated with a specified response.
  36 +
  37 + @param response The response to be processed.
  38 + @param data The response data to be decoded.
  39 + @param error The error that occurred while attempting to decode the response data.
  40 +
  41 + @return The object decoded from the specified response data.
  42 + */
  43 +- (nullable id)responseObjectForResponse:(nullable NSURLResponse *)response
  44 + data:(nullable NSData *)data
  45 + error:(NSError * _Nullable __autoreleasing *)error NS_SWIFT_NOTHROW;
  46 +
  47 +@end
  48 +
  49 +#pragma mark -
  50 +
  51 +/**
  52 + `AFHTTPResponseSerializer` conforms to the `AFURLRequestSerialization` & `AFURLResponseSerialization` protocols, offering a concrete base implementation of query string / URL form-encoded parameter serialization and default request headers, as well as response status code and content type validation.
  53 +
  54 + Any request or response serializer dealing with HTTP is encouraged to subclass `AFHTTPResponseSerializer` in order to ensure consistent default behavior.
  55 + */
  56 +@interface AFHTTPResponseSerializer : NSObject <AFURLResponseSerialization>
  57 +
  58 +- (instancetype)init;
  59 +
  60 +@property (nonatomic, assign) NSStringEncoding stringEncoding DEPRECATED_MSG_ATTRIBUTE("The string encoding is never used. AFHTTPResponseSerializer only validates status codes and content types but does not try to decode the received data in any way.");
  61 +
  62 +/**
  63 + Creates and returns a serializer with default configuration.
  64 + */
  65 ++ (instancetype)serializer;
  66 +
  67 +///-----------------------------------------
  68 +/// @name Configuring Response Serialization
  69 +///-----------------------------------------
  70 +
  71 +/**
  72 + The acceptable HTTP status codes for responses. When non-`nil`, responses with status codes not contained by the set will result in an error during validation.
  73 +
  74 + See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
  75 + */
  76 +@property (nonatomic, copy, nullable) NSIndexSet *acceptableStatusCodes;
  77 +
  78 +/**
  79 + The acceptable MIME types for responses. When non-`nil`, responses with a `Content-Type` with MIME types that do not intersect with the set will result in an error during validation.
  80 + */
  81 +@property (nonatomic, copy, nullable) NSSet <NSString *> *acceptableContentTypes;
  82 +
  83 +/**
  84 + Validates the specified response and data.
  85 +
  86 + In its base implementation, this method checks for an acceptable status code and content type. Subclasses may wish to add other domain-specific checks.
  87 +
  88 + @param response The response to be validated.
  89 + @param data The data associated with the response.
  90 + @param error The error that occurred while attempting to validate the response.
  91 +
  92 + @return `YES` if the response is valid, otherwise `NO`.
  93 + */
  94 +- (BOOL)validateResponse:(nullable NSHTTPURLResponse *)response
  95 + data:(nullable NSData *)data
  96 + error:(NSError * _Nullable __autoreleasing *)error;
  97 +
  98 +@end
  99 +
  100 +#pragma mark -
  101 +
  102 +
  103 +/**
  104 + `AFJSONResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes JSON responses.
  105 +
  106 + By default, `AFJSONResponseSerializer` accepts the following MIME types, which includes the official standard, `application/json`, as well as other commonly-used types:
  107 +
  108 + - `application/json`
  109 + - `text/json`
  110 + - `text/javascript`
  111 +
  112 + In RFC 7159 - Section 8.1, it states that JSON text is required to be encoded in UTF-8, UTF-16, or UTF-32, and the default encoding is UTF-8. NSJSONSerialization provides support for all the encodings listed in the specification, and recommends UTF-8 for efficiency. Using an unsupported encoding will result in serialization error. See the `NSJSONSerialization` documentation for more details.
  113 + */
  114 +@interface AFJSONResponseSerializer : AFHTTPResponseSerializer
  115 +
  116 +- (instancetype)init;
  117 +
  118 +/**
  119 + Options for reading the response JSON data and creating the Foundation objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONReadingOptions". `0` by default.
  120 + */
  121 +@property (nonatomic, assign) NSJSONReadingOptions readingOptions;
  122 +
  123 +/**
  124 + Whether to remove keys with `NSNull` values from response JSON. Defaults to `NO`.
  125 + */
  126 +@property (nonatomic, assign) BOOL removesKeysWithNullValues;
  127 +
  128 +/**
  129 + Creates and returns a JSON serializer with specified reading and writing options.
  130 +
  131 + @param readingOptions The specified JSON reading options.
  132 + */
  133 ++ (instancetype)serializerWithReadingOptions:(NSJSONReadingOptions)readingOptions;
  134 +
  135 +@end
  136 +
  137 +#pragma mark -
  138 +
  139 +/**
  140 + `AFXMLParserResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLParser` objects.
  141 +
  142 + By default, `AFXMLParserResponseSerializer` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types:
  143 +
  144 + - `application/xml`
  145 + - `text/xml`
  146 + */
  147 +@interface AFXMLParserResponseSerializer : AFHTTPResponseSerializer
  148 +
  149 +@end
  150 +
  151 +#pragma mark -
  152 +
  153 +#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
  154 +
  155 +/**
  156 + `AFXMLDocumentResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLDocument` objects.
  157 +
  158 + By default, `AFXMLDocumentResponseSerializer` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types:
  159 +
  160 + - `application/xml`
  161 + - `text/xml`
  162 + */
  163 +@interface AFXMLDocumentResponseSerializer : AFHTTPResponseSerializer
  164 +
  165 +- (instancetype)init;
  166 +
  167 +/**
  168 + Input and output options specifically intended for `NSXMLDocument` objects. For possible values, see the `NSXMLDocument` documentation section "Input and Output Options". `0` by default.
  169 + */
  170 +@property (nonatomic, assign) NSUInteger options;
  171 +
  172 +/**
  173 + Creates and returns an XML document serializer with the specified options.
  174 +
  175 + @param mask The XML document options.
  176 + */
  177 ++ (instancetype)serializerWithXMLDocumentOptions:(NSUInteger)mask;
  178 +
  179 +@end
  180 +
  181 +#endif
  182 +
  183 +#pragma mark -
  184 +
  185 +/**
  186 + `AFPropertyListResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLDocument` objects.
  187 +
  188 + By default, `AFPropertyListResponseSerializer` accepts the following MIME types:
  189 +
  190 + - `application/x-plist`
  191 + */
  192 +@interface AFPropertyListResponseSerializer : AFHTTPResponseSerializer
  193 +
  194 +- (instancetype)init;
  195 +
  196 +/**
  197 + The property list format. Possible values are described in "NSPropertyListFormat".
  198 + */
  199 +@property (nonatomic, assign) NSPropertyListFormat format;
  200 +
  201 +/**
  202 + The property list reading options. Possible values are described in "NSPropertyListMutabilityOptions."
  203 + */
  204 +@property (nonatomic, assign) NSPropertyListReadOptions readOptions;
  205 +
  206 +/**
  207 + Creates and returns a property list serializer with a specified format, read options, and write options.
  208 +
  209 + @param format The property list format.
  210 + @param readOptions The property list reading options.
  211 + */
  212 ++ (instancetype)serializerWithFormat:(NSPropertyListFormat)format
  213 + readOptions:(NSPropertyListReadOptions)readOptions;
  214 +
  215 +@end
  216 +
  217 +#pragma mark -
  218 +
  219 +/**
  220 + `AFImageResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes image responses.
  221 +
  222 + By default, `AFImageResponseSerializer` accepts the following MIME types, which correspond to the image formats supported by UIImage or NSImage:
  223 +
  224 + - `image/tiff`
  225 + - `image/jpeg`
  226 + - `image/gif`
  227 + - `image/png`
  228 + - `image/ico`
  229 + - `image/x-icon`
  230 + - `image/bmp`
  231 + - `image/x-bmp`
  232 + - `image/x-xbitmap`
  233 + - `image/x-win-bitmap`
  234 + */
  235 +@interface AFImageResponseSerializer : AFHTTPResponseSerializer
  236 +
  237 +#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH
  238 +/**
  239 + The scale factor used when interpreting the image data to construct `responseImage`. Specifying a scale factor of 1.0 results in an image whose size matches the pixel-based dimensions of the image. Applying a different scale factor changes the size of the image as reported by the size property. This is set to the value of scale of the main screen by default, which automatically scales images for retina displays, for instance.
  240 + */
  241 +@property (nonatomic, assign) CGFloat imageScale;
  242 +
  243 +/**
  244 + Whether to automatically inflate response image data for compressed formats (such as PNG or JPEG). Enabling this can significantly improve drawing performance on iOS when used with `setCompletionBlockWithSuccess:failure:`, as it allows a bitmap representation to be constructed in the background rather than on the main thread. `YES` by default.
  245 + */
  246 +@property (nonatomic, assign) BOOL automaticallyInflatesResponseImage;
  247 +#endif
  248 +
  249 +@end
  250 +
  251 +#pragma mark -
  252 +
  253 +/**
  254 + `AFCompoundSerializer` is a subclass of `AFHTTPResponseSerializer` that delegates the response serialization to the first `AFHTTPResponseSerializer` object that returns an object for `responseObjectForResponse:data:error:`, falling back on the default behavior of `AFHTTPResponseSerializer`. This is useful for supporting multiple potential types and structures of server responses with a single serializer.
  255 + */
  256 +@interface AFCompoundResponseSerializer : AFHTTPResponseSerializer
  257 +
  258 +/**
  259 + The component response serializers.
  260 + */
  261 +@property (readonly, nonatomic, copy) NSArray <id<AFURLResponseSerialization>> *responseSerializers;
  262 +
  263 +/**
  264 + Creates and returns a compound serializer comprised of the specified response serializers.
  265 +
  266 + @warning Each response serializer specified must be a subclass of `AFHTTPResponseSerializer`, and response to `-validateResponse:data:error:`.
  267 + */
  268 ++ (instancetype)compoundSerializerWithResponseSerializers:(NSArray <id<AFURLResponseSerialization>> *)responseSerializers;
  269 +
  270 +@end
  271 +
  272 +///----------------
  273 +/// @name Constants
  274 +///----------------
  275 +
  276 +/**
  277 + ## Error Domains
  278 +
  279 + The following error domain is predefined.
  280 +
  281 + - `NSString * const AFURLResponseSerializationErrorDomain`
  282 +
  283 + ### Constants
  284 +
  285 + `AFURLResponseSerializationErrorDomain`
  286 + AFURLResponseSerializer errors. Error codes for `AFURLResponseSerializationErrorDomain` correspond to codes in `NSURLErrorDomain`.
  287 + */
  288 +FOUNDATION_EXPORT NSString * const AFURLResponseSerializationErrorDomain;
  289 +
  290 +/**
  291 + ## User info dictionary keys
  292 +
  293 + These keys may exist in the user info dictionary, in addition to those defined for NSError.
  294 +
  295 + - `NSString * const AFNetworkingOperationFailingURLResponseErrorKey`
  296 + - `NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey`
  297 +
  298 + ### Constants
  299 +
  300 + `AFNetworkingOperationFailingURLResponseErrorKey`
  301 + The corresponding value is an `NSURLResponse` containing the response of the operation associated with an error. This key is only present in the `AFURLResponseSerializationErrorDomain`.
  302 +
  303 + `AFNetworkingOperationFailingURLResponseDataErrorKey`
  304 + The corresponding value is an `NSData` containing the original data of the operation associated with an error. This key is only present in the `AFURLResponseSerializationErrorDomain`.
  305 + */
  306 +FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLResponseErrorKey;
  307 +
  308 +FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey;
  309 +
  310 +NS_ASSUME_NONNULL_END
... ...
Example/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.m 0 → 100755
  1 +// AFURLResponseSerialization.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 "AFURLResponseSerialization.h"
  23 +
  24 +#import <TargetConditionals.h>
  25 +
  26 +#if TARGET_OS_IOS
  27 +#import <UIKit/UIKit.h>
  28 +#elif TARGET_OS_WATCH
  29 +#import <WatchKit/WatchKit.h>
  30 +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
  31 +#import <Cocoa/Cocoa.h>
  32 +#endif
  33 +
  34 +NSString * const AFURLResponseSerializationErrorDomain = @"com.alamofire.error.serialization.response";
  35 +NSString * const AFNetworkingOperationFailingURLResponseErrorKey = @"com.alamofire.serialization.response.error.response";
  36 +NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey = @"com.alamofire.serialization.response.error.data";
  37 +
  38 +static NSError * AFErrorWithUnderlyingError(NSError *error, NSError *underlyingError) {
  39 + if (!error) {
  40 + return underlyingError;
  41 + }
  42 +
  43 + if (!underlyingError || error.userInfo[NSUnderlyingErrorKey]) {
  44 + return error;
  45 + }
  46 +
  47 + NSMutableDictionary *mutableUserInfo = [error.userInfo mutableCopy];
  48 + mutableUserInfo[NSUnderlyingErrorKey] = underlyingError;
  49 +
  50 + return [[NSError alloc] initWithDomain:error.domain code:error.code userInfo:mutableUserInfo];
  51 +}
  52 +
  53 +static BOOL AFErrorOrUnderlyingErrorHasCodeInDomain(NSError *error, NSInteger code, NSString *domain) {
  54 + if ([error.domain isEqualToString:domain] && error.code == code) {
  55 + return YES;
  56 + } else if (error.userInfo[NSUnderlyingErrorKey]) {
  57 + return AFErrorOrUnderlyingErrorHasCodeInDomain(error.userInfo[NSUnderlyingErrorKey], code, domain);
  58 + }
  59 +
  60 + return NO;
  61 +}
  62 +
  63 +static id AFJSONObjectByRemovingKeysWithNullValues(id JSONObject, NSJSONReadingOptions readingOptions) {
  64 + if ([JSONObject isKindOfClass:[NSArray class]]) {
  65 + NSMutableArray *mutableArray = [NSMutableArray arrayWithCapacity:[(NSArray *)JSONObject count]];
  66 + for (id value in (NSArray *)JSONObject) {
  67 + [mutableArray addObject:AFJSONObjectByRemovingKeysWithNullValues(value, readingOptions)];
  68 + }
  69 +
  70 + return (readingOptions & NSJSONReadingMutableContainers) ? mutableArray : [NSArray arrayWithArray:mutableArray];
  71 + } else if ([JSONObject isKindOfClass:[NSDictionary class]]) {
  72 + NSMutableDictionary *mutableDictionary = [NSMutableDictionary dictionaryWithDictionary:JSONObject];
  73 + for (id <NSCopying> key in [(NSDictionary *)JSONObject allKeys]) {
  74 + id value = (NSDictionary *)JSONObject[key];
  75 + if (!value || [value isEqual:[NSNull null]]) {
  76 + [mutableDictionary removeObjectForKey:key];
  77 + } else if ([value isKindOfClass:[NSArray class]] || [value isKindOfClass:[NSDictionary class]]) {
  78 + mutableDictionary[key] = AFJSONObjectByRemovingKeysWithNullValues(value, readingOptions);
  79 + }
  80 + }
  81 +
  82 + return (readingOptions & NSJSONReadingMutableContainers) ? mutableDictionary : [NSDictionary dictionaryWithDictionary:mutableDictionary];
  83 + }
  84 +
  85 + return JSONObject;
  86 +}
  87 +
  88 +@implementation AFHTTPResponseSerializer
  89 +
  90 ++ (instancetype)serializer {
  91 + return [[self alloc] init];
  92 +}
  93 +
  94 +- (instancetype)init {
  95 + self = [super init];
  96 + if (!self) {
  97 + return nil;
  98 + }
  99 +
  100 + self.acceptableStatusCodes = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(200, 100)];
  101 + self.acceptableContentTypes = nil;
  102 +
  103 + return self;
  104 +}
  105 +
  106 +#pragma mark -
  107 +
  108 +- (BOOL)validateResponse:(NSHTTPURLResponse *)response
  109 + data:(NSData *)data
  110 + error:(NSError * __autoreleasing *)error
  111 +{
  112 + BOOL responseIsValid = YES;
  113 + NSError *validationError = nil;
  114 +
  115 + if (response && [response isKindOfClass:[NSHTTPURLResponse class]]) {
  116 + if (self.acceptableContentTypes && ![self.acceptableContentTypes containsObject:[response MIMEType]] &&
  117 + !([response MIMEType] == nil && [data length] == 0)) {
  118 +
  119 + if ([data length] > 0 && [response URL]) {
  120 + NSMutableDictionary *mutableUserInfo = [@{
  121 + NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: unacceptable content-type: %@", @"AFNetworking", nil), [response MIMEType]],
  122 + NSURLErrorFailingURLErrorKey:[response URL],
  123 + AFNetworkingOperationFailingURLResponseErrorKey: response,
  124 + } mutableCopy];
  125 + if (data) {
  126 + mutableUserInfo[AFNetworkingOperationFailingURLResponseDataErrorKey] = data;
  127 + }
  128 +
  129 + validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:mutableUserInfo], validationError);
  130 + }
  131 +
  132 + responseIsValid = NO;
  133 + }
  134 +
  135 + if (self.acceptableStatusCodes && ![self.acceptableStatusCodes containsIndex:(NSUInteger)response.statusCode] && [response URL]) {
  136 + NSMutableDictionary *mutableUserInfo = [@{
  137 + NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: %@ (%ld)", @"AFNetworking", nil), [NSHTTPURLResponse localizedStringForStatusCode:response.statusCode], (long)response.statusCode],
  138 + NSURLErrorFailingURLErrorKey:[response URL],
  139 + AFNetworkingOperationFailingURLResponseErrorKey: response,
  140 + } mutableCopy];
  141 +
  142 + if (data) {
  143 + mutableUserInfo[AFNetworkingOperationFailingURLResponseDataErrorKey] = data;
  144 + }
  145 +
  146 + validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorBadServerResponse userInfo:mutableUserInfo], validationError);
  147 +
  148 + responseIsValid = NO;
  149 + }
  150 + }
  151 +
  152 + if (error && !responseIsValid) {
  153 + *error = validationError;
  154 + }
  155 +
  156 + return responseIsValid;
  157 +}
  158 +
  159 +#pragma mark - AFURLResponseSerialization
  160 +
  161 +- (id)responseObjectForResponse:(NSURLResponse *)response
  162 + data:(NSData *)data
  163 + error:(NSError *__autoreleasing *)error
  164 +{
  165 + [self validateResponse:(NSHTTPURLResponse *)response data:data error:error];
  166 +
  167 + return data;
  168 +}
  169 +
  170 +#pragma mark - NSSecureCoding
  171 +
  172 ++ (BOOL)supportsSecureCoding {
  173 + return YES;
  174 +}
  175 +
  176 +- (instancetype)initWithCoder:(NSCoder *)decoder {
  177 + self = [self init];
  178 + if (!self) {
  179 + return nil;
  180 + }
  181 +
  182 + self.acceptableStatusCodes = [decoder decodeObjectOfClass:[NSIndexSet class] forKey:NSStringFromSelector(@selector(acceptableStatusCodes))];
  183 + self.acceptableContentTypes = [decoder decodeObjectOfClass:[NSIndexSet class] forKey:NSStringFromSelector(@selector(acceptableContentTypes))];
  184 +
  185 + return self;
  186 +}
  187 +
  188 +- (void)encodeWithCoder:(NSCoder *)coder {
  189 + [coder encodeObject:self.acceptableStatusCodes forKey:NSStringFromSelector(@selector(acceptableStatusCodes))];
  190 + [coder encodeObject:self.acceptableContentTypes forKey:NSStringFromSelector(@selector(acceptableContentTypes))];
  191 +}
  192 +
  193 +#pragma mark - NSCopying
  194 +
  195 +- (instancetype)copyWithZone:(NSZone *)zone {
  196 + AFHTTPResponseSerializer *serializer = [[[self class] allocWithZone:zone] init];
  197 + serializer.acceptableStatusCodes = [self.acceptableStatusCodes copyWithZone:zone];
  198 + serializer.acceptableContentTypes = [self.acceptableContentTypes copyWithZone:zone];
  199 +
  200 + return serializer;
  201 +}
  202 +
  203 +@end
  204 +
  205 +#pragma mark -
  206 +
  207 +@implementation AFJSONResponseSerializer
  208 +
  209 ++ (instancetype)serializer {
  210 + return [self serializerWithReadingOptions:(NSJSONReadingOptions)0];
  211 +}
  212 +
  213 ++ (instancetype)serializerWithReadingOptions:(NSJSONReadingOptions)readingOptions {
  214 + AFJSONResponseSerializer *serializer = [[self alloc] init];
  215 + serializer.readingOptions = readingOptions;
  216 +
  217 + return serializer;
  218 +}
  219 +
  220 +- (instancetype)init {
  221 + self = [super init];
  222 + if (!self) {
  223 + return nil;
  224 + }
  225 +
  226 + self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
  227 +
  228 + return self;
  229 +}
  230 +
  231 +#pragma mark - AFURLResponseSerialization
  232 +
  233 +- (id)responseObjectForResponse:(NSURLResponse *)response
  234 + data:(NSData *)data
  235 + error:(NSError *__autoreleasing *)error
  236 +{
  237 + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
  238 + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) {
  239 + return nil;
  240 + }
  241 + }
  242 +
  243 + // Workaround for behavior of Rails to return a single space for `head :ok` (a workaround for a bug in Safari), which is not interpreted as valid input by NSJSONSerialization.
  244 + // See https://github.com/rails/rails/issues/1742
  245 + BOOL isSpace = [data isEqualToData:[NSData dataWithBytes:" " length:1]];
  246 +
  247 + if (data.length == 0 || isSpace) {
  248 + return nil;
  249 + }
  250 +
  251 + NSError *serializationError = nil;
  252 +
  253 + id responseObject = [NSJSONSerialization JSONObjectWithData:data options:self.readingOptions error:&serializationError];
  254 +
  255 + if (!responseObject)
  256 + {
  257 + if (error) {
  258 + *error = AFErrorWithUnderlyingError(serializationError, *error);
  259 + }
  260 + return nil;
  261 + }
  262 +
  263 + if (self.removesKeysWithNullValues) {
  264 + return AFJSONObjectByRemovingKeysWithNullValues(responseObject, self.readingOptions);
  265 + }
  266 +
  267 + return responseObject;
  268 +}
  269 +
  270 +#pragma mark - NSSecureCoding
  271 +
  272 +- (instancetype)initWithCoder:(NSCoder *)decoder {
  273 + self = [super initWithCoder:decoder];
  274 + if (!self) {
  275 + return nil;
  276 + }
  277 +
  278 + self.readingOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(readingOptions))] unsignedIntegerValue];
  279 + self.removesKeysWithNullValues = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(removesKeysWithNullValues))] boolValue];
  280 +
  281 + return self;
  282 +}
  283 +
  284 +- (void)encodeWithCoder:(NSCoder *)coder {
  285 + [super encodeWithCoder:coder];
  286 +
  287 + [coder encodeObject:@(self.readingOptions) forKey:NSStringFromSelector(@selector(readingOptions))];
  288 + [coder encodeObject:@(self.removesKeysWithNullValues) forKey:NSStringFromSelector(@selector(removesKeysWithNullValues))];
  289 +}
  290 +
  291 +#pragma mark - NSCopying
  292 +
  293 +- (instancetype)copyWithZone:(NSZone *)zone {
  294 + AFJSONResponseSerializer *serializer = [super copyWithZone:zone];
  295 + serializer.readingOptions = self.readingOptions;
  296 + serializer.removesKeysWithNullValues = self.removesKeysWithNullValues;
  297 +
  298 + return serializer;
  299 +}
  300 +
  301 +@end
  302 +
  303 +#pragma mark -
  304 +
  305 +@implementation AFXMLParserResponseSerializer
  306 +
  307 ++ (instancetype)serializer {
  308 + AFXMLParserResponseSerializer *serializer = [[self alloc] init];
  309 +
  310 + return serializer;
  311 +}
  312 +
  313 +- (instancetype)init {
  314 + self = [super init];
  315 + if (!self) {
  316 + return nil;
  317 + }
  318 +
  319 + self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/xml", @"text/xml", nil];
  320 +
  321 + return self;
  322 +}
  323 +
  324 +#pragma mark - AFURLResponseSerialization
  325 +
  326 +- (id)responseObjectForResponse:(NSHTTPURLResponse *)response
  327 + data:(NSData *)data
  328 + error:(NSError *__autoreleasing *)error
  329 +{
  330 + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
  331 + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) {
  332 + return nil;
  333 + }
  334 + }
  335 +
  336 + return [[NSXMLParser alloc] initWithData:data];
  337 +}
  338 +
  339 +@end
  340 +
  341 +#pragma mark -
  342 +
  343 +#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
  344 +
  345 +@implementation AFXMLDocumentResponseSerializer
  346 +
  347 ++ (instancetype)serializer {
  348 + return [self serializerWithXMLDocumentOptions:0];
  349 +}
  350 +
  351 ++ (instancetype)serializerWithXMLDocumentOptions:(NSUInteger)mask {
  352 + AFXMLDocumentResponseSerializer *serializer = [[self alloc] init];
  353 + serializer.options = mask;
  354 +
  355 + return serializer;
  356 +}
  357 +
  358 +- (instancetype)init {
  359 + self = [super init];
  360 + if (!self) {
  361 + return nil;
  362 + }
  363 +
  364 + self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/xml", @"text/xml", nil];
  365 +
  366 + return self;
  367 +}
  368 +
  369 +#pragma mark - AFURLResponseSerialization
  370 +
  371 +- (id)responseObjectForResponse:(NSURLResponse *)response
  372 + data:(NSData *)data
  373 + error:(NSError *__autoreleasing *)error
  374 +{
  375 + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
  376 + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) {
  377 + return nil;
  378 + }
  379 + }
  380 +
  381 + NSError *serializationError = nil;
  382 + NSXMLDocument *document = [[NSXMLDocument alloc] initWithData:data options:self.options error:&serializationError];
  383 +
  384 + if (!document)
  385 + {
  386 + if (error) {
  387 + *error = AFErrorWithUnderlyingError(serializationError, *error);
  388 + }
  389 + return nil;
  390 + }
  391 +
  392 + return document;
  393 +}
  394 +
  395 +#pragma mark - NSSecureCoding
  396 +
  397 +- (instancetype)initWithCoder:(NSCoder *)decoder {
  398 + self = [super initWithCoder:decoder];
  399 + if (!self) {
  400 + return nil;
  401 + }
  402 +
  403 + self.options = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(options))] unsignedIntegerValue];
  404 +
  405 + return self;
  406 +}
  407 +
  408 +- (void)encodeWithCoder:(NSCoder *)coder {
  409 + [super encodeWithCoder:coder];
  410 +
  411 + [coder encodeObject:@(self.options) forKey:NSStringFromSelector(@selector(options))];
  412 +}
  413 +
  414 +#pragma mark - NSCopying
  415 +
  416 +- (instancetype)copyWithZone:(NSZone *)zone {
  417 + AFXMLDocumentResponseSerializer *serializer = [super copyWithZone:zone];
  418 + serializer.options = self.options;
  419 +
  420 + return serializer;
  421 +}
  422 +
  423 +@end
  424 +
  425 +#endif
  426 +
  427 +#pragma mark -
  428 +
  429 +@implementation AFPropertyListResponseSerializer
  430 +
  431 ++ (instancetype)serializer {
  432 + return [self serializerWithFormat:NSPropertyListXMLFormat_v1_0 readOptions:0];
  433 +}
  434 +
  435 ++ (instancetype)serializerWithFormat:(NSPropertyListFormat)format
  436 + readOptions:(NSPropertyListReadOptions)readOptions
  437 +{
  438 + AFPropertyListResponseSerializer *serializer = [[self alloc] init];
  439 + serializer.format = format;
  440 + serializer.readOptions = readOptions;
  441 +
  442 + return serializer;
  443 +}
  444 +
  445 +- (instancetype)init {
  446 + self = [super init];
  447 + if (!self) {
  448 + return nil;
  449 + }
  450 +
  451 + self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/x-plist", nil];
  452 +
  453 + return self;
  454 +}
  455 +
  456 +#pragma mark - AFURLResponseSerialization
  457 +
  458 +- (id)responseObjectForResponse:(NSURLResponse *)response
  459 + data:(NSData *)data
  460 + error:(NSError *__autoreleasing *)error
  461 +{
  462 + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
  463 + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) {
  464 + return nil;
  465 + }
  466 + }
  467 +
  468 + if (!data) {
  469 + return nil;
  470 + }
  471 +
  472 + NSError *serializationError = nil;
  473 +
  474 + id responseObject = [NSPropertyListSerialization propertyListWithData:data options:self.readOptions format:NULL error:&serializationError];
  475 +
  476 + if (!responseObject)
  477 + {
  478 + if (error) {
  479 + *error = AFErrorWithUnderlyingError(serializationError, *error);
  480 + }
  481 + return nil;
  482 + }
  483 +
  484 + return responseObject;
  485 +}
  486 +
  487 +#pragma mark - NSSecureCoding
  488 +
  489 +- (instancetype)initWithCoder:(NSCoder *)decoder {
  490 + self = [super initWithCoder:decoder];
  491 + if (!self) {
  492 + return nil;
  493 + }
  494 +
  495 + self.format = (NSPropertyListFormat)[[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(format))] unsignedIntegerValue];
  496 + self.readOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(readOptions))] unsignedIntegerValue];
  497 +
  498 + return self;
  499 +}
  500 +
  501 +- (void)encodeWithCoder:(NSCoder *)coder {
  502 + [super encodeWithCoder:coder];
  503 +
  504 + [coder encodeObject:@(self.format) forKey:NSStringFromSelector(@selector(format))];
  505 + [coder encodeObject:@(self.readOptions) forKey:NSStringFromSelector(@selector(readOptions))];
  506 +}
  507 +
  508 +#pragma mark - NSCopying
  509 +
  510 +- (instancetype)copyWithZone:(NSZone *)zone {
  511 + AFPropertyListResponseSerializer *serializer = [super copyWithZone:zone];
  512 + serializer.format = self.format;
  513 + serializer.readOptions = self.readOptions;
  514 +
  515 + return serializer;
  516 +}
  517 +
  518 +@end
  519 +
  520 +#pragma mark -
  521 +
  522 +#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH
  523 +#import <CoreGraphics/CoreGraphics.h>
  524 +#import <UIKit/UIKit.h>
  525 +
  526 +@interface UIImage (AFNetworkingSafeImageLoading)
  527 ++ (UIImage *)af_safeImageWithData:(NSData *)data;
  528 +@end
  529 +
  530 +static NSLock* imageLock = nil;
  531 +
  532 +@implementation UIImage (AFNetworkingSafeImageLoading)
  533 +
  534 ++ (UIImage *)af_safeImageWithData:(NSData *)data {
  535 + UIImage* image = nil;
  536 + static dispatch_once_t onceToken;
  537 + dispatch_once(&onceToken, ^{
  538 + imageLock = [[NSLock alloc] init];
  539 + });
  540 +
  541 + [imageLock lock];
  542 + image = [UIImage imageWithData:data];
  543 + [imageLock unlock];
  544 + return image;
  545 +}
  546 +
  547 +@end
  548 +
  549 +static UIImage * AFImageWithDataAtScale(NSData *data, CGFloat scale) {
  550 + UIImage *image = [UIImage af_safeImageWithData:data];
  551 + if (image.images) {
  552 + return image;
  553 + }
  554 +
  555 + return [[UIImage alloc] initWithCGImage:[image CGImage] scale:scale orientation:image.imageOrientation];
  556 +}
  557 +
  558 +static UIImage * AFInflatedImageFromResponseWithDataAtScale(NSHTTPURLResponse *response, NSData *data, CGFloat scale) {
  559 + if (!data || [data length] == 0) {
  560 + return nil;
  561 + }
  562 +
  563 + CGImageRef imageRef = NULL;
  564 + CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData((__bridge CFDataRef)data);
  565 +
  566 + if ([response.MIMEType isEqualToString:@"image/png"]) {
  567 + imageRef = CGImageCreateWithPNGDataProvider(dataProvider, NULL, true, kCGRenderingIntentDefault);
  568 + } else if ([response.MIMEType isEqualToString:@"image/jpeg"]) {
  569 + imageRef = CGImageCreateWithJPEGDataProvider(dataProvider, NULL, true, kCGRenderingIntentDefault);
  570 +
  571 + if (imageRef) {
  572 + CGColorSpaceRef imageColorSpace = CGImageGetColorSpace(imageRef);
  573 + CGColorSpaceModel imageColorSpaceModel = CGColorSpaceGetModel(imageColorSpace);
  574 +
  575 + // CGImageCreateWithJPEGDataProvider does not properly handle CMKY, so fall back to AFImageWithDataAtScale
  576 + if (imageColorSpaceModel == kCGColorSpaceModelCMYK) {
  577 + CGImageRelease(imageRef);
  578 + imageRef = NULL;
  579 + }
  580 + }
  581 + }
  582 +
  583 + CGDataProviderRelease(dataProvider);
  584 +
  585 + UIImage *image = AFImageWithDataAtScale(data, scale);
  586 + if (!imageRef) {
  587 + if (image.images || !image) {
  588 + return image;
  589 + }
  590 +
  591 + imageRef = CGImageCreateCopy([image CGImage]);
  592 + if (!imageRef) {
  593 + return nil;
  594 + }
  595 + }
  596 +
  597 + size_t width = CGImageGetWidth(imageRef);
  598 + size_t height = CGImageGetHeight(imageRef);
  599 + size_t bitsPerComponent = CGImageGetBitsPerComponent(imageRef);
  600 +
  601 + if (width * height > 1024 * 1024 || bitsPerComponent > 8) {
  602 + CGImageRelease(imageRef);
  603 +
  604 + return image;
  605 + }
  606 +
  607 + // CGImageGetBytesPerRow() calculates incorrectly in iOS 5.0, so defer to CGBitmapContextCreate
  608 + size_t bytesPerRow = 0;
  609 + CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
  610 + CGColorSpaceModel colorSpaceModel = CGColorSpaceGetModel(colorSpace);
  611 + CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef);
  612 +
  613 + if (colorSpaceModel == kCGColorSpaceModelRGB) {
  614 + uint32_t alpha = (bitmapInfo & kCGBitmapAlphaInfoMask);
  615 +#pragma clang diagnostic push
  616 +#pragma clang diagnostic ignored "-Wassign-enum"
  617 + if (alpha == kCGImageAlphaNone) {
  618 + bitmapInfo &= ~kCGBitmapAlphaInfoMask;
  619 + bitmapInfo |= kCGImageAlphaNoneSkipFirst;
  620 + } else if (!(alpha == kCGImageAlphaNoneSkipFirst || alpha == kCGImageAlphaNoneSkipLast)) {
  621 + bitmapInfo &= ~kCGBitmapAlphaInfoMask;
  622 + bitmapInfo |= kCGImageAlphaPremultipliedFirst;
  623 + }
  624 +#pragma clang diagnostic pop
  625 + }
  626 +
  627 + CGContextRef context = CGBitmapContextCreate(NULL, width, height, bitsPerComponent, bytesPerRow, colorSpace, bitmapInfo);
  628 +
  629 + CGColorSpaceRelease(colorSpace);
  630 +
  631 + if (!context) {
  632 + CGImageRelease(imageRef);
  633 +
  634 + return image;
  635 + }
  636 +
  637 + CGContextDrawImage(context, CGRectMake(0.0f, 0.0f, width, height), imageRef);
  638 + CGImageRef inflatedImageRef = CGBitmapContextCreateImage(context);
  639 +
  640 + CGContextRelease(context);
  641 +
  642 + UIImage *inflatedImage = [[UIImage alloc] initWithCGImage:inflatedImageRef scale:scale orientation:image.imageOrientation];
  643 +
  644 + CGImageRelease(inflatedImageRef);
  645 + CGImageRelease(imageRef);
  646 +
  647 + return inflatedImage;
  648 +}
  649 +#endif
  650 +
  651 +
  652 +@implementation AFImageResponseSerializer
  653 +
  654 +- (instancetype)init {
  655 + self = [super init];
  656 + if (!self) {
  657 + return nil;
  658 + }
  659 +
  660 + self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"image/tiff", @"image/jpeg", @"image/gif", @"image/png", @"image/ico", @"image/x-icon", @"image/bmp", @"image/x-bmp", @"image/x-xbitmap", @"image/x-win-bitmap", nil];
  661 +
  662 +#if TARGET_OS_IOS || TARGET_OS_TV
  663 + self.imageScale = [[UIScreen mainScreen] scale];
  664 + self.automaticallyInflatesResponseImage = YES;
  665 +#elif TARGET_OS_WATCH
  666 + self.imageScale = [[WKInterfaceDevice currentDevice] screenScale];
  667 + self.automaticallyInflatesResponseImage = YES;
  668 +#endif
  669 +
  670 + return self;
  671 +}
  672 +
  673 +#pragma mark - AFURLResponseSerializer
  674 +
  675 +- (id)responseObjectForResponse:(NSURLResponse *)response
  676 + data:(NSData *)data
  677 + error:(NSError *__autoreleasing *)error
  678 +{
  679 + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
  680 + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) {
  681 + return nil;
  682 + }
  683 + }
  684 +
  685 +#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH
  686 + if (self.automaticallyInflatesResponseImage) {
  687 + return AFInflatedImageFromResponseWithDataAtScale((NSHTTPURLResponse *)response, data, self.imageScale);
  688 + } else {
  689 + return AFImageWithDataAtScale(data, self.imageScale);
  690 + }
  691 +#else
  692 + // Ensure that the image is set to it's correct pixel width and height
  693 + NSBitmapImageRep *bitimage = [[NSBitmapImageRep alloc] initWithData:data];
  694 + NSImage *image = [[NSImage alloc] initWithSize:NSMakeSize([bitimage pixelsWide], [bitimage pixelsHigh])];
  695 + [image addRepresentation:bitimage];
  696 +
  697 + return image;
  698 +#endif
  699 +
  700 + return nil;
  701 +}
  702 +
  703 +#pragma mark - NSSecureCoding
  704 +
  705 +- (instancetype)initWithCoder:(NSCoder *)decoder {
  706 + self = [super initWithCoder:decoder];
  707 + if (!self) {
  708 + return nil;
  709 + }
  710 +
  711 +#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH
  712 + NSNumber *imageScale = [decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(imageScale))];
  713 +#if CGFLOAT_IS_DOUBLE
  714 + self.imageScale = [imageScale doubleValue];
  715 +#else
  716 + self.imageScale = [imageScale floatValue];
  717 +#endif
  718 +
  719 + self.automaticallyInflatesResponseImage = [decoder decodeBoolForKey:NSStringFromSelector(@selector(automaticallyInflatesResponseImage))];
  720 +#endif
  721 +
  722 + return self;
  723 +}
  724 +
  725 +- (void)encodeWithCoder:(NSCoder *)coder {
  726 + [super encodeWithCoder:coder];
  727 +
  728 +#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH
  729 + [coder encodeObject:@(self.imageScale) forKey:NSStringFromSelector(@selector(imageScale))];
  730 + [coder encodeBool:self.automaticallyInflatesResponseImage forKey:NSStringFromSelector(@selector(automaticallyInflatesResponseImage))];
  731 +#endif
  732 +}
  733 +
  734 +#pragma mark - NSCopying
  735 +
  736 +- (instancetype)copyWithZone:(NSZone *)zone {
  737 + AFImageResponseSerializer *serializer = [super copyWithZone:zone];
  738 +
  739 +#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH
  740 + serializer.imageScale = self.imageScale;
  741 + serializer.automaticallyInflatesResponseImage = self.automaticallyInflatesResponseImage;
  742 +#endif
  743 +
  744 + return serializer;
  745 +}
  746 +
  747 +@end
  748 +
  749 +#pragma mark -
  750 +
  751 +@interface AFCompoundResponseSerializer ()
  752 +@property (readwrite, nonatomic, copy) NSArray *responseSerializers;
  753 +@end
  754 +
  755 +@implementation AFCompoundResponseSerializer
  756 +
  757 ++ (instancetype)compoundSerializerWithResponseSerializers:(NSArray *)responseSerializers {
  758 + AFCompoundResponseSerializer *serializer = [[self alloc] init];
  759 + serializer.responseSerializers = responseSerializers;
  760 +
  761 + return serializer;
  762 +}
  763 +
  764 +#pragma mark - AFURLResponseSerialization
  765 +
  766 +- (id)responseObjectForResponse:(NSURLResponse *)response
  767 + data:(NSData *)data
  768 + error:(NSError *__autoreleasing *)error
  769 +{
  770 + for (id <AFURLResponseSerialization> serializer in self.responseSerializers) {
  771 + if (![serializer isKindOfClass:[AFHTTPResponseSerializer class]]) {
  772 + continue;
  773 + }
  774 +
  775 + NSError *serializerError = nil;
  776 + id responseObject = [serializer responseObjectForResponse:response data:data error:&serializerError];
  777 + if (responseObject) {
  778 + if (error) {
  779 + *error = AFErrorWithUnderlyingError(serializerError, *error);
  780 + }
  781 +
  782 + return responseObject;
  783 + }
  784 + }
  785 +
  786 + return [super responseObjectForResponse:response data:data error:error];
  787 +}
  788 +
  789 +#pragma mark - NSSecureCoding
  790 +
  791 +- (instancetype)initWithCoder:(NSCoder *)decoder {
  792 + self = [super initWithCoder:decoder];
  793 + if (!self) {
  794 + return nil;
  795 + }
  796 +
  797 + self.responseSerializers = [decoder decodeObjectOfClass:[NSArray class] forKey:NSStringFromSelector(@selector(responseSerializers))];
  798 +
  799 + return self;
  800 +}
  801 +
  802 +- (void)encodeWithCoder:(NSCoder *)coder {
  803 + [super encodeWithCoder:coder];
  804 +
  805 + [coder encodeObject:self.responseSerializers forKey:NSStringFromSelector(@selector(responseSerializers))];
  806 +}
  807 +
  808 +#pragma mark - NSCopying
  809 +
  810 +- (instancetype)copyWithZone:(NSZone *)zone {
  811 + AFCompoundResponseSerializer *serializer = [super copyWithZone:zone];
  812 + serializer.responseSerializers = self.responseSerializers;
  813 +
  814 + return serializer;
  815 +}
  816 +
  817 +@end
... ...
Example/Pods/AFNetworking/AFNetworking/AFURLSessionManager.h 0 → 100644
  1 +// AFURLSessionManager.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 +
  23 +#import <Foundation/Foundation.h>
  24 +
  25 +#import "AFURLResponseSerialization.h"
  26 +#import "AFURLRequestSerialization.h"
  27 +#import "AFSecurityPolicy.h"
  28 +#import "AFCompatibilityMacros.h"
  29 +#if !TARGET_OS_WATCH
  30 +#import "AFNetworkReachabilityManager.h"
  31 +#endif
  32 +
  33 +/**
  34 + `AFURLSessionManager` creates and manages an `NSURLSession` object based on a specified `NSURLSessionConfiguration` object, which conforms to `<NSURLSessionTaskDelegate>`, `<NSURLSessionDataDelegate>`, `<NSURLSessionDownloadDelegate>`, and `<NSURLSessionDelegate>`.
  35 +
  36 + ## Subclassing Notes
  37 +
  38 + This is the base class for `AFHTTPSessionManager`, which adds functionality specific to making HTTP requests. If you are looking to extend `AFURLSessionManager` specifically for HTTP, consider subclassing `AFHTTPSessionManager` instead.
  39 +
  40 + ## NSURLSession & NSURLSessionTask Delegate Methods
  41 +
  42 + `AFURLSessionManager` implements the following delegate methods:
  43 +
  44 + ### `NSURLSessionDelegate`
  45 +
  46 + - `URLSession:didBecomeInvalidWithError:`
  47 + - `URLSession:didReceiveChallenge:completionHandler:`
  48 + - `URLSessionDidFinishEventsForBackgroundURLSession:`
  49 +
  50 + ### `NSURLSessionTaskDelegate`
  51 +
  52 + - `URLSession:willPerformHTTPRedirection:newRequest:completionHandler:`
  53 + - `URLSession:task:didReceiveChallenge:completionHandler:`
  54 + - `URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:`
  55 + - `URLSession:task:needNewBodyStream:`
  56 + - `URLSession:task:didCompleteWithError:`
  57 +
  58 + ### `NSURLSessionDataDelegate`
  59 +
  60 + - `URLSession:dataTask:didReceiveResponse:completionHandler:`
  61 + - `URLSession:dataTask:didBecomeDownloadTask:`
  62 + - `URLSession:dataTask:didReceiveData:`
  63 + - `URLSession:dataTask:willCacheResponse:completionHandler:`
  64 +
  65 + ### `NSURLSessionDownloadDelegate`
  66 +
  67 + - `URLSession:downloadTask:didFinishDownloadingToURL:`
  68 + - `URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesWritten:totalBytesExpectedToWrite:`
  69 + - `URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:`
  70 +
  71 + If any of these methods are overridden in a subclass, they _must_ call the `super` implementation first.
  72 +
  73 + ## Network Reachability Monitoring
  74 +
  75 + Network reachability status and change monitoring is available through the `reachabilityManager` property. Applications may choose to monitor network reachability conditions in order to prevent or suspend any outbound requests. See `AFNetworkReachabilityManager` for more details.
  76 +
  77 + ## NSCoding Caveats
  78 +
  79 + - Encoded managers do not include any block properties. Be sure to set delegate callback blocks when using `-initWithCoder:` or `NSKeyedUnarchiver`.
  80 +
  81 + ## NSCopying Caveats
  82 +
  83 + - `-copy` and `-copyWithZone:` return a new manager with a new `NSURLSession` created from the configuration of the original.
  84 + - Operation copies do not include any delegate callback blocks, as they often strongly captures a reference to `self`, which would otherwise have the unintuitive side-effect of pointing to the _original_ session manager when copied.
  85 +
  86 + @warning Managers for background sessions must be owned for the duration of their use. This can be accomplished by creating an application-wide or shared singleton instance.
  87 + */
  88 +
  89 +NS_ASSUME_NONNULL_BEGIN
  90 +
  91 +@interface AFURLSessionManager : NSObject <NSURLSessionDelegate, NSURLSessionTaskDelegate, NSURLSessionDataDelegate, NSURLSessionDownloadDelegate, NSSecureCoding, NSCopying>
  92 +
  93 +/**
  94 + The managed session.
  95 + */
  96 +@property (readonly, nonatomic, strong) NSURLSession *session;
  97 +
  98 +/**
  99 + The operation queue on which delegate callbacks are run.
  100 + */
  101 +@property (readonly, nonatomic, strong) NSOperationQueue *operationQueue;
  102 +
  103 +/**
  104 + Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an instance of `AFJSONResponseSerializer`.
  105 +
  106 + @warning `responseSerializer` must not be `nil`.
  107 + */
  108 +@property (nonatomic, strong) id <AFURLResponseSerialization> responseSerializer;
  109 +
  110 +///-------------------------------
  111 +/// @name Managing Security Policy
  112 +///-------------------------------
  113 +
  114 +/**
  115 + The security policy used by created session to evaluate server trust for secure connections. `AFURLSessionManager` uses the `defaultPolicy` unless otherwise specified.
  116 + */
  117 +@property (nonatomic, strong) AFSecurityPolicy *securityPolicy;
  118 +
  119 +#if !TARGET_OS_WATCH
  120 +///--------------------------------------
  121 +/// @name Monitoring Network Reachability
  122 +///--------------------------------------
  123 +
  124 +/**
  125 + The network reachability manager. `AFURLSessionManager` uses the `sharedManager` by default.
  126 + */
  127 +@property (readwrite, nonatomic, strong) AFNetworkReachabilityManager *reachabilityManager;
  128 +#endif
  129 +
  130 +///----------------------------
  131 +/// @name Getting Session Tasks
  132 +///----------------------------
  133 +
  134 +/**
  135 + The data, upload, and download tasks currently run by the managed session.
  136 + */
  137 +@property (readonly, nonatomic, strong) NSArray <NSURLSessionTask *> *tasks;
  138 +
  139 +/**
  140 + The data tasks currently run by the managed session.
  141 + */
  142 +@property (readonly, nonatomic, strong) NSArray <NSURLSessionDataTask *> *dataTasks;
  143 +
  144 +/**
  145 + The upload tasks currently run by the managed session.
  146 + */
  147 +@property (readonly, nonatomic, strong) NSArray <NSURLSessionUploadTask *> *uploadTasks;
  148 +
  149 +/**
  150 + The download tasks currently run by the managed session.
  151 + */
  152 +@property (readonly, nonatomic, strong) NSArray <NSURLSessionDownloadTask *> *downloadTasks;
  153 +
  154 +///-------------------------------
  155 +/// @name Managing Callback Queues
  156 +///-------------------------------
  157 +
  158 +/**
  159 + The dispatch queue for `completionBlock`. If `NULL` (default), the main queue is used.
  160 + */
  161 +@property (nonatomic, strong, nullable) dispatch_queue_t completionQueue;
  162 +
  163 +/**
  164 + The dispatch group for `completionBlock`. If `NULL` (default), a private dispatch group is used.
  165 + */
  166 +@property (nonatomic, strong, nullable) dispatch_group_t completionGroup;
  167 +
  168 +///---------------------------------
  169 +/// @name Working Around System Bugs
  170 +///---------------------------------
  171 +
  172 +/**
  173 + Whether to attempt to retry creation of upload tasks for background sessions when initial call returns `nil`. `NO` by default.
  174 +
  175 + @bug As of iOS 7.0, there is a bug where upload tasks created for background tasks are sometimes `nil`. As a workaround, if this property is `YES`, AFNetworking will follow Apple's recommendation to try creating the task again.
  176 +
  177 + @see https://github.com/AFNetworking/AFNetworking/issues/1675
  178 + */
  179 +@property (nonatomic, assign) BOOL attemptsToRecreateUploadTasksForBackgroundSessions;
  180 +
  181 +///---------------------
  182 +/// @name Initialization
  183 +///---------------------
  184 +
  185 +/**
  186 + Creates and returns a manager for a session created with the specified configuration. This is the designated initializer.
  187 +
  188 + @param configuration The configuration used to create the managed session.
  189 +
  190 + @return A manager for a newly-created session.
  191 + */
  192 +- (instancetype)initWithSessionConfiguration:(nullable NSURLSessionConfiguration *)configuration NS_DESIGNATED_INITIALIZER;
  193 +
  194 +/**
  195 + Invalidates the managed session, optionally canceling pending tasks.
  196 +
  197 + @param cancelPendingTasks Whether or not to cancel pending tasks.
  198 + */
  199 +- (void)invalidateSessionCancelingTasks:(BOOL)cancelPendingTasks;
  200 +
  201 +///-------------------------
  202 +/// @name Running Data Tasks
  203 +///-------------------------
  204 +
  205 +/**
  206 + Creates an `NSURLSessionDataTask` with the specified request.
  207 +
  208 + @param request The HTTP request for the request.
  209 + @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any.
  210 + */
  211 +- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request
  212 + completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler DEPRECATED_ATTRIBUTE;
  213 +
  214 +/**
  215 + Creates an `NSURLSessionDataTask` with the specified request.
  216 +
  217 + @param request The HTTP request for the request.
  218 + @param uploadProgressBlock A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.
  219 + @param downloadProgressBlock A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue.
  220 + @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any.
  221 + */
  222 +- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request
  223 + uploadProgress:(nullable void (^)(NSProgress *uploadProgress))uploadProgressBlock
  224 + downloadProgress:(nullable void (^)(NSProgress *downloadProgress))downloadProgressBlock
  225 + completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler;
  226 +
  227 +///---------------------------
  228 +/// @name Running Upload Tasks
  229 +///---------------------------
  230 +
  231 +/**
  232 + Creates an `NSURLSessionUploadTask` with the specified request for a local file.
  233 +
  234 + @param request The HTTP request for the request.
  235 + @param fileURL A URL to the local file to be uploaded.
  236 + @param uploadProgressBlock A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.
  237 + @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any.
  238 +
  239 + @see `attemptsToRecreateUploadTasksForBackgroundSessions`
  240 + */
  241 +- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request
  242 + fromFile:(NSURL *)fileURL
  243 + progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgressBlock
  244 + completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler;
  245 +
  246 +/**
  247 + Creates an `NSURLSessionUploadTask` with the specified request for an HTTP body.
  248 +
  249 + @param request The HTTP request for the request.
  250 + @param bodyData A data object containing the HTTP body to be uploaded.
  251 + @param uploadProgressBlock A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.
  252 + @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any.
  253 + */
  254 +- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request
  255 + fromData:(nullable NSData *)bodyData
  256 + progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgressBlock
  257 + completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler;
  258 +
  259 +/**
  260 + Creates an `NSURLSessionUploadTask` with the specified streaming request.
  261 +
  262 + @param request The HTTP request for the request.
  263 + @param uploadProgressBlock A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.
  264 + @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any.
  265 + */
  266 +- (NSURLSessionUploadTask *)uploadTaskWithStreamedRequest:(NSURLRequest *)request
  267 + progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgressBlock
  268 + completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler;
  269 +
  270 +///-----------------------------
  271 +/// @name Running Download Tasks
  272 +///-----------------------------
  273 +
  274 +/**
  275 + Creates an `NSURLSessionDownloadTask` with the specified request.
  276 +
  277 + @param request The HTTP request for the request.
  278 + @param downloadProgressBlock A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue.
  279 + @param destination A block object to be executed in order to determine the destination of the downloaded file. This block takes two arguments, the target path & the server response, and returns the desired file URL of the resulting download. The temporary file used during the download will be automatically deleted after being moved to the returned URL.
  280 + @param completionHandler A block to be executed when a task finishes. This block has no return value and takes three arguments: the server response, the path of the downloaded file, and the error describing the network or parsing error that occurred, if any.
  281 +
  282 + @warning If using a background `NSURLSessionConfiguration` on iOS, these blocks will be lost when the app is terminated. Background sessions may prefer to use `-setDownloadTaskDidFinishDownloadingBlock:` to specify the URL for saving the downloaded file, rather than the destination block of this method.
  283 + */
  284 +- (NSURLSessionDownloadTask *)downloadTaskWithRequest:(NSURLRequest *)request
  285 + progress:(nullable void (^)(NSProgress *downloadProgress))downloadProgressBlock
  286 + destination:(nullable NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination
  287 + completionHandler:(nullable void (^)(NSURLResponse *response, NSURL * _Nullable filePath, NSError * _Nullable error))completionHandler;
  288 +
  289 +/**
  290 + Creates an `NSURLSessionDownloadTask` with the specified resume data.
  291 +
  292 + @param resumeData The data used to resume downloading.
  293 + @param downloadProgressBlock A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue.
  294 + @param destination A block object to be executed in order to determine the destination of the downloaded file. This block takes two arguments, the target path & the server response, and returns the desired file URL of the resulting download. The temporary file used during the download will be automatically deleted after being moved to the returned URL.
  295 + @param completionHandler A block to be executed when a task finishes. This block has no return value and takes three arguments: the server response, the path of the downloaded file, and the error describing the network or parsing error that occurred, if any.
  296 + */
  297 +- (NSURLSessionDownloadTask *)downloadTaskWithResumeData:(NSData *)resumeData
  298 + progress:(nullable void (^)(NSProgress *downloadProgress))downloadProgressBlock
  299 + destination:(nullable NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination
  300 + completionHandler:(nullable void (^)(NSURLResponse *response, NSURL * _Nullable filePath, NSError * _Nullable error))completionHandler;
  301 +
  302 +///---------------------------------
  303 +/// @name Getting Progress for Tasks
  304 +///---------------------------------
  305 +
  306 +/**
  307 + Returns the upload progress of the specified task.
  308 +
  309 + @param task The session task. Must not be `nil`.
  310 +
  311 + @return An `NSProgress` object reporting the upload progress of a task, or `nil` if the progress is unavailable.
  312 + */
  313 +- (nullable NSProgress *)uploadProgressForTask:(NSURLSessionTask *)task;
  314 +
  315 +/**
  316 + Returns the download progress of the specified task.
  317 +
  318 + @param task The session task. Must not be `nil`.
  319 +
  320 + @return An `NSProgress` object reporting the download progress of a task, or `nil` if the progress is unavailable.
  321 + */
  322 +- (nullable NSProgress *)downloadProgressForTask:(NSURLSessionTask *)task;
  323 +
  324 +///-----------------------------------------
  325 +/// @name Setting Session Delegate Callbacks
  326 +///-----------------------------------------
  327 +
  328 +/**
  329 + Sets a block to be executed when the managed session becomes invalid, as handled by the `NSURLSessionDelegate` method `URLSession:didBecomeInvalidWithError:`.
  330 +
  331 + @param block A block object to be executed when the managed session becomes invalid. The block has no return value, and takes two arguments: the session, and the error related to the cause of invalidation.
  332 + */
  333 +- (void)setSessionDidBecomeInvalidBlock:(nullable void (^)(NSURLSession *session, NSError *error))block;
  334 +
  335 +/**
  336 + Sets a block to be executed when a connection level authentication challenge has occurred, as handled by the `NSURLSessionDelegate` method `URLSession:didReceiveChallenge:completionHandler:`.
  337 +
  338 + @param block A block object to be executed when a connection level authentication challenge has occurred. The block returns the disposition of the authentication challenge, and takes three arguments: the session, the authentication challenge, and a pointer to the credential that should be used to resolve the challenge.
  339 + */
  340 +- (void)setSessionDidReceiveAuthenticationChallengeBlock:(nullable NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * _Nullable __autoreleasing * _Nullable credential))block;
  341 +
  342 +///--------------------------------------
  343 +/// @name Setting Task Delegate Callbacks
  344 +///--------------------------------------
  345 +
  346 +/**
  347 + Sets a block to be executed when a task requires a new request body stream to send to the remote server, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:needNewBodyStream:`.
  348 +
  349 + @param block A block object to be executed when a task requires a new request body stream.
  350 + */
  351 +- (void)setTaskNeedNewBodyStreamBlock:(nullable NSInputStream * (^)(NSURLSession *session, NSURLSessionTask *task))block;
  352 +
  353 +/**
  354 + Sets a block to be executed when an HTTP request is attempting to perform a redirection to a different URL, as handled by the `NSURLSessionTaskDelegate` method `URLSession:willPerformHTTPRedirection:newRequest:completionHandler:`.
  355 +
  356 + @param block A block object to be executed when an HTTP request is attempting to perform a redirection to a different URL. The block returns the request to be made for the redirection, and takes four arguments: the session, the task, the redirection response, and the request corresponding to the redirection response.
  357 + */
  358 +- (void)setTaskWillPerformHTTPRedirectionBlock:(nullable NSURLRequest * _Nullable (^)(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request))block;
  359 +
  360 +/**
  361 + Sets a block to be executed when a session task has received a request specific authentication challenge, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didReceiveChallenge:completionHandler:`.
  362 +
  363 + @param block A block object to be executed when a session task has received a request specific authentication challenge. The block returns the disposition of the authentication challenge, and takes four arguments: the session, the task, the authentication challenge, and a pointer to the credential that should be used to resolve the challenge.
  364 + */
  365 +- (void)setTaskDidReceiveAuthenticationChallengeBlock:(nullable NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, NSURLCredential * _Nullable __autoreleasing * _Nullable credential))block;
  366 +
  367 +/**
  368 + Sets a block to be executed periodically to track upload progress, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:`.
  369 +
  370 + @param block A block object to be called when an undetermined number of bytes have been uploaded to the server. This block has no return value and takes five arguments: the session, the task, the number of bytes written since the last time the upload progress block was called, the total bytes written, and the total bytes expected to be written during the request, as initially determined by the length of the HTTP body. This block may be called multiple times, and will execute on the main thread.
  371 + */
  372 +- (void)setTaskDidSendBodyDataBlock:(nullable void (^)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend))block;
  373 +
  374 +/**
  375 + Sets a block to be executed as the last message related to a specific task, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didCompleteWithError:`.
  376 +
  377 + @param block A block object to be executed when a session task is completed. The block has no return value, and takes three arguments: the session, the task, and any error that occurred in the process of executing the task.
  378 + */
  379 +- (void)setTaskDidCompleteBlock:(nullable void (^)(NSURLSession *session, NSURLSessionTask *task, NSError * _Nullable error))block;
  380 +
  381 +///-------------------------------------------
  382 +/// @name Setting Data Task Delegate Callbacks
  383 +///-------------------------------------------
  384 +
  385 +/**
  386 + Sets a block to be executed when a data task has received a response, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didReceiveResponse:completionHandler:`.
  387 +
  388 + @param block A block object to be executed when a data task has received a response. The block returns the disposition of the session response, and takes three arguments: the session, the data task, and the received response.
  389 + */
  390 +- (void)setDataTaskDidReceiveResponseBlock:(nullable NSURLSessionResponseDisposition (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response))block;
  391 +
  392 +/**
  393 + Sets a block to be executed when a data task has become a download task, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didBecomeDownloadTask:`.
  394 +
  395 + @param block A block object to be executed when a data task has become a download task. The block has no return value, and takes three arguments: the session, the data task, and the download task it has become.
  396 + */
  397 +- (void)setDataTaskDidBecomeDownloadTaskBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask))block;
  398 +
  399 +/**
  400 + Sets a block to be executed when a data task receives data, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didReceiveData:`.
  401 +
  402 + @param block A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the session, the data task, and the data received. This block may be called multiple times, and will execute on the session manager operation queue.
  403 + */
  404 +- (void)setDataTaskDidReceiveDataBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data))block;
  405 +
  406 +/**
  407 + Sets a block to be executed to determine the caching behavior of a data task, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:willCacheResponse:completionHandler:`.
  408 +
  409 + @param block A block object to be executed to determine the caching behavior of a data task. The block returns the response to cache, and takes three arguments: the session, the data task, and the proposed cached URL response.
  410 + */
  411 +- (void)setDataTaskWillCacheResponseBlock:(nullable NSCachedURLResponse * (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSCachedURLResponse *proposedResponse))block;
  412 +
  413 +/**
  414 + Sets a block to be executed once all messages enqueued for a session have been delivered, as handled by the `NSURLSessionDataDelegate` method `URLSessionDidFinishEventsForBackgroundURLSession:`.
  415 +
  416 + @param block A block object to be executed once all messages enqueued for a session have been delivered. The block has no return value and takes a single argument: the session.
  417 + */
  418 +- (void)setDidFinishEventsForBackgroundURLSessionBlock:(nullable void (^)(NSURLSession *session))block AF_API_UNAVAILABLE(macos);
  419 +
  420 +///-----------------------------------------------
  421 +/// @name Setting Download Task Delegate Callbacks
  422 +///-----------------------------------------------
  423 +
  424 +/**
  425 + Sets a block to be executed when a download task has completed a download, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didFinishDownloadingToURL:`.
  426 +
  427 + @param block A block object to be executed when a download task has completed. The block returns the URL the download should be moved to, and takes three arguments: the session, the download task, and the temporary location of the downloaded file. If the file manager encounters an error while attempting to move the temporary file to the destination, an `AFURLSessionDownloadTaskDidFailToMoveFileNotification` will be posted, with the download task as its object, and the user info of the error.
  428 + */
  429 +- (void)setDownloadTaskDidFinishDownloadingBlock:(nullable NSURL * _Nullable (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location))block;
  430 +
  431 +/**
  432 + Sets a block to be executed periodically to track download progress, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesWritten:totalBytesExpectedToWrite:`.
  433 +
  434 + @param block A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes five arguments: the session, the download task, the number of bytes read since the last time the download progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times, and will execute on the session manager operation queue.
  435 + */
  436 +- (void)setDownloadTaskDidWriteDataBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite))block;
  437 +
  438 +/**
  439 + Sets a block to be executed when a download task has been resumed, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:`.
  440 +
  441 + @param block A block object to be executed when a download task has been resumed. The block has no return value and takes four arguments: the session, the download task, the file offset of the resumed download, and the total number of bytes expected to be downloaded.
  442 + */
  443 +- (void)setDownloadTaskDidResumeBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOffset, int64_t expectedTotalBytes))block;
  444 +
  445 +@end
  446 +
  447 +///--------------------
  448 +/// @name Notifications
  449 +///--------------------
  450 +
  451 +/**
  452 + Posted when a task resumes.
  453 + */
  454 +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidResumeNotification;
  455 +
  456 +/**
  457 + Posted when a task finishes executing. Includes a userInfo dictionary with additional information about the task.
  458 + */
  459 +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteNotification;
  460 +
  461 +/**
  462 + Posted when a task suspends its execution.
  463 + */
  464 +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidSuspendNotification;
  465 +
  466 +/**
  467 + Posted when a session is invalidated.
  468 + */
  469 +FOUNDATION_EXPORT NSString * const AFURLSessionDidInvalidateNotification;
  470 +
  471 +/**
  472 + Posted when a session download task encountered an error when moving the temporary download file to a specified destination.
  473 + */
  474 +FOUNDATION_EXPORT NSString * const AFURLSessionDownloadTaskDidFailToMoveFileNotification;
  475 +
  476 +/**
  477 + The raw response data of the task. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteNotification` if response data exists for the task.
  478 + */
  479 +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteResponseDataKey;
  480 +
  481 +/**
  482 + The serialized response object of the task. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteNotification` if the response was serialized.
  483 + */
  484 +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteSerializedResponseKey;
  485 +
  486 +/**
  487 + The response serializer used to serialize the response. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteNotification` if the task has an associated response serializer.
  488 + */
  489 +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteResponseSerializerKey;
  490 +
  491 +/**
  492 + The file path associated with the download task. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteNotification` if an the response data has been stored directly to disk.
  493 + */
  494 +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteAssetPathKey;
  495 +
  496 +/**
  497 + Any error associated with the task, or the serialization of the response. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteNotification` if an error exists.
  498 + */
  499 +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteErrorKey;
  500 +
  501 +NS_ASSUME_NONNULL_END
... ...
Example/Pods/AFNetworking/AFNetworking/AFURLSessionManager.m 0 → 100644
  1 +// AFURLSessionManager.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 "AFURLSessionManager.h"
  23 +#import <objc/runtime.h>
  24 +
  25 +#ifndef NSFoundationVersionNumber_iOS_8_0
  26 +#define NSFoundationVersionNumber_With_Fixed_5871104061079552_bug 1140.11
  27 +#else
  28 +#define NSFoundationVersionNumber_With_Fixed_5871104061079552_bug NSFoundationVersionNumber_iOS_8_0
  29 +#endif
  30 +
  31 +static dispatch_queue_t url_session_manager_creation_queue() {
  32 + static dispatch_queue_t af_url_session_manager_creation_queue;
  33 + static dispatch_once_t onceToken;
  34 + dispatch_once(&onceToken, ^{
  35 + af_url_session_manager_creation_queue = dispatch_queue_create("com.alamofire.networking.session.manager.creation", DISPATCH_QUEUE_SERIAL);
  36 + });
  37 +
  38 + return af_url_session_manager_creation_queue;
  39 +}
  40 +
  41 +static void url_session_manager_create_task_safely(dispatch_block_t block) {
  42 + if (NSFoundationVersionNumber < NSFoundationVersionNumber_With_Fixed_5871104061079552_bug) {
  43 + // Fix of bug
  44 + // Open Radar:http://openradar.appspot.com/radar?id=5871104061079552 (status: Fixed in iOS8)
  45 + // Issue about:https://github.com/AFNetworking/AFNetworking/issues/2093
  46 + dispatch_sync(url_session_manager_creation_queue(), block);
  47 + } else {
  48 + block();
  49 + }
  50 +}
  51 +
  52 +static dispatch_queue_t url_session_manager_processing_queue() {
  53 + static dispatch_queue_t af_url_session_manager_processing_queue;
  54 + static dispatch_once_t onceToken;
  55 + dispatch_once(&onceToken, ^{
  56 + af_url_session_manager_processing_queue = dispatch_queue_create("com.alamofire.networking.session.manager.processing", DISPATCH_QUEUE_CONCURRENT);
  57 + });
  58 +
  59 + return af_url_session_manager_processing_queue;
  60 +}
  61 +
  62 +static dispatch_group_t url_session_manager_completion_group() {
  63 + static dispatch_group_t af_url_session_manager_completion_group;
  64 + static dispatch_once_t onceToken;
  65 + dispatch_once(&onceToken, ^{
  66 + af_url_session_manager_completion_group = dispatch_group_create();
  67 + });
  68 +
  69 + return af_url_session_manager_completion_group;
  70 +}
  71 +
  72 +NSString * const AFNetworkingTaskDidResumeNotification = @"com.alamofire.networking.task.resume";
  73 +NSString * const AFNetworkingTaskDidCompleteNotification = @"com.alamofire.networking.task.complete";
  74 +NSString * const AFNetworkingTaskDidSuspendNotification = @"com.alamofire.networking.task.suspend";
  75 +NSString * const AFURLSessionDidInvalidateNotification = @"com.alamofire.networking.session.invalidate";
  76 +NSString * const AFURLSessionDownloadTaskDidFailToMoveFileNotification = @"com.alamofire.networking.session.download.file-manager-error";
  77 +
  78 +NSString * const AFNetworkingTaskDidCompleteSerializedResponseKey = @"com.alamofire.networking.task.complete.serializedresponse";
  79 +NSString * const AFNetworkingTaskDidCompleteResponseSerializerKey = @"com.alamofire.networking.task.complete.responseserializer";
  80 +NSString * const AFNetworkingTaskDidCompleteResponseDataKey = @"com.alamofire.networking.complete.finish.responsedata";
  81 +NSString * const AFNetworkingTaskDidCompleteErrorKey = @"com.alamofire.networking.task.complete.error";
  82 +NSString * const AFNetworkingTaskDidCompleteAssetPathKey = @"com.alamofire.networking.task.complete.assetpath";
  83 +
  84 +static NSString * const AFURLSessionManagerLockName = @"com.alamofire.networking.session.manager.lock";
  85 +
  86 +static NSUInteger const AFMaximumNumberOfAttemptsToRecreateBackgroundSessionUploadTask = 3;
  87 +
  88 +typedef void (^AFURLSessionDidBecomeInvalidBlock)(NSURLSession *session, NSError *error);
  89 +typedef NSURLSessionAuthChallengeDisposition (^AFURLSessionDidReceiveAuthenticationChallengeBlock)(NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential);
  90 +
  91 +typedef NSURLRequest * (^AFURLSessionTaskWillPerformHTTPRedirectionBlock)(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request);
  92 +typedef NSURLSessionAuthChallengeDisposition (^AFURLSessionTaskDidReceiveAuthenticationChallengeBlock)(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential);
  93 +typedef void (^AFURLSessionDidFinishEventsForBackgroundURLSessionBlock)(NSURLSession *session);
  94 +
  95 +typedef NSInputStream * (^AFURLSessionTaskNeedNewBodyStreamBlock)(NSURLSession *session, NSURLSessionTask *task);
  96 +typedef void (^AFURLSessionTaskDidSendBodyDataBlock)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend);
  97 +typedef void (^AFURLSessionTaskDidCompleteBlock)(NSURLSession *session, NSURLSessionTask *task, NSError *error);
  98 +
  99 +typedef NSURLSessionResponseDisposition (^AFURLSessionDataTaskDidReceiveResponseBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response);
  100 +typedef void (^AFURLSessionDataTaskDidBecomeDownloadTaskBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask);
  101 +typedef void (^AFURLSessionDataTaskDidReceiveDataBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data);
  102 +typedef NSCachedURLResponse * (^AFURLSessionDataTaskWillCacheResponseBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSCachedURLResponse *proposedResponse);
  103 +
  104 +typedef NSURL * (^AFURLSessionDownloadTaskDidFinishDownloadingBlock)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location);
  105 +typedef void (^AFURLSessionDownloadTaskDidWriteDataBlock)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite);
  106 +typedef void (^AFURLSessionDownloadTaskDidResumeBlock)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOffset, int64_t expectedTotalBytes);
  107 +typedef void (^AFURLSessionTaskProgressBlock)(NSProgress *);
  108 +
  109 +typedef void (^AFURLSessionTaskCompletionHandler)(NSURLResponse *response, id responseObject, NSError *error);
  110 +
  111 +
  112 +#pragma mark -
  113 +
  114 +@interface AFURLSessionManagerTaskDelegate : NSObject <NSURLSessionTaskDelegate, NSURLSessionDataDelegate, NSURLSessionDownloadDelegate>
  115 +- (instancetype)initWithTask:(NSURLSessionTask *)task;
  116 +@property (nonatomic, weak) AFURLSessionManager *manager;
  117 +@property (nonatomic, strong) NSMutableData *mutableData;
  118 +@property (nonatomic, strong) NSProgress *uploadProgress;
  119 +@property (nonatomic, strong) NSProgress *downloadProgress;
  120 +@property (nonatomic, copy) NSURL *downloadFileURL;
  121 +@property (nonatomic, copy) AFURLSessionDownloadTaskDidFinishDownloadingBlock downloadTaskDidFinishDownloading;
  122 +@property (nonatomic, copy) AFURLSessionTaskProgressBlock uploadProgressBlock;
  123 +@property (nonatomic, copy) AFURLSessionTaskProgressBlock downloadProgressBlock;
  124 +@property (nonatomic, copy) AFURLSessionTaskCompletionHandler completionHandler;
  125 +@end
  126 +
  127 +@implementation AFURLSessionManagerTaskDelegate
  128 +
  129 +- (instancetype)initWithTask:(NSURLSessionTask *)task {
  130 + self = [super init];
  131 + if (!self) {
  132 + return nil;
  133 + }
  134 +
  135 + _mutableData = [NSMutableData data];
  136 + _uploadProgress = [[NSProgress alloc] initWithParent:nil userInfo:nil];
  137 + _downloadProgress = [[NSProgress alloc] initWithParent:nil userInfo:nil];
  138 +
  139 + __weak __typeof__(task) weakTask = task;
  140 + for (NSProgress *progress in @[ _uploadProgress, _downloadProgress ])
  141 + {
  142 + progress.totalUnitCount = NSURLSessionTransferSizeUnknown;
  143 + progress.cancellable = YES;
  144 + progress.cancellationHandler = ^{
  145 + [weakTask cancel];
  146 + };
  147 + progress.pausable = YES;
  148 + progress.pausingHandler = ^{
  149 + [weakTask suspend];
  150 + };
  151 +#if AF_CAN_USE_AT_AVAILABLE
  152 + if (@available(iOS 9, macOS 10.11, *))
  153 +#else
  154 + if ([progress respondsToSelector:@selector(setResumingHandler:)])
  155 +#endif
  156 + {
  157 + progress.resumingHandler = ^{
  158 + [weakTask resume];
  159 + };
  160 + }
  161 +
  162 + [progress addObserver:self
  163 + forKeyPath:NSStringFromSelector(@selector(fractionCompleted))
  164 + options:NSKeyValueObservingOptionNew
  165 + context:NULL];
  166 + }
  167 + return self;
  168 +}
  169 +
  170 +- (void)dealloc {
  171 + [self.downloadProgress removeObserver:self forKeyPath:NSStringFromSelector(@selector(fractionCompleted))];
  172 + [self.uploadProgress removeObserver:self forKeyPath:NSStringFromSelector(@selector(fractionCompleted))];
  173 +}
  174 +
  175 +#pragma mark - NSProgress Tracking
  176 +
  177 +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString *,id> *)change context:(void *)context {
  178 + if ([object isEqual:self.downloadProgress]) {
  179 + if (self.downloadProgressBlock) {
  180 + self.downloadProgressBlock(object);
  181 + }
  182 + }
  183 + else if ([object isEqual:self.uploadProgress]) {
  184 + if (self.uploadProgressBlock) {
  185 + self.uploadProgressBlock(object);
  186 + }
  187 + }
  188 +}
  189 +
  190 +#pragma mark - NSURLSessionTaskDelegate
  191 +
  192 +- (void)URLSession:(__unused NSURLSession *)session
  193 + task:(NSURLSessionTask *)task
  194 +didCompleteWithError:(NSError *)error
  195 +{
  196 + __strong AFURLSessionManager *manager = self.manager;
  197 +
  198 + __block id responseObject = nil;
  199 +
  200 + __block NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
  201 + userInfo[AFNetworkingTaskDidCompleteResponseSerializerKey] = manager.responseSerializer;
  202 +
  203 + //Performance Improvement from #2672
  204 + NSData *data = nil;
  205 + if (self.mutableData) {
  206 + data = [self.mutableData copy];
  207 + //We no longer need the reference, so nil it out to gain back some memory.
  208 + self.mutableData = nil;
  209 + }
  210 +
  211 + if (self.downloadFileURL) {
  212 + userInfo[AFNetworkingTaskDidCompleteAssetPathKey] = self.downloadFileURL;
  213 + } else if (data) {
  214 + userInfo[AFNetworkingTaskDidCompleteResponseDataKey] = data;
  215 + }
  216 +
  217 + if (error) {
  218 + userInfo[AFNetworkingTaskDidCompleteErrorKey] = error;
  219 +
  220 + dispatch_group_async(manager.completionGroup ?: url_session_manager_completion_group(), manager.completionQueue ?: dispatch_get_main_queue(), ^{
  221 + if (self.completionHandler) {
  222 + self.completionHandler(task.response, responseObject, error);
  223 + }
  224 +
  225 + dispatch_async(dispatch_get_main_queue(), ^{
  226 + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidCompleteNotification object:task userInfo:userInfo];
  227 + });
  228 + });
  229 + } else {
  230 + dispatch_async(url_session_manager_processing_queue(), ^{
  231 + NSError *serializationError = nil;
  232 + responseObject = [manager.responseSerializer responseObjectForResponse:task.response data:data error:&serializationError];
  233 +
  234 + if (self.downloadFileURL) {
  235 + responseObject = self.downloadFileURL;
  236 + }
  237 +
  238 + if (responseObject) {
  239 + userInfo[AFNetworkingTaskDidCompleteSerializedResponseKey] = responseObject;
  240 + }
  241 +
  242 + if (serializationError) {
  243 + userInfo[AFNetworkingTaskDidCompleteErrorKey] = serializationError;
  244 + }
  245 +
  246 + dispatch_group_async(manager.completionGroup ?: url_session_manager_completion_group(), manager.completionQueue ?: dispatch_get_main_queue(), ^{
  247 + if (self.completionHandler) {
  248 + self.completionHandler(task.response, responseObject, serializationError);
  249 + }
  250 +
  251 + dispatch_async(dispatch_get_main_queue(), ^{
  252 + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidCompleteNotification object:task userInfo:userInfo];
  253 + });
  254 + });
  255 + });
  256 + }
  257 +}
  258 +
  259 +#pragma mark - NSURLSessionDataDelegate
  260 +
  261 +- (void)URLSession:(__unused NSURLSession *)session
  262 + dataTask:(__unused NSURLSessionDataTask *)dataTask
  263 + didReceiveData:(NSData *)data
  264 +{
  265 + self.downloadProgress.totalUnitCount = dataTask.countOfBytesExpectedToReceive;
  266 + self.downloadProgress.completedUnitCount = dataTask.countOfBytesReceived;
  267 +
  268 + [self.mutableData appendData:data];
  269 +}
  270 +
  271 +- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task
  272 + didSendBodyData:(int64_t)bytesSent
  273 + totalBytesSent:(int64_t)totalBytesSent
  274 +totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend{
  275 +
  276 + self.uploadProgress.totalUnitCount = task.countOfBytesExpectedToSend;
  277 + self.uploadProgress.completedUnitCount = task.countOfBytesSent;
  278 +}
  279 +
  280 +#pragma mark - NSURLSessionDownloadDelegate
  281 +
  282 +- (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask
  283 + didWriteData:(int64_t)bytesWritten
  284 + totalBytesWritten:(int64_t)totalBytesWritten
  285 +totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite{
  286 +
  287 + self.downloadProgress.totalUnitCount = totalBytesExpectedToWrite;
  288 + self.downloadProgress.completedUnitCount = totalBytesWritten;
  289 +}
  290 +
  291 +- (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask
  292 + didResumeAtOffset:(int64_t)fileOffset
  293 +expectedTotalBytes:(int64_t)expectedTotalBytes{
  294 +
  295 + self.downloadProgress.totalUnitCount = expectedTotalBytes;
  296 + self.downloadProgress.completedUnitCount = fileOffset;
  297 +}
  298 +
  299 +- (void)URLSession:(NSURLSession *)session
  300 + downloadTask:(NSURLSessionDownloadTask *)downloadTask
  301 +didFinishDownloadingToURL:(NSURL *)location
  302 +{
  303 + self.downloadFileURL = nil;
  304 +
  305 + if (self.downloadTaskDidFinishDownloading) {
  306 + self.downloadFileURL = self.downloadTaskDidFinishDownloading(session, downloadTask, location);
  307 + if (self.downloadFileURL) {
  308 + NSError *fileManagerError = nil;
  309 +
  310 + if (![[NSFileManager defaultManager] moveItemAtURL:location toURL:self.downloadFileURL error:&fileManagerError]) {
  311 + [[NSNotificationCenter defaultCenter] postNotificationName:AFURLSessionDownloadTaskDidFailToMoveFileNotification object:downloadTask userInfo:fileManagerError.userInfo];
  312 + }
  313 + }
  314 + }
  315 +}
  316 +
  317 +@end
  318 +
  319 +#pragma mark -
  320 +
  321 +/**
  322 + * A workaround for issues related to key-value observing the `state` of an `NSURLSessionTask`.
  323 + *
  324 + * See:
  325 + * - https://github.com/AFNetworking/AFNetworking/issues/1477
  326 + * - https://github.com/AFNetworking/AFNetworking/issues/2638
  327 + * - https://github.com/AFNetworking/AFNetworking/pull/2702
  328 + */
  329 +
  330 +static inline void af_swizzleSelector(Class theClass, SEL originalSelector, SEL swizzledSelector) {
  331 + Method originalMethod = class_getInstanceMethod(theClass, originalSelector);
  332 + Method swizzledMethod = class_getInstanceMethod(theClass, swizzledSelector);
  333 + method_exchangeImplementations(originalMethod, swizzledMethod);
  334 +}
  335 +
  336 +static inline BOOL af_addMethod(Class theClass, SEL selector, Method method) {
  337 + return class_addMethod(theClass, selector, method_getImplementation(method), method_getTypeEncoding(method));
  338 +}
  339 +
  340 +static NSString * const AFNSURLSessionTaskDidResumeNotification = @"com.alamofire.networking.nsurlsessiontask.resume";
  341 +static NSString * const AFNSURLSessionTaskDidSuspendNotification = @"com.alamofire.networking.nsurlsessiontask.suspend";
  342 +
  343 +@interface _AFURLSessionTaskSwizzling : NSObject
  344 +
  345 +@end
  346 +
  347 +@implementation _AFURLSessionTaskSwizzling
  348 +
  349 ++ (void)load {
  350 + /**
  351 + WARNING: Trouble Ahead
  352 + https://github.com/AFNetworking/AFNetworking/pull/2702
  353 + */
  354 +
  355 + if (NSClassFromString(@"NSURLSessionTask")) {
  356 + /**
  357 + iOS 7 and iOS 8 differ in NSURLSessionTask implementation, which makes the next bit of code a bit tricky.
  358 + Many Unit Tests have been built to validate as much of this behavior has possible.
  359 + Here is what we know:
  360 + - NSURLSessionTasks are implemented with class clusters, meaning the class you request from the API isn't actually the type of class you will get back.
  361 + - Simply referencing `[NSURLSessionTask class]` will not work. You need to ask an `NSURLSession` to actually create an object, and grab the class from there.
  362 + - On iOS 7, `localDataTask` is a `__NSCFLocalDataTask`, which inherits from `__NSCFLocalSessionTask`, which inherits from `__NSCFURLSessionTask`.
  363 + - On iOS 8, `localDataTask` is a `__NSCFLocalDataTask`, which inherits from `__NSCFLocalSessionTask`, which inherits from `NSURLSessionTask`.
  364 + - On iOS 7, `__NSCFLocalSessionTask` and `__NSCFURLSessionTask` are the only two classes that have their own implementations of `resume` and `suspend`, and `__NSCFLocalSessionTask` DOES NOT CALL SUPER. This means both classes need to be swizzled.
  365 + - On iOS 8, `NSURLSessionTask` is the only class that implements `resume` and `suspend`. This means this is the only class that needs to be swizzled.
  366 + - Because `NSURLSessionTask` is not involved in the class hierarchy for every version of iOS, its easier to add the swizzled methods to a dummy class and manage them there.
  367 +
  368 + Some Assumptions:
  369 + - No implementations of `resume` or `suspend` call super. If this were to change in a future version of iOS, we'd need to handle it.
  370 + - No background task classes override `resume` or `suspend`
  371 +
  372 + The current solution:
  373 + 1) Grab an instance of `__NSCFLocalDataTask` by asking an instance of `NSURLSession` for a data task.
  374 + 2) Grab a pointer to the original implementation of `af_resume`
  375 + 3) Check to see if the current class has an implementation of resume. If so, continue to step 4.
  376 + 4) Grab the super class of the current class.
  377 + 5) Grab a pointer for the current class to the current implementation of `resume`.
  378 + 6) Grab a pointer for the super class to the current implementation of `resume`.
  379 + 7) If the current class implementation of `resume` is not equal to the super class implementation of `resume` AND the current implementation of `resume` is not equal to the original implementation of `af_resume`, THEN swizzle the methods
  380 + 8) Set the current class to the super class, and repeat steps 3-8
  381 + */
  382 + NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration ephemeralSessionConfiguration];
  383 + NSURLSession * session = [NSURLSession sessionWithConfiguration:configuration];
  384 +#pragma GCC diagnostic push
  385 +#pragma GCC diagnostic ignored "-Wnonnull"
  386 + NSURLSessionDataTask *localDataTask = [session dataTaskWithURL:nil];
  387 +#pragma clang diagnostic pop
  388 + IMP originalAFResumeIMP = method_getImplementation(class_getInstanceMethod([self class], @selector(af_resume)));
  389 + Class currentClass = [localDataTask class];
  390 +
  391 + while (class_getInstanceMethod(currentClass, @selector(resume))) {
  392 + Class superClass = [currentClass superclass];
  393 + IMP classResumeIMP = method_getImplementation(class_getInstanceMethod(currentClass, @selector(resume)));
  394 + IMP superclassResumeIMP = method_getImplementation(class_getInstanceMethod(superClass, @selector(resume)));
  395 + if (classResumeIMP != superclassResumeIMP &&
  396 + originalAFResumeIMP != classResumeIMP) {
  397 + [self swizzleResumeAndSuspendMethodForClass:currentClass];
  398 + }
  399 + currentClass = [currentClass superclass];
  400 + }
  401 +
  402 + [localDataTask cancel];
  403 + [session finishTasksAndInvalidate];
  404 + }
  405 +}
  406 +
  407 ++ (void)swizzleResumeAndSuspendMethodForClass:(Class)theClass {
  408 + Method afResumeMethod = class_getInstanceMethod(self, @selector(af_resume));
  409 + Method afSuspendMethod = class_getInstanceMethod(self, @selector(af_suspend));
  410 +
  411 + if (af_addMethod(theClass, @selector(af_resume), afResumeMethod)) {
  412 + af_swizzleSelector(theClass, @selector(resume), @selector(af_resume));
  413 + }
  414 +
  415 + if (af_addMethod(theClass, @selector(af_suspend), afSuspendMethod)) {
  416 + af_swizzleSelector(theClass, @selector(suspend), @selector(af_suspend));
  417 + }
  418 +}
  419 +
  420 +- (NSURLSessionTaskState)state {
  421 + NSAssert(NO, @"State method should never be called in the actual dummy class");
  422 + return NSURLSessionTaskStateCanceling;
  423 +}
  424 +
  425 +- (void)af_resume {
  426 + NSAssert([self respondsToSelector:@selector(state)], @"Does not respond to state");
  427 + NSURLSessionTaskState state = [self state];
  428 + [self af_resume];
  429 +
  430 + if (state != NSURLSessionTaskStateRunning) {
  431 + [[NSNotificationCenter defaultCenter] postNotificationName:AFNSURLSessionTaskDidResumeNotification object:self];
  432 + }
  433 +}
  434 +
  435 +- (void)af_suspend {
  436 + NSAssert([self respondsToSelector:@selector(state)], @"Does not respond to state");
  437 + NSURLSessionTaskState state = [self state];
  438 + [self af_suspend];
  439 +
  440 + if (state != NSURLSessionTaskStateSuspended) {
  441 + [[NSNotificationCenter defaultCenter] postNotificationName:AFNSURLSessionTaskDidSuspendNotification object:self];
  442 + }
  443 +}
  444 +@end
  445 +
  446 +#pragma mark -
  447 +
  448 +@interface AFURLSessionManager ()
  449 +@property (readwrite, nonatomic, strong) NSURLSessionConfiguration *sessionConfiguration;
  450 +@property (readwrite, nonatomic, strong) NSOperationQueue *operationQueue;
  451 +@property (readwrite, nonatomic, strong) NSURLSession *session;
  452 +@property (readwrite, nonatomic, strong) NSMutableDictionary *mutableTaskDelegatesKeyedByTaskIdentifier;
  453 +@property (readonly, nonatomic, copy) NSString *taskDescriptionForSessionTasks;
  454 +@property (readwrite, nonatomic, strong) NSLock *lock;
  455 +@property (readwrite, nonatomic, copy) AFURLSessionDidBecomeInvalidBlock sessionDidBecomeInvalid;
  456 +@property (readwrite, nonatomic, copy) AFURLSessionDidReceiveAuthenticationChallengeBlock sessionDidReceiveAuthenticationChallenge;
  457 +@property (readwrite, nonatomic, copy) AFURLSessionDidFinishEventsForBackgroundURLSessionBlock didFinishEventsForBackgroundURLSession AF_API_UNAVAILABLE(macos);
  458 +@property (readwrite, nonatomic, copy) AFURLSessionTaskWillPerformHTTPRedirectionBlock taskWillPerformHTTPRedirection;
  459 +@property (readwrite, nonatomic, copy) AFURLSessionTaskDidReceiveAuthenticationChallengeBlock taskDidReceiveAuthenticationChallenge;
  460 +@property (readwrite, nonatomic, copy) AFURLSessionTaskNeedNewBodyStreamBlock taskNeedNewBodyStream;
  461 +@property (readwrite, nonatomic, copy) AFURLSessionTaskDidSendBodyDataBlock taskDidSendBodyData;
  462 +@property (readwrite, nonatomic, copy) AFURLSessionTaskDidCompleteBlock taskDidComplete;
  463 +@property (readwrite, nonatomic, copy) AFURLSessionDataTaskDidReceiveResponseBlock dataTaskDidReceiveResponse;
  464 +@property (readwrite, nonatomic, copy) AFURLSessionDataTaskDidBecomeDownloadTaskBlock dataTaskDidBecomeDownloadTask;
  465 +@property (readwrite, nonatomic, copy) AFURLSessionDataTaskDidReceiveDataBlock dataTaskDidReceiveData;
  466 +@property (readwrite, nonatomic, copy) AFURLSessionDataTaskWillCacheResponseBlock dataTaskWillCacheResponse;
  467 +@property (readwrite, nonatomic, copy) AFURLSessionDownloadTaskDidFinishDownloadingBlock downloadTaskDidFinishDownloading;
  468 +@property (readwrite, nonatomic, copy) AFURLSessionDownloadTaskDidWriteDataBlock downloadTaskDidWriteData;
  469 +@property (readwrite, nonatomic, copy) AFURLSessionDownloadTaskDidResumeBlock downloadTaskDidResume;
  470 +@end
  471 +
  472 +@implementation AFURLSessionManager
  473 +
  474 +- (instancetype)init {
  475 + return [self initWithSessionConfiguration:nil];
  476 +}
  477 +
  478 +- (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration {
  479 + self = [super init];
  480 + if (!self) {
  481 + return nil;
  482 + }
  483 +
  484 + if (!configuration) {
  485 + configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
  486 + }
  487 +
  488 + self.sessionConfiguration = configuration;
  489 +
  490 + self.operationQueue = [[NSOperationQueue alloc] init];
  491 + self.operationQueue.maxConcurrentOperationCount = 1;
  492 +
  493 + self.session = [NSURLSession sessionWithConfiguration:self.sessionConfiguration delegate:self delegateQueue:self.operationQueue];
  494 +
  495 + self.responseSerializer = [AFJSONResponseSerializer serializer];
  496 +
  497 + self.securityPolicy = [AFSecurityPolicy defaultPolicy];
  498 +
  499 +#if !TARGET_OS_WATCH
  500 + self.reachabilityManager = [AFNetworkReachabilityManager sharedManager];
  501 +#endif
  502 +
  503 + self.mutableTaskDelegatesKeyedByTaskIdentifier = [[NSMutableDictionary alloc] init];
  504 +
  505 + self.lock = [[NSLock alloc] init];
  506 + self.lock.name = AFURLSessionManagerLockName;
  507 +
  508 + [self.session getTasksWithCompletionHandler:^(NSArray *dataTasks, NSArray *uploadTasks, NSArray *downloadTasks) {
  509 + for (NSURLSessionDataTask *task in dataTasks) {
  510 + [self addDelegateForDataTask:task uploadProgress:nil downloadProgress:nil completionHandler:nil];
  511 + }
  512 +
  513 + for (NSURLSessionUploadTask *uploadTask in uploadTasks) {
  514 + [self addDelegateForUploadTask:uploadTask progress:nil completionHandler:nil];
  515 + }
  516 +
  517 + for (NSURLSessionDownloadTask *downloadTask in downloadTasks) {
  518 + [self addDelegateForDownloadTask:downloadTask progress:nil destination:nil completionHandler:nil];
  519 + }
  520 + }];
  521 +
  522 + return self;
  523 +}
  524 +
  525 +- (void)dealloc {
  526 + [[NSNotificationCenter defaultCenter] removeObserver:self];
  527 +}
  528 +
  529 +#pragma mark -
  530 +
  531 +- (NSString *)taskDescriptionForSessionTasks {
  532 + return [NSString stringWithFormat:@"%p", self];
  533 +}
  534 +
  535 +- (void)taskDidResume:(NSNotification *)notification {
  536 + NSURLSessionTask *task = notification.object;
  537 + if ([task respondsToSelector:@selector(taskDescription)]) {
  538 + if ([task.taskDescription isEqualToString:self.taskDescriptionForSessionTasks]) {
  539 + dispatch_async(dispatch_get_main_queue(), ^{
  540 + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidResumeNotification object:task];
  541 + });
  542 + }
  543 + }
  544 +}
  545 +
  546 +- (void)taskDidSuspend:(NSNotification *)notification {
  547 + NSURLSessionTask *task = notification.object;
  548 + if ([task respondsToSelector:@selector(taskDescription)]) {
  549 + if ([task.taskDescription isEqualToString:self.taskDescriptionForSessionTasks]) {
  550 + dispatch_async(dispatch_get_main_queue(), ^{
  551 + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidSuspendNotification object:task];
  552 + });
  553 + }
  554 + }
  555 +}
  556 +
  557 +#pragma mark -
  558 +
  559 +- (AFURLSessionManagerTaskDelegate *)delegateForTask:(NSURLSessionTask *)task {
  560 + NSParameterAssert(task);
  561 +
  562 + AFURLSessionManagerTaskDelegate *delegate = nil;
  563 + [self.lock lock];
  564 + delegate = self.mutableTaskDelegatesKeyedByTaskIdentifier[@(task.taskIdentifier)];
  565 + [self.lock unlock];
  566 +
  567 + return delegate;
  568 +}
  569 +
  570 +- (void)setDelegate:(AFURLSessionManagerTaskDelegate *)delegate
  571 + forTask:(NSURLSessionTask *)task
  572 +{
  573 + NSParameterAssert(task);
  574 + NSParameterAssert(delegate);
  575 +
  576 + [self.lock lock];
  577 + self.mutableTaskDelegatesKeyedByTaskIdentifier[@(task.taskIdentifier)] = delegate;
  578 + [self addNotificationObserverForTask:task];
  579 + [self.lock unlock];
  580 +}
  581 +
  582 +- (void)addDelegateForDataTask:(NSURLSessionDataTask *)dataTask
  583 + uploadProgress:(nullable void (^)(NSProgress *uploadProgress)) uploadProgressBlock
  584 + downloadProgress:(nullable void (^)(NSProgress *downloadProgress)) downloadProgressBlock
  585 + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler
  586 +{
  587 + AFURLSessionManagerTaskDelegate *delegate = [[AFURLSessionManagerTaskDelegate alloc] initWithTask:dataTask];
  588 + delegate.manager = self;
  589 + delegate.completionHandler = completionHandler;
  590 +
  591 + dataTask.taskDescription = self.taskDescriptionForSessionTasks;
  592 + [self setDelegate:delegate forTask:dataTask];
  593 +
  594 + delegate.uploadProgressBlock = uploadProgressBlock;
  595 + delegate.downloadProgressBlock = downloadProgressBlock;
  596 +}
  597 +
  598 +- (void)addDelegateForUploadTask:(NSURLSessionUploadTask *)uploadTask
  599 + progress:(void (^)(NSProgress *uploadProgress)) uploadProgressBlock
  600 + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler
  601 +{
  602 + AFURLSessionManagerTaskDelegate *delegate = [[AFURLSessionManagerTaskDelegate alloc] initWithTask:uploadTask];
  603 + delegate.manager = self;
  604 + delegate.completionHandler = completionHandler;
  605 +
  606 + uploadTask.taskDescription = self.taskDescriptionForSessionTasks;
  607 +
  608 + [self setDelegate:delegate forTask:uploadTask];
  609 +
  610 + delegate.uploadProgressBlock = uploadProgressBlock;
  611 +}
  612 +
  613 +- (void)addDelegateForDownloadTask:(NSURLSessionDownloadTask *)downloadTask
  614 + progress:(void (^)(NSProgress *downloadProgress)) downloadProgressBlock
  615 + destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination
  616 + completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler
  617 +{
  618 + AFURLSessionManagerTaskDelegate *delegate = [[AFURLSessionManagerTaskDelegate alloc] initWithTask:downloadTask];
  619 + delegate.manager = self;
  620 + delegate.completionHandler = completionHandler;
  621 +
  622 + if (destination) {
  623 + delegate.downloadTaskDidFinishDownloading = ^NSURL * (NSURLSession * __unused session, NSURLSessionDownloadTask *task, NSURL *location) {
  624 + return destination(location, task.response);
  625 + };
  626 + }
  627 +
  628 + downloadTask.taskDescription = self.taskDescriptionForSessionTasks;
  629 +
  630 + [self setDelegate:delegate forTask:downloadTask];
  631 +
  632 + delegate.downloadProgressBlock = downloadProgressBlock;
  633 +}
  634 +
  635 +- (void)removeDelegateForTask:(NSURLSessionTask *)task {
  636 + NSParameterAssert(task);
  637 +
  638 + [self.lock lock];
  639 + [self removeNotificationObserverForTask:task];
  640 + [self.mutableTaskDelegatesKeyedByTaskIdentifier removeObjectForKey:@(task.taskIdentifier)];
  641 + [self.lock unlock];
  642 +}
  643 +
  644 +#pragma mark -
  645 +
  646 +- (NSArray *)tasksForKeyPath:(NSString *)keyPath {
  647 + __block NSArray *tasks = nil;
  648 + dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
  649 + [self.session getTasksWithCompletionHandler:^(NSArray *dataTasks, NSArray *uploadTasks, NSArray *downloadTasks) {
  650 + if ([keyPath isEqualToString:NSStringFromSelector(@selector(dataTasks))]) {
  651 + tasks = dataTasks;
  652 + } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(uploadTasks))]) {
  653 + tasks = uploadTasks;
  654 + } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(downloadTasks))]) {
  655 + tasks = downloadTasks;
  656 + } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(tasks))]) {
  657 + tasks = [@[dataTasks, uploadTasks, downloadTasks] valueForKeyPath:@"@unionOfArrays.self"];
  658 + }
  659 +
  660 + dispatch_semaphore_signal(semaphore);
  661 + }];
  662 +
  663 + dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
  664 +
  665 + return tasks;
  666 +}
  667 +
  668 +- (NSArray *)tasks {
  669 + return [self tasksForKeyPath:NSStringFromSelector(_cmd)];
  670 +}
  671 +
  672 +- (NSArray *)dataTasks {
  673 + return [self tasksForKeyPath:NSStringFromSelector(_cmd)];
  674 +}
  675 +
  676 +- (NSArray *)uploadTasks {
  677 + return [self tasksForKeyPath:NSStringFromSelector(_cmd)];
  678 +}
  679 +
  680 +- (NSArray *)downloadTasks {
  681 + return [self tasksForKeyPath:NSStringFromSelector(_cmd)];
  682 +}
  683 +
  684 +#pragma mark -
  685 +
  686 +- (void)invalidateSessionCancelingTasks:(BOOL)cancelPendingTasks {
  687 + if (cancelPendingTasks) {
  688 + [self.session invalidateAndCancel];
  689 + } else {
  690 + [self.session finishTasksAndInvalidate];
  691 + }
  692 +}
  693 +
  694 +#pragma mark -
  695 +
  696 +- (void)setResponseSerializer:(id <AFURLResponseSerialization>)responseSerializer {
  697 + NSParameterAssert(responseSerializer);
  698 +
  699 + _responseSerializer = responseSerializer;
  700 +}
  701 +
  702 +#pragma mark -
  703 +- (void)addNotificationObserverForTask:(NSURLSessionTask *)task {
  704 + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(taskDidResume:) name:AFNSURLSessionTaskDidResumeNotification object:task];
  705 + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(taskDidSuspend:) name:AFNSURLSessionTaskDidSuspendNotification object:task];
  706 +}
  707 +
  708 +- (void)removeNotificationObserverForTask:(NSURLSessionTask *)task {
  709 + [[NSNotificationCenter defaultCenter] removeObserver:self name:AFNSURLSessionTaskDidSuspendNotification object:task];
  710 + [[NSNotificationCenter defaultCenter] removeObserver:self name:AFNSURLSessionTaskDidResumeNotification object:task];
  711 +}
  712 +
  713 +#pragma mark -
  714 +
  715 +- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request
  716 + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler
  717 +{
  718 + return [self dataTaskWithRequest:request uploadProgress:nil downloadProgress:nil completionHandler:completionHandler];
  719 +}
  720 +
  721 +- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request
  722 + uploadProgress:(nullable void (^)(NSProgress *uploadProgress)) uploadProgressBlock
  723 + downloadProgress:(nullable void (^)(NSProgress *downloadProgress)) downloadProgressBlock
  724 + completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler {
  725 +
  726 + __block NSURLSessionDataTask *dataTask = nil;
  727 + url_session_manager_create_task_safely(^{
  728 + dataTask = [self.session dataTaskWithRequest:request];
  729 + });
  730 +
  731 + [self addDelegateForDataTask:dataTask uploadProgress:uploadProgressBlock downloadProgress:downloadProgressBlock completionHandler:completionHandler];
  732 +
  733 + return dataTask;
  734 +}
  735 +
  736 +#pragma mark -
  737 +
  738 +- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request
  739 + fromFile:(NSURL *)fileURL
  740 + progress:(void (^)(NSProgress *uploadProgress)) uploadProgressBlock
  741 + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler
  742 +{
  743 + __block NSURLSessionUploadTask *uploadTask = nil;
  744 + url_session_manager_create_task_safely(^{
  745 + uploadTask = [self.session uploadTaskWithRequest:request fromFile:fileURL];
  746 +
  747 + // uploadTask may be nil on iOS7 because uploadTaskWithRequest:fromFile: may return nil despite being documented as nonnull (https://devforums.apple.com/message/926113#926113)
  748 + if (!uploadTask && self.attemptsToRecreateUploadTasksForBackgroundSessions && self.session.configuration.identifier) {
  749 + for (NSUInteger attempts = 0; !uploadTask && attempts < AFMaximumNumberOfAttemptsToRecreateBackgroundSessionUploadTask; attempts++) {
  750 + uploadTask = [self.session uploadTaskWithRequest:request fromFile:fileURL];
  751 + }
  752 + }
  753 + });
  754 +
  755 + if (uploadTask) {
  756 + [self addDelegateForUploadTask:uploadTask
  757 + progress:uploadProgressBlock
  758 + completionHandler:completionHandler];
  759 + }
  760 +
  761 + return uploadTask;
  762 +}
  763 +
  764 +- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request
  765 + fromData:(NSData *)bodyData
  766 + progress:(void (^)(NSProgress *uploadProgress)) uploadProgressBlock
  767 + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler
  768 +{
  769 + __block NSURLSessionUploadTask *uploadTask = nil;
  770 + url_session_manager_create_task_safely(^{
  771 + uploadTask = [self.session uploadTaskWithRequest:request fromData:bodyData];
  772 + });
  773 +
  774 + [self addDelegateForUploadTask:uploadTask progress:uploadProgressBlock completionHandler:completionHandler];
  775 +
  776 + return uploadTask;
  777 +}
  778 +
  779 +- (NSURLSessionUploadTask *)uploadTaskWithStreamedRequest:(NSURLRequest *)request
  780 + progress:(void (^)(NSProgress *uploadProgress)) uploadProgressBlock
  781 + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler
  782 +{
  783 + __block NSURLSessionUploadTask *uploadTask = nil;
  784 + url_session_manager_create_task_safely(^{
  785 + uploadTask = [self.session uploadTaskWithStreamedRequest:request];
  786 + });
  787 +
  788 + [self addDelegateForUploadTask:uploadTask progress:uploadProgressBlock completionHandler:completionHandler];
  789 +
  790 + return uploadTask;
  791 +}
  792 +
  793 +#pragma mark -
  794 +
  795 +- (NSURLSessionDownloadTask *)downloadTaskWithRequest:(NSURLRequest *)request
  796 + progress:(void (^)(NSProgress *downloadProgress)) downloadProgressBlock
  797 + destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination
  798 + completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler
  799 +{
  800 + __block NSURLSessionDownloadTask *downloadTask = nil;
  801 + url_session_manager_create_task_safely(^{
  802 + downloadTask = [self.session downloadTaskWithRequest:request];
  803 + });
  804 +
  805 + [self addDelegateForDownloadTask:downloadTask progress:downloadProgressBlock destination:destination completionHandler:completionHandler];
  806 +
  807 + return downloadTask;
  808 +}
  809 +
  810 +- (NSURLSessionDownloadTask *)downloadTaskWithResumeData:(NSData *)resumeData
  811 + progress:(void (^)(NSProgress *downloadProgress)) downloadProgressBlock
  812 + destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination
  813 + completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler
  814 +{
  815 + __block NSURLSessionDownloadTask *downloadTask = nil;
  816 + url_session_manager_create_task_safely(^{
  817 + downloadTask = [self.session downloadTaskWithResumeData:resumeData];
  818 + });
  819 +
  820 + [self addDelegateForDownloadTask:downloadTask progress:downloadProgressBlock destination:destination completionHandler:completionHandler];
  821 +
  822 + return downloadTask;
  823 +}
  824 +
  825 +#pragma mark -
  826 +- (NSProgress *)uploadProgressForTask:(NSURLSessionTask *)task {
  827 + return [[self delegateForTask:task] uploadProgress];
  828 +}
  829 +
  830 +- (NSProgress *)downloadProgressForTask:(NSURLSessionTask *)task {
  831 + return [[self delegateForTask:task] downloadProgress];
  832 +}
  833 +
  834 +#pragma mark -
  835 +
  836 +- (void)setSessionDidBecomeInvalidBlock:(void (^)(NSURLSession *session, NSError *error))block {
  837 + self.sessionDidBecomeInvalid = block;
  838 +}
  839 +
  840 +- (void)setSessionDidReceiveAuthenticationChallengeBlock:(NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential))block {
  841 + self.sessionDidReceiveAuthenticationChallenge = block;
  842 +}
  843 +
  844 +#if !TARGET_OS_OSX
  845 +- (void)setDidFinishEventsForBackgroundURLSessionBlock:(void (^)(NSURLSession *session))block {
  846 + self.didFinishEventsForBackgroundURLSession = block;
  847 +}
  848 +#endif
  849 +
  850 +#pragma mark -
  851 +
  852 +- (void)setTaskNeedNewBodyStreamBlock:(NSInputStream * (^)(NSURLSession *session, NSURLSessionTask *task))block {
  853 + self.taskNeedNewBodyStream = block;
  854 +}
  855 +
  856 +- (void)setTaskWillPerformHTTPRedirectionBlock:(NSURLRequest * (^)(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request))block {
  857 + self.taskWillPerformHTTPRedirection = block;
  858 +}
  859 +
  860 +- (void)setTaskDidReceiveAuthenticationChallengeBlock:(NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential))block {
  861 + self.taskDidReceiveAuthenticationChallenge = block;
  862 +}
  863 +
  864 +- (void)setTaskDidSendBodyDataBlock:(void (^)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend))block {
  865 + self.taskDidSendBodyData = block;
  866 +}
  867 +
  868 +- (void)setTaskDidCompleteBlock:(void (^)(NSURLSession *session, NSURLSessionTask *task, NSError *error))block {
  869 + self.taskDidComplete = block;
  870 +}
  871 +
  872 +#pragma mark -
  873 +
  874 +- (void)setDataTaskDidReceiveResponseBlock:(NSURLSessionResponseDisposition (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response))block {
  875 + self.dataTaskDidReceiveResponse = block;
  876 +}
  877 +
  878 +- (void)setDataTaskDidBecomeDownloadTaskBlock:(void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask))block {
  879 + self.dataTaskDidBecomeDownloadTask = block;
  880 +}
  881 +
  882 +- (void)setDataTaskDidReceiveDataBlock:(void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data))block {
  883 + self.dataTaskDidReceiveData = block;
  884 +}
  885 +
  886 +- (void)setDataTaskWillCacheResponseBlock:(NSCachedURLResponse * (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSCachedURLResponse *proposedResponse))block {
  887 + self.dataTaskWillCacheResponse = block;
  888 +}
  889 +
  890 +#pragma mark -
  891 +
  892 +- (void)setDownloadTaskDidFinishDownloadingBlock:(NSURL * (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location))block {
  893 + self.downloadTaskDidFinishDownloading = block;
  894 +}
  895 +
  896 +- (void)setDownloadTaskDidWriteDataBlock:(void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite))block {
  897 + self.downloadTaskDidWriteData = block;
  898 +}
  899 +
  900 +- (void)setDownloadTaskDidResumeBlock:(void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOffset, int64_t expectedTotalBytes))block {
  901 + self.downloadTaskDidResume = block;
  902 +}
  903 +
  904 +#pragma mark - NSObject
  905 +
  906 +- (NSString *)description {
  907 + return [NSString stringWithFormat:@"<%@: %p, session: %@, operationQueue: %@>", NSStringFromClass([self class]), self, self.session, self.operationQueue];
  908 +}
  909 +
  910 +- (BOOL)respondsToSelector:(SEL)selector {
  911 + if (selector == @selector(URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:)) {
  912 + return self.taskWillPerformHTTPRedirection != nil;
  913 + } else if (selector == @selector(URLSession:dataTask:didReceiveResponse:completionHandler:)) {
  914 + return self.dataTaskDidReceiveResponse != nil;
  915 + } else if (selector == @selector(URLSession:dataTask:willCacheResponse:completionHandler:)) {
  916 + return self.dataTaskWillCacheResponse != nil;
  917 + }
  918 +#if !TARGET_OS_OSX
  919 + else if (selector == @selector(URLSessionDidFinishEventsForBackgroundURLSession:)) {
  920 + return self.didFinishEventsForBackgroundURLSession != nil;
  921 + }
  922 +#endif
  923 +
  924 + return [[self class] instancesRespondToSelector:selector];
  925 +}
  926 +
  927 +#pragma mark - NSURLSessionDelegate
  928 +
  929 +- (void)URLSession:(NSURLSession *)session
  930 +didBecomeInvalidWithError:(NSError *)error
  931 +{
  932 + if (self.sessionDidBecomeInvalid) {
  933 + self.sessionDidBecomeInvalid(session, error);
  934 + }
  935 +
  936 + [[NSNotificationCenter defaultCenter] postNotificationName:AFURLSessionDidInvalidateNotification object:session];
  937 +}
  938 +
  939 +- (void)URLSession:(NSURLSession *)session
  940 +didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge
  941 + completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler
  942 +{
  943 + NSURLSessionAuthChallengeDisposition disposition = NSURLSessionAuthChallengePerformDefaultHandling;
  944 + __block NSURLCredential *credential = nil;
  945 +
  946 + if (self.sessionDidReceiveAuthenticationChallenge) {
  947 + disposition = self.sessionDidReceiveAuthenticationChallenge(session, challenge, &credential);
  948 + } else {
  949 + if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
  950 + if ([self.securityPolicy evaluateServerTrust:challenge.protectionSpace.serverTrust forDomain:challenge.protectionSpace.host]) {
  951 + credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];
  952 + if (credential) {
  953 + disposition = NSURLSessionAuthChallengeUseCredential;
  954 + } else {
  955 + disposition = NSURLSessionAuthChallengePerformDefaultHandling;
  956 + }
  957 + } else {
  958 + disposition = NSURLSessionAuthChallengeCancelAuthenticationChallenge;
  959 + }
  960 + } else {
  961 + disposition = NSURLSessionAuthChallengePerformDefaultHandling;
  962 + }
  963 + }
  964 +
  965 + if (completionHandler) {
  966 + completionHandler(disposition, credential);
  967 + }
  968 +}
  969 +
  970 +#pragma mark - NSURLSessionTaskDelegate
  971 +
  972 +- (void)URLSession:(NSURLSession *)session
  973 + task:(NSURLSessionTask *)task
  974 +willPerformHTTPRedirection:(NSHTTPURLResponse *)response
  975 + newRequest:(NSURLRequest *)request
  976 + completionHandler:(void (^)(NSURLRequest *))completionHandler
  977 +{
  978 + NSURLRequest *redirectRequest = request;
  979 +
  980 + if (self.taskWillPerformHTTPRedirection) {
  981 + redirectRequest = self.taskWillPerformHTTPRedirection(session, task, response, request);
  982 + }
  983 +
  984 + if (completionHandler) {
  985 + completionHandler(redirectRequest);
  986 + }
  987 +}
  988 +
  989 +- (void)URLSession:(NSURLSession *)session
  990 + task:(NSURLSessionTask *)task
  991 +didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge
  992 + completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler
  993 +{
  994 + NSURLSessionAuthChallengeDisposition disposition = NSURLSessionAuthChallengePerformDefaultHandling;
  995 + __block NSURLCredential *credential = nil;
  996 +
  997 + if (self.taskDidReceiveAuthenticationChallenge) {
  998 + disposition = self.taskDidReceiveAuthenticationChallenge(session, task, challenge, &credential);
  999 + } else {
  1000 + if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
  1001 + if ([self.securityPolicy evaluateServerTrust:challenge.protectionSpace.serverTrust forDomain:challenge.protectionSpace.host]) {
  1002 + disposition = NSURLSessionAuthChallengeUseCredential;
  1003 + credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];
  1004 + } else {
  1005 + disposition = NSURLSessionAuthChallengeCancelAuthenticationChallenge;
  1006 + }
  1007 + } else {
  1008 + disposition = NSURLSessionAuthChallengePerformDefaultHandling;
  1009 + }
  1010 + }
  1011 +
  1012 + if (completionHandler) {
  1013 + completionHandler(disposition, credential);
  1014 + }
  1015 +}
  1016 +
  1017 +- (void)URLSession:(NSURLSession *)session
  1018 + task:(NSURLSessionTask *)task
  1019 + needNewBodyStream:(void (^)(NSInputStream *bodyStream))completionHandler
  1020 +{
  1021 + NSInputStream *inputStream = nil;
  1022 +
  1023 + if (self.taskNeedNewBodyStream) {
  1024 + inputStream = self.taskNeedNewBodyStream(session, task);
  1025 + } else if (task.originalRequest.HTTPBodyStream && [task.originalRequest.HTTPBodyStream conformsToProtocol:@protocol(NSCopying)]) {
  1026 + inputStream = [task.originalRequest.HTTPBodyStream copy];
  1027 + }
  1028 +
  1029 + if (completionHandler) {
  1030 + completionHandler(inputStream);
  1031 + }
  1032 +}
  1033 +
  1034 +- (void)URLSession:(NSURLSession *)session
  1035 + task:(NSURLSessionTask *)task
  1036 + didSendBodyData:(int64_t)bytesSent
  1037 + totalBytesSent:(int64_t)totalBytesSent
  1038 +totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend
  1039 +{
  1040 +
  1041 + int64_t totalUnitCount = totalBytesExpectedToSend;
  1042 + if(totalUnitCount == NSURLSessionTransferSizeUnknown) {
  1043 + NSString *contentLength = [task.originalRequest valueForHTTPHeaderField:@"Content-Length"];
  1044 + if(contentLength) {
  1045 + totalUnitCount = (int64_t) [contentLength longLongValue];
  1046 + }
  1047 + }
  1048 +
  1049 + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:task];
  1050 +
  1051 + if (delegate) {
  1052 + [delegate URLSession:session task:task didSendBodyData:bytesSent totalBytesSent:totalBytesSent totalBytesExpectedToSend:totalBytesExpectedToSend];
  1053 + }
  1054 +
  1055 + if (self.taskDidSendBodyData) {
  1056 + self.taskDidSendBodyData(session, task, bytesSent, totalBytesSent, totalUnitCount);
  1057 + }
  1058 +}
  1059 +
  1060 +- (void)URLSession:(NSURLSession *)session
  1061 + task:(NSURLSessionTask *)task
  1062 +didCompleteWithError:(NSError *)error
  1063 +{
  1064 + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:task];
  1065 +
  1066 + // delegate may be nil when completing a task in the background
  1067 + if (delegate) {
  1068 + [delegate URLSession:session task:task didCompleteWithError:error];
  1069 +
  1070 + [self removeDelegateForTask:task];
  1071 + }
  1072 +
  1073 + if (self.taskDidComplete) {
  1074 + self.taskDidComplete(session, task, error);
  1075 + }
  1076 +}
  1077 +
  1078 +#pragma mark - NSURLSessionDataDelegate
  1079 +
  1080 +- (void)URLSession:(NSURLSession *)session
  1081 + dataTask:(NSURLSessionDataTask *)dataTask
  1082 +didReceiveResponse:(NSURLResponse *)response
  1083 + completionHandler:(void (^)(NSURLSessionResponseDisposition disposition))completionHandler
  1084 +{
  1085 + NSURLSessionResponseDisposition disposition = NSURLSessionResponseAllow;
  1086 +
  1087 + if (self.dataTaskDidReceiveResponse) {
  1088 + disposition = self.dataTaskDidReceiveResponse(session, dataTask, response);
  1089 + }
  1090 +
  1091 + if (completionHandler) {
  1092 + completionHandler(disposition);
  1093 + }
  1094 +}
  1095 +
  1096 +- (void)URLSession:(NSURLSession *)session
  1097 + dataTask:(NSURLSessionDataTask *)dataTask
  1098 +didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask
  1099 +{
  1100 + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:dataTask];
  1101 + if (delegate) {
  1102 + [self removeDelegateForTask:dataTask];
  1103 + [self setDelegate:delegate forTask:downloadTask];
  1104 + }
  1105 +
  1106 + if (self.dataTaskDidBecomeDownloadTask) {
  1107 + self.dataTaskDidBecomeDownloadTask(session, dataTask, downloadTask);
  1108 + }
  1109 +}
  1110 +
  1111 +- (void)URLSession:(NSURLSession *)session
  1112 + dataTask:(NSURLSessionDataTask *)dataTask
  1113 + didReceiveData:(NSData *)data
  1114 +{
  1115 +
  1116 + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:dataTask];
  1117 + [delegate URLSession:session dataTask:dataTask didReceiveData:data];
  1118 +
  1119 + if (self.dataTaskDidReceiveData) {
  1120 + self.dataTaskDidReceiveData(session, dataTask, data);
  1121 + }
  1122 +}
  1123 +
  1124 +- (void)URLSession:(NSURLSession *)session
  1125 + dataTask:(NSURLSessionDataTask *)dataTask
  1126 + willCacheResponse:(NSCachedURLResponse *)proposedResponse
  1127 + completionHandler:(void (^)(NSCachedURLResponse *cachedResponse))completionHandler
  1128 +{
  1129 + NSCachedURLResponse *cachedResponse = proposedResponse;
  1130 +
  1131 + if (self.dataTaskWillCacheResponse) {
  1132 + cachedResponse = self.dataTaskWillCacheResponse(session, dataTask, proposedResponse);
  1133 + }
  1134 +
  1135 + if (completionHandler) {
  1136 + completionHandler(cachedResponse);
  1137 + }
  1138 +}
  1139 +
  1140 +#if !TARGET_OS_OSX
  1141 +- (void)URLSessionDidFinishEventsForBackgroundURLSession:(NSURLSession *)session {
  1142 + if (self.didFinishEventsForBackgroundURLSession) {
  1143 + dispatch_async(dispatch_get_main_queue(), ^{
  1144 + self.didFinishEventsForBackgroundURLSession(session);
  1145 + });
  1146 + }
  1147 +}
  1148 +#endif
  1149 +
  1150 +#pragma mark - NSURLSessionDownloadDelegate
  1151 +
  1152 +- (void)URLSession:(NSURLSession *)session
  1153 + downloadTask:(NSURLSessionDownloadTask *)downloadTask
  1154 +didFinishDownloadingToURL:(NSURL *)location
  1155 +{
  1156 + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:downloadTask];
  1157 + if (self.downloadTaskDidFinishDownloading) {
  1158 + NSURL *fileURL = self.downloadTaskDidFinishDownloading(session, downloadTask, location);
  1159 + if (fileURL) {
  1160 + delegate.downloadFileURL = fileURL;
  1161 + NSError *error = nil;
  1162 +
  1163 + if (![[NSFileManager defaultManager] moveItemAtURL:location toURL:fileURL error:&error]) {
  1164 + [[NSNotificationCenter defaultCenter] postNotificationName:AFURLSessionDownloadTaskDidFailToMoveFileNotification object:downloadTask userInfo:error.userInfo];
  1165 + }
  1166 +
  1167 + return;
  1168 + }
  1169 + }
  1170 +
  1171 + if (delegate) {
  1172 + [delegate URLSession:session downloadTask:downloadTask didFinishDownloadingToURL:location];
  1173 + }
  1174 +}
  1175 +
  1176 +- (void)URLSession:(NSURLSession *)session
  1177 + downloadTask:(NSURLSessionDownloadTask *)downloadTask
  1178 + didWriteData:(int64_t)bytesWritten
  1179 + totalBytesWritten:(int64_t)totalBytesWritten
  1180 +totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite
  1181 +{
  1182 +
  1183 + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:downloadTask];
  1184 +
  1185 + if (delegate) {
  1186 + [delegate URLSession:session downloadTask:downloadTask didWriteData:bytesWritten totalBytesWritten:totalBytesWritten totalBytesExpectedToWrite:totalBytesExpectedToWrite];
  1187 + }
  1188 +
  1189 + if (self.downloadTaskDidWriteData) {
  1190 + self.downloadTaskDidWriteData(session, downloadTask, bytesWritten, totalBytesWritten, totalBytesExpectedToWrite);
  1191 + }
  1192 +}
  1193 +
  1194 +- (void)URLSession:(NSURLSession *)session
  1195 + downloadTask:(NSURLSessionDownloadTask *)downloadTask
  1196 + didResumeAtOffset:(int64_t)fileOffset
  1197 +expectedTotalBytes:(int64_t)expectedTotalBytes
  1198 +{
  1199 +
  1200 + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:downloadTask];
  1201 +
  1202 + if (delegate) {
  1203 + [delegate URLSession:session downloadTask:downloadTask didResumeAtOffset:fileOffset expectedTotalBytes:expectedTotalBytes];
  1204 + }
  1205 +
  1206 + if (self.downloadTaskDidResume) {
  1207 + self.downloadTaskDidResume(session, downloadTask, fileOffset, expectedTotalBytes);
  1208 + }
  1209 +}
  1210 +
  1211 +#pragma mark - NSSecureCoding
  1212 +
  1213 ++ (BOOL)supportsSecureCoding {
  1214 + return YES;
  1215 +}
  1216 +
  1217 +- (instancetype)initWithCoder:(NSCoder *)decoder {
  1218 + NSURLSessionConfiguration *configuration = [decoder decodeObjectOfClass:[NSURLSessionConfiguration class] forKey:@"sessionConfiguration"];
  1219 +
  1220 + self = [self initWithSessionConfiguration:configuration];
  1221 + if (!self) {
  1222 + return nil;
  1223 + }
  1224 +
  1225 + return self;
  1226 +}
  1227 +
  1228 +- (void)encodeWithCoder:(NSCoder *)coder {
  1229 + [coder encodeObject:self.session.configuration forKey:@"sessionConfiguration"];
  1230 +}
  1231 +
  1232 +#pragma mark - NSCopying
  1233 +
  1234 +- (instancetype)copyWithZone:(NSZone *)zone {
  1235 + return [[[self class] allocWithZone:zone] initWithSessionConfiguration:self.session.configuration];
  1236 +}
  1237 +
  1238 +@end
... ...
Example/Pods/AFNetworking/LICENSE 0 → 100644
  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.
... ...
Example/Pods/AFNetworking/README.md 0 → 100644
  1 +<p align="center" >
  2 + <img src="https://raw.github.com/AFNetworking/AFNetworking/assets/afnetworking-logo.png" alt="AFNetworking" title="AFNetworking">
  3 +</p>
  4 +
  5 +[![Build Status](https://travis-ci.org/AFNetworking/AFNetworking.svg)](https://travis-ci.org/AFNetworking/AFNetworking)
  6 +[![codecov.io](https://codecov.io/github/AFNetworking/AFNetworking/coverage.svg?branch=master)](https://codecov.io/github/AFNetworking/AFNetworking?branch=master)
  7 +[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/AFNetworking.svg)](https://img.shields.io/cocoapods/v/AFNetworking.svg)
  8 +[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
  9 +[![Platform](https://img.shields.io/cocoapods/p/AFNetworking.svg?style=flat)](http://cocoadocs.org/docsets/AFNetworking)
  10 +[![Twitter](https://img.shields.io/badge/twitter-@AFNetworking-blue.svg?style=flat)](http://twitter.com/AFNetworking)
  11 +
  12 +AFNetworking is a delightful networking library for iOS, macOS, watchOS, and tvOS. It's built on top of the [Foundation URL Loading System](http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/URLLoadingSystem/URLLoadingSystem.html), extending the powerful high-level networking abstractions built into Cocoa. It has a modular architecture with well-designed, feature-rich APIs that are a joy to use.
  13 +
  14 +Perhaps the most important feature of all, however, is the amazing community of developers who use and contribute to AFNetworking every day. AFNetworking powers some of the most popular and critically-acclaimed apps on the iPhone, iPad, and Mac.
  15 +
  16 +Choose AFNetworking for your next project, or migrate over your existing projects—you'll be happy you did!
  17 +
  18 +## How To Get Started
  19 +
  20 +- [Download AFNetworking](https://github.com/AFNetworking/AFNetworking/archive/master.zip) and try out the included Mac and iPhone example apps
  21 +- Read the ["Getting Started" guide](https://github.com/AFNetworking/AFNetworking/wiki/Getting-Started-with-AFNetworking), [FAQ](https://github.com/AFNetworking/AFNetworking/wiki/AFNetworking-FAQ), or [other articles on the Wiki](https://github.com/AFNetworking/AFNetworking/wiki)
  22 +- Check out the [documentation](http://cocoadocs.org/docsets/AFNetworking/) for a comprehensive look at all of the APIs available in AFNetworking
  23 +- Read the [AFNetworking 3.0 Migration Guide](https://github.com/AFNetworking/AFNetworking/wiki/AFNetworking-3.0-Migration-Guide) for an overview of the architectural changes from 2.0.
  24 +
  25 +## Communication
  26 +
  27 +- If you **need help**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/afnetworking). (Tag 'afnetworking')
  28 +- If you'd like to **ask a general question**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/afnetworking).
  29 +- If you **found a bug**, _and can provide steps to reliably reproduce it_, open an issue.
  30 +- If you **have a feature request**, open an issue.
  31 +- If you **want to contribute**, submit a pull request.
  32 +
  33 +## Installation
  34 +AFNetworking supports multiple methods for installing the library in a project.
  35 +
  36 +## Installation with CocoaPods
  37 +
  38 +[CocoaPods](http://cocoapods.org) is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like AFNetworking in your projects. See the ["Getting Started" guide for more information](https://github.com/AFNetworking/AFNetworking/wiki/Getting-Started-with-AFNetworking). You can install it with the following command:
  39 +
  40 +```bash
  41 +$ gem install cocoapods
  42 +```
  43 +
  44 +> CocoaPods 0.39.0+ is required to build AFNetworking 3.0.0+.
  45 +
  46 +#### Podfile
  47 +
  48 +To integrate AFNetworking into your Xcode project using CocoaPods, specify it in your `Podfile`:
  49 +
  50 +```ruby
  51 +source 'https://github.com/CocoaPods/Specs.git'
  52 +platform :ios, '8.0'
  53 +
  54 +target 'TargetName' do
  55 +pod 'AFNetworking', '~> 3.0'
  56 +end
  57 +```
  58 +
  59 +Then, run the following command:
  60 +
  61 +```bash
  62 +$ pod install
  63 +```
  64 +
  65 +### Installation with Carthage
  66 +
  67 +[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
  68 +
  69 +You can install Carthage with [Homebrew](http://brew.sh/) using the following command:
  70 +
  71 +```bash
  72 +$ brew update
  73 +$ brew install carthage
  74 +```
  75 +
  76 +To integrate AFNetworking into your Xcode project using Carthage, specify it in your `Cartfile`:
  77 +
  78 +```ogdl
  79 +github "AFNetworking/AFNetworking" ~> 3.0
  80 +```
  81 +
  82 +Run `carthage` to build the framework and drag the built `AFNetworking.framework` into your Xcode project.
  83 +
  84 +## Requirements
  85 +
  86 +| AFNetworking Version | Minimum iOS Target | Minimum macOS Target | Minimum watchOS Target | Minimum tvOS Target | Notes |
  87 +|:--------------------:|:---------------------------:|:----------------------------:|:----------------------------:|:----------------------------:|:-------------------------------------------------------------------------:|
  88 +| 3.x | iOS 7 | OS X 10.9 | watchOS 2.0 | tvOS 9.0 | Xcode 7+ is required. `NSURLConnectionOperation` support has been removed. |
  89 +| 2.6 -> 2.6.3 | iOS 7 | OS X 10.9 | watchOS 2.0 | n/a | Xcode 7+ is required. |
  90 +| 2.0 -> 2.5.4 | iOS 6 | OS X 10.8 | n/a | n/a | Xcode 5+ is required. `NSURLSession` subspec requires iOS 7 or OS X 10.9. |
  91 +| 1.x | iOS 5 | Mac OS X 10.7 | n/a | n/a |
  92 +| 0.10.x | iOS 4 | Mac OS X 10.6 | n/a | n/a |
  93 +
  94 +(macOS projects must support [64-bit with modern Cocoa runtime](https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtVersionsPlatforms.html)).
  95 +
  96 +> Programming in Swift? Try [Alamofire](https://github.com/Alamofire/Alamofire) for a more conventional set of APIs.
  97 +
  98 +## Architecture
  99 +
  100 +### NSURLSession
  101 +
  102 +- `AFURLSessionManager`
  103 +- `AFHTTPSessionManager`
  104 +
  105 +### Serialization
  106 +
  107 +* `<AFURLRequestSerialization>`
  108 + - `AFHTTPRequestSerializer`
  109 + - `AFJSONRequestSerializer`
  110 + - `AFPropertyListRequestSerializer`
  111 +* `<AFURLResponseSerialization>`
  112 + - `AFHTTPResponseSerializer`
  113 + - `AFJSONResponseSerializer`
  114 + - `AFXMLParserResponseSerializer`
  115 + - `AFXMLDocumentResponseSerializer` _(macOS)_
  116 + - `AFPropertyListResponseSerializer`
  117 + - `AFImageResponseSerializer`
  118 + - `AFCompoundResponseSerializer`
  119 +
  120 +### Additional Functionality
  121 +
  122 +- `AFSecurityPolicy`
  123 +- `AFNetworkReachabilityManager`
  124 +
  125 +## Usage
  126 +
  127 +### AFURLSessionManager
  128 +
  129 +`AFURLSessionManager` creates and manages an `NSURLSession` object based on a specified `NSURLSessionConfiguration` object, which conforms to `<NSURLSessionTaskDelegate>`, `<NSURLSessionDataDelegate>`, `<NSURLSessionDownloadDelegate>`, and `<NSURLSessionDelegate>`.
  130 +
  131 +#### Creating a Download Task
  132 +
  133 +```objective-c
  134 +NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
  135 +AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];
  136 +
  137 +NSURL *URL = [NSURL URLWithString:@"http://example.com/download.zip"];
  138 +NSURLRequest *request = [NSURLRequest requestWithURL:URL];
  139 +
  140 +NSURLSessionDownloadTask *downloadTask = [manager downloadTaskWithRequest:request progress:nil destination:^NSURL *(NSURL *targetPath, NSURLResponse *response) {
  141 + NSURL *documentsDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil];
  142 + return [documentsDirectoryURL URLByAppendingPathComponent:[response suggestedFilename]];
  143 +} completionHandler:^(NSURLResponse *response, NSURL *filePath, NSError *error) {
  144 + NSLog(@"File downloaded to: %@", filePath);
  145 +}];
  146 +[downloadTask resume];
  147 +```
  148 +
  149 +#### Creating an Upload Task
  150 +
  151 +```objective-c
  152 +NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
  153 +AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];
  154 +
  155 +NSURL *URL = [NSURL URLWithString:@"http://example.com/upload"];
  156 +NSURLRequest *request = [NSURLRequest requestWithURL:URL];
  157 +
  158 +NSURL *filePath = [NSURL fileURLWithPath:@"file://path/to/image.png"];
  159 +NSURLSessionUploadTask *uploadTask = [manager uploadTaskWithRequest:request fromFile:filePath progress:nil completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
  160 + if (error) {
  161 + NSLog(@"Error: %@", error);
  162 + } else {
  163 + NSLog(@"Success: %@ %@", response, responseObject);
  164 + }
  165 +}];
  166 +[uploadTask resume];
  167 +```
  168 +
  169 +#### Creating an Upload Task for a Multi-Part Request, with Progress
  170 +
  171 +```objective-c
  172 +NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:@"http://example.com/upload" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
  173 + [formData appendPartWithFileURL:[NSURL fileURLWithPath:@"file://path/to/image.jpg"] name:@"file" fileName:@"filename.jpg" mimeType:@"image/jpeg" error:nil];
  174 + } error:nil];
  175 +
  176 +AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
  177 +
  178 +NSURLSessionUploadTask *uploadTask;
  179 +uploadTask = [manager
  180 + uploadTaskWithStreamedRequest:request
  181 + progress:^(NSProgress * _Nonnull uploadProgress) {
  182 + // This is not called back on the main queue.
  183 + // You are responsible for dispatching to the main queue for UI updates
  184 + dispatch_async(dispatch_get_main_queue(), ^{
  185 + //Update the progress view
  186 + [progressView setProgress:uploadProgress.fractionCompleted];
  187 + });
  188 + }
  189 + completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) {
  190 + if (error) {
  191 + NSLog(@"Error: %@", error);
  192 + } else {
  193 + NSLog(@"%@ %@", response, responseObject);
  194 + }
  195 + }];
  196 +
  197 +[uploadTask resume];
  198 +```
  199 +
  200 +#### Creating a Data Task
  201 +
  202 +```objective-c
  203 +NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
  204 +AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];
  205 +
  206 +NSURL *URL = [NSURL URLWithString:@"http://httpbin.org/get"];
  207 +NSURLRequest *request = [NSURLRequest requestWithURL:URL];
  208 +
  209 +NSURLSessionDataTask *dataTask = [manager dataTaskWithRequest:request completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
  210 + if (error) {
  211 + NSLog(@"Error: %@", error);
  212 + } else {
  213 + NSLog(@"%@ %@", response, responseObject);
  214 + }
  215 +}];
  216 +[dataTask resume];
  217 +```
  218 +
  219 +---
  220 +
  221 +### Request Serialization
  222 +
  223 +Request serializers create requests from URL strings, encoding parameters as either a query string or HTTP body.
  224 +
  225 +```objective-c
  226 +NSString *URLString = @"http://example.com";
  227 +NSDictionary *parameters = @{@"foo": @"bar", @"baz": @[@1, @2, @3]};
  228 +```
  229 +
  230 +#### Query String Parameter Encoding
  231 +
  232 +```objective-c
  233 +[[AFHTTPRequestSerializer serializer] requestWithMethod:@"GET" URLString:URLString parameters:parameters error:nil];
  234 +```
  235 +
  236 + GET http://example.com?foo=bar&baz[]=1&baz[]=2&baz[]=3
  237 +
  238 +#### URL Form Parameter Encoding
  239 +
  240 +```objective-c
  241 +[[AFHTTPRequestSerializer serializer] requestWithMethod:@"POST" URLString:URLString parameters:parameters error:nil];
  242 +```
  243 +
  244 + POST http://example.com/
  245 + Content-Type: application/x-www-form-urlencoded
  246 +
  247 + foo=bar&baz[]=1&baz[]=2&baz[]=3
  248 +
  249 +#### JSON Parameter Encoding
  250 +
  251 +```objective-c
  252 +[[AFJSONRequestSerializer serializer] requestWithMethod:@"POST" URLString:URLString parameters:parameters error:nil];
  253 +```
  254 +
  255 + POST http://example.com/
  256 + Content-Type: application/json
  257 +
  258 + {"foo": "bar", "baz": [1,2,3]}
  259 +
  260 +---
  261 +
  262 +### Network Reachability Manager
  263 +
  264 +`AFNetworkReachabilityManager` monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces.
  265 +
  266 +* Do not use Reachability to determine if the original request should be sent.
  267 + * You should try to send it.
  268 +* You can use Reachability to determine when a request should be automatically retried.
  269 + * Although it may still fail, a Reachability notification that the connectivity is available is a good time to retry something.
  270 +* Network reachability is a useful tool for determining why a request might have failed.
  271 + * After a network request has failed, telling the user they're offline is better than giving them a more technical but accurate error, such as "request timed out."
  272 +
  273 +See also [WWDC 2012 session 706, "Networking Best Practices."](https://developer.apple.com/videos/play/wwdc2012-706/).
  274 +
  275 +#### Shared Network Reachability
  276 +
  277 +```objective-c
  278 +[[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
  279 + NSLog(@"Reachability: %@", AFStringFromNetworkReachabilityStatus(status));
  280 +}];
  281 +
  282 +[[AFNetworkReachabilityManager sharedManager] startMonitoring];
  283 +```
  284 +
  285 +---
  286 +
  287 +### Security Policy
  288 +
  289 +`AFSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections.
  290 +
  291 +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.
  292 +
  293 +#### Allowing Invalid SSL Certificates
  294 +
  295 +```objective-c
  296 +AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
  297 +manager.securityPolicy.allowInvalidCertificates = YES; // not recommended for production
  298 +```
  299 +
  300 +---
  301 +
  302 +## Unit Tests
  303 +
  304 +AFNetworking includes a suite of unit tests within the Tests subdirectory. These tests can be run simply be executed the test action on the platform framework you would like to test.
  305 +
  306 +## Credits
  307 +
  308 +AFNetworking is owned and maintained by the [Alamofire Software Foundation](http://alamofire.org).
  309 +
  310 +AFNetworking was originally created by [Scott Raymond](https://github.com/sco/) and [Mattt Thompson](https://github.com/mattt/) in the development of [Gowalla for iPhone](http://en.wikipedia.org/wiki/Gowalla).
  311 +
  312 +AFNetworking's logo was designed by [Alan Defibaugh](http://www.alandefibaugh.com/).
  313 +
  314 +And most of all, thanks to AFNetworking's [growing list of contributors](https://github.com/AFNetworking/AFNetworking/contributors).
  315 +
  316 +### Security Disclosure
  317 +
  318 +If you believe you have identified a security vulnerability with AFNetworking, you should report it as soon as possible via email to security@alamofire.org. Please do not post it to a public issue tracker.
  319 +
  320 +## License
  321 +
  322 +AFNetworking is released under the MIT license. See [LICENSE](https://github.com/AFNetworking/AFNetworking/blob/master/LICENSE) for details.
... ...
Example/Pods/AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.h 0 → 100644
  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 <TargetConditionals.h>
  23 +#import <Foundation/Foundation.h>
  24 +
  25 +#if TARGET_OS_IOS || TARGET_OS_TV
  26 +#import <UIKit/UIKit.h>
  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 <NSObject>
  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 <AFImageCache>
  74 +
  75 +/**
  76 + Asks if the image should be cached using an identifier created from the request and additional identifier.
  77 +
  78 + @param image The image to be cached.
  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 + @return A BOOL indicating whether or not the image should be added to the cache. YES will cache, NO will prevent caching.
  83 + */
  84 +- (BOOL)shouldCacheImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier;
  85 +
  86 +/**
  87 + Adds the image to the cache using an identifier created from the request and additional identifier.
  88 +
  89 + @param image The image to cache.
  90 + @param request The unique URL request identifing the image asset.
  91 + @param identifier The additional identifier to apply to the URL request to identify the image.
  92 + */
  93 +- (void)addImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier;
  94 +
  95 +/**
  96 + Removes the image from the cache using an identifier created from the request and additional identifier.
  97 +
  98 + @param request The unique URL request identifing the image asset.
  99 + @param identifier The additional identifier to apply to the URL request to identify the image.
  100 +
  101 + @return A BOOL indicating whether or not all images were removed from the cache.
  102 + */
  103 +- (BOOL)removeImageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier;
  104 +
  105 +/**
  106 + Returns the image from the cache associated with an identifier created from the request and additional identifier.
  107 +
  108 + @param request The unique URL request identifing the image asset.
  109 + @param identifier The additional identifier to apply to the URL request to identify the image.
  110 +
  111 + @return An image for the matching request and identifier, or nil.
  112 + */
  113 +- (nullable UIImage *)imageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier;
  114 +
  115 +@end
  116 +
  117 +/**
  118 + 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.
  119 + */
  120 +@interface AFAutoPurgingImageCache : NSObject <AFImageRequestCache>
  121 +
  122 +/**
  123 + The total memory capacity of the cache in bytes.
  124 + */
  125 +@property (nonatomic, assign) UInt64 memoryCapacity;
  126 +
  127 +/**
  128 + The preferred memory usage after purge in bytes. During a purge, images will be purged until the memory capacity drops below this limit.
  129 + */
  130 +@property (nonatomic, assign) UInt64 preferredMemoryUsageAfterPurge;
  131 +
  132 +/**
  133 + The current total memory usage in bytes of all images stored within the cache.
  134 + */
  135 +@property (nonatomic, assign, readonly) UInt64 memoryUsage;
  136 +
  137 +/**
  138 + 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`.
  139 +
  140 + @return The new `AutoPurgingImageCache` instance.
  141 + */
  142 +- (instancetype)init;
  143 +
  144 +/**
  145 + Initialies the `AutoPurgingImageCache` instance with the given memory capacity and preferred memory usage
  146 + after purge limit.
  147 +
  148 + @param memoryCapacity The total memory capacity of the cache in bytes.
  149 + @param preferredMemoryCapacity The preferred memory usage after purge in bytes.
  150 +
  151 + @return The new `AutoPurgingImageCache` instance.
  152 + */
  153 +- (instancetype)initWithMemoryCapacity:(UInt64)memoryCapacity preferredMemoryCapacity:(UInt64)preferredMemoryCapacity;
  154 +
  155 +@end
  156 +
  157 +NS_ASSUME_NONNULL_END
  158 +
  159 +#endif
  160 +
... ...
Example/Pods/AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.m 0 → 100644
  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 <TargetConditionals.h>
  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 <NSString* , AFCachedImage*> *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 <AFCachedImage*> *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 +- (BOOL)shouldCacheImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier {
  200 + return YES;
  201 +}
  202 +
  203 +@end
  204 +
  205 +#endif
... ...
Example/Pods/AFNetworking/UIKit+AFNetworking/AFImageDownloader.h 0 → 100644
  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 <TargetConditionals.h>
  23 +
  24 +#if TARGET_OS_IOS || TARGET_OS_TV
  25 +
  26 +#import <Foundation/Foundation.h>
  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 <AFImageRequestCache> 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 + The default `NSURLSessionConfiguration` with common usage parameter values.
  86 + */
  87 ++ (NSURLSessionConfiguration *)defaultURLSessionConfiguration;
  88 +
  89 +/**
  90 + Default initializer
  91 +
  92 + @return An instance of `AFImageDownloader` initialized with default values.
  93 + */
  94 +- (instancetype)init;
  95 +
  96 +/**
  97 + Initializer with specific `URLSessionConfiguration`
  98 +
  99 + @param configuration The `NSURLSessionConfiguration` to be be used
  100 +
  101 + @return An instance of `AFImageDownloader` initialized with default values and custom `NSURLSessionConfiguration`
  102 + */
  103 +- (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration;
  104 +
  105 +/**
  106 + Initializes the `AFImageDownloader` instance with the given session manager, download prioritization, maximum active download count and image cache.
  107 +
  108 + @param sessionManager The session manager to use to download images.
  109 + @param downloadPrioritization The download prioritization of the download queue.
  110 + @param maximumActiveDownloads The maximum number of active downloads allowed at any given time. Recommend `4`.
  111 + @param imageCache The image cache used to store all downloaded images in.
  112 +
  113 + @return The new `AFImageDownloader` instance.
  114 + */
  115 +- (instancetype)initWithSessionManager:(AFHTTPSessionManager *)sessionManager
  116 + downloadPrioritization:(AFImageDownloadPrioritization)downloadPrioritization
  117 + maximumActiveDownloads:(NSInteger)maximumActiveDownloads
  118 + imageCache:(nullable id <AFImageRequestCache>)imageCache;
  119 +
  120 +/**
  121 + Creates a data task using the `sessionManager` instance for the specified URL request.
  122 +
  123 + If the same data task is already in the queue or currently being downloaded, the success and failure blocks are
  124 + appended to the already existing task. Once the task completes, all success or failure blocks attached to the
  125 + task are executed in the order they were added.
  126 +
  127 + @param request The URL request.
  128 + @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`.
  129 + @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.
  130 +
  131 + @return The image download receipt for the data task if available. `nil` if the image is stored in the cache.
  132 + cache and the URL request cache policy allows the cache to be used.
  133 + */
  134 +- (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *)request
  135 + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *responseObject))success
  136 + failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure;
  137 +
  138 +/**
  139 + Creates a data task using the `sessionManager` instance for the specified URL request.
  140 +
  141 + If the same data task is already in the queue or currently being downloaded, the success and failure blocks are
  142 + appended to the already existing task. Once the task completes, all success or failure blocks attached to the
  143 + task are executed in the order they were added.
  144 +
  145 + @param request The URL request.
  146 + @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.
  147 + @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`.
  148 + @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.
  149 +
  150 + @return The image download receipt for the data task if available. `nil` if the image is stored in the cache.
  151 + cache and the URL request cache policy allows the cache to be used.
  152 + */
  153 +- (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *)request
  154 + withReceiptID:(NSUUID *)receiptID
  155 + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *responseObject))success
  156 + failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure;
  157 +
  158 +/**
  159 + Cancels the data task in the receipt by removing the corresponding success and failure blocks and cancelling the data task if necessary.
  160 +
  161 + 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.
  162 +
  163 + @param imageDownloadReceipt The image download receipt to cancel.
  164 + */
  165 +- (void)cancelTaskForImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt;
  166 +
  167 +@end
  168 +
  169 +#endif
  170 +
  171 +NS_ASSUME_NONNULL_END
... ...
Example/Pods/AFNetworking/UIKit+AFNetworking/AFImageDownloader.m 0 → 100644
  1 +// AFImageDownloader.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 <TargetConditionals.h>
  23 +
  24 +#if TARGET_OS_IOS || TARGET_OS_TV
  25 +
  26 +#import "AFImageDownloader.h"
  27 +#import "AFHTTPSessionManager.h"
  28 +
  29 +@interface AFImageDownloaderResponseHandler : NSObject
  30 +@property (nonatomic, strong) NSUUID *uuid;
  31 +@property (nonatomic, copy) void (^successBlock)(NSURLRequest*, NSHTTPURLResponse*, UIImage*);
  32 +@property (nonatomic, copy) void (^failureBlock)(NSURLRequest*, NSHTTPURLResponse*, NSError*);
  33 +@end
  34 +
  35 +@implementation AFImageDownloaderResponseHandler
  36 +
  37 +- (instancetype)initWithUUID:(NSUUID *)uuid
  38 + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *responseObject))success
  39 + failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure {
  40 + if (self = [self init]) {
  41 + self.uuid = uuid;
  42 + self.successBlock = success;
  43 + self.failureBlock = failure;
  44 + }
  45 + return self;
  46 +}
  47 +
  48 +- (NSString *)description {
  49 + return [NSString stringWithFormat: @"<AFImageDownloaderResponseHandler>UUID: %@", [self.uuid UUIDString]];
  50 +}
  51 +
  52 +@end
  53 +
  54 +@interface AFImageDownloaderMergedTask : NSObject
  55 +@property (nonatomic, strong) NSString *URLIdentifier;
  56 +@property (nonatomic, strong) NSUUID *identifier;
  57 +@property (nonatomic, strong) NSURLSessionDataTask *task;
  58 +@property (nonatomic, strong) NSMutableArray <AFImageDownloaderResponseHandler*> *responseHandlers;
  59 +
  60 +@end
  61 +
  62 +@implementation AFImageDownloaderMergedTask
  63 +
  64 +- (instancetype)initWithURLIdentifier:(NSString *)URLIdentifier identifier:(NSUUID *)identifier task:(NSURLSessionDataTask *)task {
  65 + if (self = [self init]) {
  66 + self.URLIdentifier = URLIdentifier;
  67 + self.task = task;
  68 + self.identifier = identifier;
  69 + self.responseHandlers = [[NSMutableArray alloc] init];
  70 + }
  71 + return self;
  72 +}
  73 +
  74 +- (void)addResponseHandler:(AFImageDownloaderResponseHandler*)handler {
  75 + [self.responseHandlers addObject:handler];
  76 +}
  77 +
  78 +- (void)removeResponseHandler:(AFImageDownloaderResponseHandler*)handler {
  79 + [self.responseHandlers removeObject:handler];
  80 +}
  81 +
  82 +@end
  83 +
  84 +@implementation AFImageDownloadReceipt
  85 +
  86 +- (instancetype)initWithReceiptID:(NSUUID *)receiptID task:(NSURLSessionDataTask *)task {
  87 + if (self = [self init]) {
  88 + self.receiptID = receiptID;
  89 + self.task = task;
  90 + }
  91 + return self;
  92 +}
  93 +
  94 +@end
  95 +
  96 +@interface AFImageDownloader ()
  97 +
  98 +@property (nonatomic, strong) dispatch_queue_t synchronizationQueue;
  99 +@property (nonatomic, strong) dispatch_queue_t responseQueue;
  100 +
  101 +@property (nonatomic, assign) NSInteger maximumActiveDownloads;
  102 +@property (nonatomic, assign) NSInteger activeRequestCount;
  103 +
  104 +@property (nonatomic, strong) NSMutableArray *queuedMergedTasks;
  105 +@property (nonatomic, strong) NSMutableDictionary *mergedTasks;
  106 +
  107 +@end
  108 +
  109 +@implementation AFImageDownloader
  110 +
  111 ++ (NSURLCache *)defaultURLCache {
  112 +
  113 + // It's been discovered that a crash will occur on certain versions
  114 + // of iOS if you customize the cache.
  115 + //
  116 + // More info can be found here: https://devforums.apple.com/message/1102182#1102182
  117 + //
  118 + // When iOS 7 support is dropped, this should be modified to use
  119 + // NSProcessInfo methods instead.
  120 + if ([[[UIDevice currentDevice] systemVersion] compare:@"8.2" options:NSNumericSearch] == NSOrderedAscending) {
  121 + return [NSURLCache sharedURLCache];
  122 + }
  123 + return [[NSURLCache alloc] initWithMemoryCapacity:20 * 1024 * 1024
  124 + diskCapacity:150 * 1024 * 1024
  125 + diskPath:@"com.alamofire.imagedownloader"];
  126 +}
  127 +
  128 ++ (NSURLSessionConfiguration *)defaultURLSessionConfiguration {
  129 + NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
  130 +
  131 + //TODO set the default HTTP headers
  132 +
  133 + configuration.HTTPShouldSetCookies = YES;
  134 + configuration.HTTPShouldUsePipelining = NO;
  135 +
  136 + configuration.requestCachePolicy = NSURLRequestUseProtocolCachePolicy;
  137 + configuration.allowsCellularAccess = YES;
  138 + configuration.timeoutIntervalForRequest = 60.0;
  139 + configuration.URLCache = [AFImageDownloader defaultURLCache];
  140 +
  141 + return configuration;
  142 +}
  143 +
  144 +- (instancetype)init {
  145 + NSURLSessionConfiguration *defaultConfiguration = [self.class defaultURLSessionConfiguration];
  146 + return [self initWithSessionConfiguration:defaultConfiguration];
  147 +}
  148 +
  149 +- (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration {
  150 + AFHTTPSessionManager *sessionManager = [[AFHTTPSessionManager alloc] initWithSessionConfiguration:configuration];
  151 + sessionManager.responseSerializer = [AFImageResponseSerializer serializer];
  152 +
  153 + return [self initWithSessionManager:sessionManager
  154 + downloadPrioritization:AFImageDownloadPrioritizationFIFO
  155 + maximumActiveDownloads:4
  156 + imageCache:[[AFAutoPurgingImageCache alloc] init]];
  157 +}
  158 +
  159 +- (instancetype)initWithSessionManager:(AFHTTPSessionManager *)sessionManager
  160 + downloadPrioritization:(AFImageDownloadPrioritization)downloadPrioritization
  161 + maximumActiveDownloads:(NSInteger)maximumActiveDownloads
  162 + imageCache:(id <AFImageRequestCache>)imageCache {
  163 + if (self = [super init]) {
  164 + self.sessionManager = sessionManager;
  165 +
  166 + self.downloadPrioritizaton = downloadPrioritization;
  167 + self.maximumActiveDownloads = maximumActiveDownloads;
  168 + self.imageCache = imageCache;
  169 +
  170 + self.queuedMergedTasks = [[NSMutableArray alloc] init];
  171 + self.mergedTasks = [[NSMutableDictionary alloc] init];
  172 + self.activeRequestCount = 0;
  173 +
  174 + NSString *name = [NSString stringWithFormat:@"com.alamofire.imagedownloader.synchronizationqueue-%@", [[NSUUID UUID] UUIDString]];
  175 + self.synchronizationQueue = dispatch_queue_create([name cStringUsingEncoding:NSASCIIStringEncoding], DISPATCH_QUEUE_SERIAL);
  176 +
  177 + name = [NSString stringWithFormat:@"com.alamofire.imagedownloader.responsequeue-%@", [[NSUUID UUID] UUIDString]];
  178 + self.responseQueue = dispatch_queue_create([name cStringUsingEncoding:NSASCIIStringEncoding], DISPATCH_QUEUE_CONCURRENT);
  179 + }
  180 +
  181 + return self;
  182 +}
  183 +
  184 ++ (instancetype)defaultInstance {
  185 + static AFImageDownloader *sharedInstance = nil;
  186 + static dispatch_once_t onceToken;
  187 + dispatch_once(&onceToken, ^{
  188 + sharedInstance = [[self alloc] init];
  189 + });
  190 + return sharedInstance;
  191 +}
  192 +
  193 +- (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *)request
  194 + success:(void (^)(NSURLRequest * _Nonnull, NSHTTPURLResponse * _Nullable, UIImage * _Nonnull))success
  195 + failure:(void (^)(NSURLRequest * _Nonnull, NSHTTPURLResponse * _Nullable, NSError * _Nonnull))failure {
  196 + return [self downloadImageForURLRequest:request withReceiptID:[NSUUID UUID] success:success failure:failure];
  197 +}
  198 +
  199 +- (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *)request
  200 + withReceiptID:(nonnull NSUUID *)receiptID
  201 + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *responseObject))success
  202 + failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure {
  203 + __block NSURLSessionDataTask *task = nil;
  204 + dispatch_sync(self.synchronizationQueue, ^{
  205 + NSString *URLIdentifier = request.URL.absoluteString;
  206 + if (URLIdentifier == nil) {
  207 + if (failure) {
  208 + NSError *error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorBadURL userInfo:nil];
  209 + dispatch_async(dispatch_get_main_queue(), ^{
  210 + failure(request, nil, error);
  211 + });
  212 + }
  213 + return;
  214 + }
  215 +
  216 + // 1) Append the success and failure blocks to a pre-existing request if it already exists
  217 + AFImageDownloaderMergedTask *existingMergedTask = self.mergedTasks[URLIdentifier];
  218 + if (existingMergedTask != nil) {
  219 + AFImageDownloaderResponseHandler *handler = [[AFImageDownloaderResponseHandler alloc] initWithUUID:receiptID success:success failure:failure];
  220 + [existingMergedTask addResponseHandler:handler];
  221 + task = existingMergedTask.task;
  222 + return;
  223 + }
  224 +
  225 + // 2) Attempt to load the image from the image cache if the cache policy allows it
  226 + switch (request.cachePolicy) {
  227 + case NSURLRequestUseProtocolCachePolicy:
  228 + case NSURLRequestReturnCacheDataElseLoad:
  229 + case NSURLRequestReturnCacheDataDontLoad: {
  230 + UIImage *cachedImage = [self.imageCache imageforRequest:request withAdditionalIdentifier:nil];
  231 + if (cachedImage != nil) {
  232 + if (success) {
  233 + dispatch_async(dispatch_get_main_queue(), ^{
  234 + success(request, nil, cachedImage);
  235 + });
  236 + }
  237 + return;
  238 + }
  239 + break;
  240 + }
  241 + default:
  242 + break;
  243 + }
  244 +
  245 + // 3) Create the request and set up authentication, validation and response serialization
  246 + NSUUID *mergedTaskIdentifier = [NSUUID UUID];
  247 + NSURLSessionDataTask *createdTask;
  248 + __weak __typeof__(self) weakSelf = self;
  249 +
  250 + createdTask = [self.sessionManager
  251 + dataTaskWithRequest:request
  252 + uploadProgress:nil
  253 + downloadProgress:nil
  254 + completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) {
  255 + dispatch_async(self.responseQueue, ^{
  256 + __strong __typeof__(weakSelf) strongSelf = weakSelf;
  257 + AFImageDownloaderMergedTask *mergedTask = strongSelf.mergedTasks[URLIdentifier];
  258 + if ([mergedTask.identifier isEqual:mergedTaskIdentifier]) {
  259 + mergedTask = [strongSelf safelyRemoveMergedTaskWithURLIdentifier:URLIdentifier];
  260 + if (error) {
  261 + for (AFImageDownloaderResponseHandler *handler in mergedTask.responseHandlers) {
  262 + if (handler.failureBlock) {
  263 + dispatch_async(dispatch_get_main_queue(), ^{
  264 + handler.failureBlock(request, (NSHTTPURLResponse*)response, error);
  265 + });
  266 + }
  267 + }
  268 + } else {
  269 + if ([strongSelf.imageCache shouldCacheImage:responseObject forRequest:request withAdditionalIdentifier:nil]) {
  270 + [strongSelf.imageCache addImage:responseObject forRequest:request withAdditionalIdentifier:nil];
  271 + }
  272 +
  273 + for (AFImageDownloaderResponseHandler *handler in mergedTask.responseHandlers) {
  274 + if (handler.successBlock) {
  275 + dispatch_async(dispatch_get_main_queue(), ^{
  276 + handler.successBlock(request, (NSHTTPURLResponse*)response, responseObject);
  277 + });
  278 + }
  279 + }
  280 +
  281 + }
  282 + }
  283 + [strongSelf safelyDecrementActiveTaskCount];
  284 + [strongSelf safelyStartNextTaskIfNecessary];
  285 + });
  286 + }];
  287 +
  288 + // 4) Store the response handler for use when the request completes
  289 + AFImageDownloaderResponseHandler *handler = [[AFImageDownloaderResponseHandler alloc] initWithUUID:receiptID
  290 + success:success
  291 + failure:failure];
  292 + AFImageDownloaderMergedTask *mergedTask = [[AFImageDownloaderMergedTask alloc]
  293 + initWithURLIdentifier:URLIdentifier
  294 + identifier:mergedTaskIdentifier
  295 + task:createdTask];
  296 + [mergedTask addResponseHandler:handler];
  297 + self.mergedTasks[URLIdentifier] = mergedTask;
  298 +
  299 + // 5) Either start the request or enqueue it depending on the current active request count
  300 + if ([self isActiveRequestCountBelowMaximumLimit]) {
  301 + [self startMergedTask:mergedTask];
  302 + } else {
  303 + [self enqueueMergedTask:mergedTask];
  304 + }
  305 +
  306 + task = mergedTask.task;
  307 + });
  308 + if (task) {
  309 + return [[AFImageDownloadReceipt alloc] initWithReceiptID:receiptID task:task];
  310 + } else {
  311 + return nil;
  312 + }
  313 +}
  314 +
  315 +- (void)cancelTaskForImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt {
  316 + dispatch_sync(self.synchronizationQueue, ^{
  317 + NSString *URLIdentifier = imageDownloadReceipt.task.originalRequest.URL.absoluteString;
  318 + AFImageDownloaderMergedTask *mergedTask = self.mergedTasks[URLIdentifier];
  319 + NSUInteger index = [mergedTask.responseHandlers indexOfObjectPassingTest:^BOOL(AFImageDownloaderResponseHandler * _Nonnull handler, __unused NSUInteger idx, __unused BOOL * _Nonnull stop) {
  320 + return handler.uuid == imageDownloadReceipt.receiptID;
  321 + }];
  322 +
  323 + if (index != NSNotFound) {
  324 + AFImageDownloaderResponseHandler *handler = mergedTask.responseHandlers[index];
  325 + [mergedTask removeResponseHandler:handler];
  326 + NSString *failureReason = [NSString stringWithFormat:@"ImageDownloader cancelled URL request: %@",imageDownloadReceipt.task.originalRequest.URL.absoluteString];
  327 + NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey:failureReason};
  328 + NSError *error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled userInfo:userInfo];
  329 + if (handler.failureBlock) {
  330 + dispatch_async(dispatch_get_main_queue(), ^{
  331 + handler.failureBlock(imageDownloadReceipt.task.originalRequest, nil, error);
  332 + });
  333 + }
  334 + }
  335 +
  336 + if (mergedTask.responseHandlers.count == 0 && mergedTask.task.state == NSURLSessionTaskStateSuspended) {
  337 + [mergedTask.task cancel];
  338 + [self removeMergedTaskWithURLIdentifier:URLIdentifier];
  339 + }
  340 + });
  341 +}
  342 +
  343 +- (AFImageDownloaderMergedTask*)safelyRemoveMergedTaskWithURLIdentifier:(NSString *)URLIdentifier {
  344 + __block AFImageDownloaderMergedTask *mergedTask = nil;
  345 + dispatch_sync(self.synchronizationQueue, ^{
  346 + mergedTask = [self removeMergedTaskWithURLIdentifier:URLIdentifier];
  347 + });
  348 + return mergedTask;
  349 +}
  350 +
  351 +//This method should only be called from safely within the synchronizationQueue
  352 +- (AFImageDownloaderMergedTask *)removeMergedTaskWithURLIdentifier:(NSString *)URLIdentifier {
  353 + AFImageDownloaderMergedTask *mergedTask = self.mergedTasks[URLIdentifier];
  354 + [self.mergedTasks removeObjectForKey:URLIdentifier];
  355 + return mergedTask;
  356 +}
  357 +
  358 +- (void)safelyDecrementActiveTaskCount {
  359 + dispatch_sync(self.synchronizationQueue, ^{
  360 + if (self.activeRequestCount > 0) {
  361 + self.activeRequestCount -= 1;
  362 + }
  363 + });
  364 +}
  365 +
  366 +- (void)safelyStartNextTaskIfNecessary {
  367 + dispatch_sync(self.synchronizationQueue, ^{
  368 + if ([self isActiveRequestCountBelowMaximumLimit]) {
  369 + while (self.queuedMergedTasks.count > 0) {
  370 + AFImageDownloaderMergedTask *mergedTask = [self dequeueMergedTask];
  371 + if (mergedTask.task.state == NSURLSessionTaskStateSuspended) {
  372 + [self startMergedTask:mergedTask];
  373 + break;
  374 + }
  375 + }
  376 + }
  377 + });
  378 +}
  379 +
  380 +- (void)startMergedTask:(AFImageDownloaderMergedTask *)mergedTask {
  381 + [mergedTask.task resume];
  382 + ++self.activeRequestCount;
  383 +}
  384 +
  385 +- (void)enqueueMergedTask:(AFImageDownloaderMergedTask *)mergedTask {
  386 + switch (self.downloadPrioritizaton) {
  387 + case AFImageDownloadPrioritizationFIFO:
  388 + [self.queuedMergedTasks addObject:mergedTask];
  389 + break;
  390 + case AFImageDownloadPrioritizationLIFO:
  391 + [self.queuedMergedTasks insertObject:mergedTask atIndex:0];
  392 + break;
  393 + }
  394 +}
  395 +
  396 +- (AFImageDownloaderMergedTask *)dequeueMergedTask {
  397 + AFImageDownloaderMergedTask *mergedTask = nil;
  398 + mergedTask = [self.queuedMergedTasks firstObject];
  399 + [self.queuedMergedTasks removeObject:mergedTask];
  400 + return mergedTask;
  401 +}
  402 +
  403 +- (BOOL)isActiveRequestCountBelowMaximumLimit {
  404 + return self.activeRequestCount < self.maximumActiveDownloads;
  405 +}
  406 +
  407 +@end
  408 +
  409 +#endif
... ...
Example/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h 0 → 100644
  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 <Foundation/Foundation.h>
  23 +
  24 +#import <TargetConditionals.h>
  25 +
  26 +#if TARGET_OS_IOS
  27 +
  28 +#import <UIKit/UIKit.h>
  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
... ...
Example/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m 0 → 100644
  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 + _activityCount = MAX(_activityCount - 1, 0);
  151 + }
  152 + [self didChangeValueForKey:@"activityCount"];
  153 +
  154 + dispatch_async(dispatch_get_main_queue(), ^{
  155 + [self updateCurrentStateForNetworkActivityChange];
  156 + });
  157 +}
  158 +
  159 +- (void)networkRequestDidStart:(NSNotification *)notification {
  160 + if ([AFNetworkRequestFromNotification(notification) URL]) {
  161 + [self incrementActivityCount];
  162 + }
  163 +}
  164 +
  165 +- (void)networkRequestDidFinish:(NSNotification *)notification {
  166 + if ([AFNetworkRequestFromNotification(notification) URL]) {
  167 + [self decrementActivityCount];
  168 + }
  169 +}
  170 +
  171 +#pragma mark - Internal State Management
  172 +- (void)setCurrentState:(AFNetworkActivityManagerState)currentState {
  173 + @synchronized(self) {
  174 + if (_currentState != currentState) {
  175 + [self willChangeValueForKey:@"currentState"];
  176 + _currentState = currentState;
  177 + switch (currentState) {
  178 + case AFNetworkActivityManagerStateNotActive:
  179 + [self cancelActivationDelayTimer];
  180 + [self cancelCompletionDelayTimer];
  181 + [self setNetworkActivityIndicatorVisible:NO];
  182 + break;
  183 + case AFNetworkActivityManagerStateDelayingStart:
  184 + [self startActivationDelayTimer];
  185 + break;
  186 + case AFNetworkActivityManagerStateActive:
  187 + [self cancelCompletionDelayTimer];
  188 + [self setNetworkActivityIndicatorVisible:YES];
  189 + break;
  190 + case AFNetworkActivityManagerStateDelayingEnd:
  191 + [self startCompletionDelayTimer];
  192 + break;
  193 + }
  194 + [self didChangeValueForKey:@"currentState"];
  195 + }
  196 +
  197 + }
  198 +}
  199 +
  200 +- (void)updateCurrentStateForNetworkActivityChange {
  201 + if (self.enabled) {
  202 + switch (self.currentState) {
  203 + case AFNetworkActivityManagerStateNotActive:
  204 + if (self.isNetworkActivityOccurring) {
  205 + [self setCurrentState:AFNetworkActivityManagerStateDelayingStart];
  206 + }
  207 + break;
  208 + case AFNetworkActivityManagerStateDelayingStart:
  209 + //No op. Let the delay timer finish out.
  210 + break;
  211 + case AFNetworkActivityManagerStateActive:
  212 + if (!self.isNetworkActivityOccurring) {
  213 + [self setCurrentState:AFNetworkActivityManagerStateDelayingEnd];
  214 + }
  215 + break;
  216 + case AFNetworkActivityManagerStateDelayingEnd:
  217 + if (self.isNetworkActivityOccurring) {
  218 + [self setCurrentState:AFNetworkActivityManagerStateActive];
  219 + }
  220 + break;
  221 + }
  222 + }
  223 +}
  224 +
  225 +- (void)startActivationDelayTimer {
  226 + self.activationDelayTimer = [NSTimer
  227 + timerWithTimeInterval:self.activationDelay target:self selector:@selector(activationDelayTimerFired) userInfo:nil repeats:NO];
  228 + [[NSRunLoop mainRunLoop] addTimer:self.activationDelayTimer forMode:NSRunLoopCommonModes];
  229 +}
  230 +
  231 +- (void)activationDelayTimerFired {
  232 + if (self.networkActivityOccurring) {
  233 + [self setCurrentState:AFNetworkActivityManagerStateActive];
  234 + } else {
  235 + [self setCurrentState:AFNetworkActivityManagerStateNotActive];
  236 + }
  237 +}
  238 +
  239 +- (void)startCompletionDelayTimer {
  240 + [self.completionDelayTimer invalidate];
  241 + self.completionDelayTimer = [NSTimer timerWithTimeInterval:self.completionDelay target:self selector:@selector(completionDelayTimerFired) userInfo:nil repeats:NO];
  242 + [[NSRunLoop mainRunLoop] addTimer:self.completionDelayTimer forMode:NSRunLoopCommonModes];
  243 +}
  244 +
  245 +- (void)completionDelayTimerFired {
  246 + [self setCurrentState:AFNetworkActivityManagerStateNotActive];
  247 +}
  248 +
  249 +- (void)cancelActivationDelayTimer {
  250 + [self.activationDelayTimer invalidate];
  251 +}
  252 +
  253 +- (void)cancelCompletionDelayTimer {
  254 + [self.completionDelayTimer invalidate];
  255 +}
  256 +
  257 +@end
  258 +
  259 +#endif
... ...
Example/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h 0 → 100644
  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 <Foundation/Foundation.h>
  23 +
  24 +#import <TargetConditionals.h>
  25 +
  26 +#if TARGET_OS_IOS || TARGET_OS_TV
  27 +
  28 +#import <UIKit/UIKit.h>
  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
... ...
Example/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m 0 → 100644
  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 <objc/runtime.h>
  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 + UIActivityIndicatorView *activityIndicatorView = self.activityIndicatorView;
  75 + if (task.state == NSURLSessionTaskStateRunning) {
  76 + [activityIndicatorView startAnimating];
  77 + } else {
  78 + [activityIndicatorView stopAnimating];
  79 + }
  80 +
  81 + [notificationCenter addObserver:self selector:@selector(af_startAnimating) name:AFNetworkingTaskDidResumeNotification object:task];
  82 + [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidCompleteNotification object:task];
  83 + [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidSuspendNotification object:task];
  84 + }
  85 + }
  86 +}
  87 +
  88 +#pragma mark -
  89 +
  90 +- (void)af_startAnimating {
  91 + dispatch_async(dispatch_get_main_queue(), ^{
  92 + [self.activityIndicatorView startAnimating];
  93 + });
  94 +}
  95 +
  96 +- (void)af_stopAnimating {
  97 + dispatch_async(dispatch_get_main_queue(), ^{
  98 + [self.activityIndicatorView stopAnimating];
  99 + });
  100 +}
  101 +
  102 +#pragma mark -
  103 +
  104 +- (void)dealloc {
  105 + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
  106 +
  107 + [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil];
  108 + [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil];
  109 + [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil];
  110 +}
  111 +
  112 +@end
  113 +
  114 +#endif
... ...
Example/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h 0 → 100644
  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 <Foundation/Foundation.h>
  23 +
  24 +#import <TargetConditionals.h>
  25 +
  26 +#if TARGET_OS_IOS || TARGET_OS_TV
  27 +
  28 +#import <UIKit/UIKit.h>
  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
... ...
Example/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.m 0 → 100644
  1 +// UIButton+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 "UIButton+AFNetworking.h"
  23 +
  24 +#import <objc/runtime.h>
  25 +
  26 +#if TARGET_OS_IOS || TARGET_OS_TV
  27 +
  28 +#import "UIImageView+AFNetworking.h"
  29 +#import "AFImageDownloader.h"
  30 +
  31 +@interface UIButton (_AFNetworking)
  32 +@end
  33 +
  34 +@implementation UIButton (_AFNetworking)
  35 +
  36 +#pragma mark -
  37 +
  38 +static char AFImageDownloadReceiptNormal;
  39 +static char AFImageDownloadReceiptHighlighted;
  40 +static char AFImageDownloadReceiptSelected;
  41 +static char AFImageDownloadReceiptDisabled;
  42 +
  43 +static const char * af_imageDownloadReceiptKeyForState(UIControlState state) {
  44 + switch (state) {
  45 + case UIControlStateHighlighted:
  46 + return &AFImageDownloadReceiptHighlighted;
  47 + case UIControlStateSelected:
  48 + return &AFImageDownloadReceiptSelected;
  49 + case UIControlStateDisabled:
  50 + return &AFImageDownloadReceiptDisabled;
  51 + case UIControlStateNormal:
  52 + default:
  53 + return &AFImageDownloadReceiptNormal;
  54 + }
  55 +}
  56 +
  57 +- (AFImageDownloadReceipt *)af_imageDownloadReceiptForState:(UIControlState)state {
  58 + return (AFImageDownloadReceipt *)objc_getAssociatedObject(self, af_imageDownloadReceiptKeyForState(state));
  59 +}
  60 +
  61 +- (void)af_setImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt
  62 + forState:(UIControlState)state
  63 +{
  64 + objc_setAssociatedObject(self, af_imageDownloadReceiptKeyForState(state), imageDownloadReceipt, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
  65 +}
  66 +
  67 +#pragma mark -
  68 +
  69 +static char AFBackgroundImageDownloadReceiptNormal;
  70 +static char AFBackgroundImageDownloadReceiptHighlighted;
  71 +static char AFBackgroundImageDownloadReceiptSelected;
  72 +static char AFBackgroundImageDownloadReceiptDisabled;
  73 +
  74 +static const char * af_backgroundImageDownloadReceiptKeyForState(UIControlState state) {
  75 + switch (state) {
  76 + case UIControlStateHighlighted:
  77 + return &AFBackgroundImageDownloadReceiptHighlighted;
  78 + case UIControlStateSelected:
  79 + return &AFBackgroundImageDownloadReceiptSelected;
  80 + case UIControlStateDisabled:
  81 + return &AFBackgroundImageDownloadReceiptDisabled;
  82 + case UIControlStateNormal:
  83 + default:
  84 + return &AFBackgroundImageDownloadReceiptNormal;
  85 + }
  86 +}
  87 +
  88 +- (AFImageDownloadReceipt *)af_backgroundImageDownloadReceiptForState:(UIControlState)state {
  89 + return (AFImageDownloadReceipt *)objc_getAssociatedObject(self, af_backgroundImageDownloadReceiptKeyForState(state));
  90 +}
  91 +
  92 +- (void)af_setBackgroundImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt
  93 + forState:(UIControlState)state
  94 +{
  95 + objc_setAssociatedObject(self, af_backgroundImageDownloadReceiptKeyForState(state), imageDownloadReceipt, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
  96 +}
  97 +
  98 +@end
  99 +
  100 +#pragma mark -
  101 +
  102 +@implementation UIButton (AFNetworking)
  103 +
  104 ++ (AFImageDownloader *)sharedImageDownloader {
  105 +
  106 + return objc_getAssociatedObject(self, @selector(sharedImageDownloader)) ?: [AFImageDownloader defaultInstance];
  107 +}
  108 +
  109 ++ (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader {
  110 + objc_setAssociatedObject(self, @selector(sharedImageDownloader), imageDownloader, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
  111 +}
  112 +
  113 +#pragma mark -
  114 +
  115 +- (void)setImageForState:(UIControlState)state
  116 + withURL:(NSURL *)url
  117 +{
  118 + [self setImageForState:state withURL:url placeholderImage:nil];
  119 +}
  120 +
  121 +- (void)setImageForState:(UIControlState)state
  122 + withURL:(NSURL *)url
  123 + placeholderImage:(UIImage *)placeholderImage
  124 +{
  125 + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
  126 + [request addValue:@"image/*" forHTTPHeaderField:@"Accept"];
  127 +
  128 + [self setImageForState:state withURLRequest:request placeholderImage:placeholderImage success:nil failure:nil];
  129 +}
  130 +
  131 +- (void)setImageForState:(UIControlState)state
  132 + withURLRequest:(NSURLRequest *)urlRequest
  133 + placeholderImage:(nullable UIImage *)placeholderImage
  134 + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success
  135 + failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure
  136 +{
  137 + if ([self isActiveTaskURLEqualToURLRequest:urlRequest forState:state]) {
  138 + return;
  139 + }
  140 +
  141 + [self cancelImageDownloadTaskForState:state];
  142 +
  143 + AFImageDownloader *downloader = [[self class] sharedImageDownloader];
  144 + id <AFImageRequestCache> imageCache = downloader.imageCache;
  145 +
  146 + //Use the image from the image cache if it exists
  147 + UIImage *cachedImage = [imageCache imageforRequest:urlRequest withAdditionalIdentifier:nil];
  148 + if (cachedImage) {
  149 + if (success) {
  150 + success(urlRequest, nil, cachedImage);
  151 + } else {
  152 + [self setImage:cachedImage forState:state];
  153 + }
  154 + [self af_setImageDownloadReceipt:nil forState:state];
  155 + } else {
  156 + if (placeholderImage) {
  157 + [self setImage:placeholderImage forState:state];
  158 + }
  159 +
  160 + __weak __typeof(self)weakSelf = self;
  161 + NSUUID *downloadID = [NSUUID UUID];
  162 + AFImageDownloadReceipt *receipt;
  163 + receipt = [downloader
  164 + downloadImageForURLRequest:urlRequest
  165 + withReceiptID:downloadID
  166 + success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull responseObject) {
  167 + __strong __typeof(weakSelf)strongSelf = weakSelf;
  168 + if ([[strongSelf af_imageDownloadReceiptForState:state].receiptID isEqual:downloadID]) {
  169 + if (success) {
  170 + success(request, response, responseObject);
  171 + } else if(responseObject) {
  172 + [strongSelf setImage:responseObject forState:state];
  173 + }
  174 + [strongSelf af_setImageDownloadReceipt:nil forState:state];
  175 + }
  176 +
  177 + }
  178 + failure:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, NSError * _Nonnull error) {
  179 + __strong __typeof(weakSelf)strongSelf = weakSelf;
  180 + if ([[strongSelf af_imageDownloadReceiptForState:state].receiptID isEqual:downloadID]) {
  181 + if (failure) {
  182 + failure(request, response, error);
  183 + }
  184 + [strongSelf af_setImageDownloadReceipt:nil forState:state];
  185 + }
  186 + }];
  187 +
  188 + [self af_setImageDownloadReceipt:receipt forState:state];
  189 + }
  190 +}
  191 +
  192 +#pragma mark -
  193 +
  194 +- (void)setBackgroundImageForState:(UIControlState)state
  195 + withURL:(NSURL *)url
  196 +{
  197 + [self setBackgroundImageForState:state withURL:url placeholderImage:nil];
  198 +}
  199 +
  200 +- (void)setBackgroundImageForState:(UIControlState)state
  201 + withURL:(NSURL *)url
  202 + placeholderImage:(nullable UIImage *)placeholderImage
  203 +{
  204 + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
  205 + [request addValue:@"image/*" forHTTPHeaderField:@"Accept"];
  206 +
  207 + [self setBackgroundImageForState:state withURLRequest:request placeholderImage:placeholderImage success:nil failure:nil];
  208 +}
  209 +
  210 +- (void)setBackgroundImageForState:(UIControlState)state
  211 + withURLRequest:(NSURLRequest *)urlRequest
  212 + placeholderImage:(nullable UIImage *)placeholderImage
  213 + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success
  214 + failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure
  215 +{
  216 + if ([self isActiveBackgroundTaskURLEqualToURLRequest:urlRequest forState:state]) {
  217 + return;
  218 + }
  219 +
  220 + [self cancelBackgroundImageDownloadTaskForState:state];
  221 +
  222 + AFImageDownloader *downloader = [[self class] sharedImageDownloader];
  223 + id <AFImageRequestCache> imageCache = downloader.imageCache;
  224 +
  225 + //Use the image from the image cache if it exists
  226 + UIImage *cachedImage = [imageCache imageforRequest:urlRequest withAdditionalIdentifier:nil];
  227 + if (cachedImage) {
  228 + if (success) {
  229 + success(urlRequest, nil, cachedImage);
  230 + } else {
  231 + [self setBackgroundImage:cachedImage forState:state];
  232 + }
  233 + [self af_setBackgroundImageDownloadReceipt:nil forState:state];
  234 + } else {
  235 + if (placeholderImage) {
  236 + [self setBackgroundImage:placeholderImage forState:state];
  237 + }
  238 +
  239 + __weak __typeof(self)weakSelf = self;
  240 + NSUUID *downloadID = [NSUUID UUID];
  241 + AFImageDownloadReceipt *receipt;
  242 + receipt = [downloader
  243 + downloadImageForURLRequest:urlRequest
  244 + withReceiptID:downloadID
  245 + success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull responseObject) {
  246 + __strong __typeof(weakSelf)strongSelf = weakSelf;
  247 + if ([[strongSelf af_backgroundImageDownloadReceiptForState:state].receiptID isEqual:downloadID]) {
  248 + if (success) {
  249 + success(request, response, responseObject);
  250 + } else if(responseObject) {
  251 + [strongSelf setBackgroundImage:responseObject forState:state];
  252 + }
  253 + [strongSelf af_setBackgroundImageDownloadReceipt:nil forState:state];
  254 + }
  255 +
  256 + }
  257 + failure:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, NSError * _Nonnull error) {
  258 + __strong __typeof(weakSelf)strongSelf = weakSelf;
  259 + if ([[strongSelf af_backgroundImageDownloadReceiptForState:state].receiptID isEqual:downloadID]) {
  260 + if (failure) {
  261 + failure(request, response, error);
  262 + }
  263 + [strongSelf af_setBackgroundImageDownloadReceipt:nil forState:state];
  264 + }
  265 + }];
  266 +
  267 + [self af_setBackgroundImageDownloadReceipt:receipt forState:state];
  268 + }
  269 +}
  270 +
  271 +#pragma mark -
  272 +
  273 +- (void)cancelImageDownloadTaskForState:(UIControlState)state {
  274 + AFImageDownloadReceipt *receipt = [self af_imageDownloadReceiptForState:state];
  275 + if (receipt != nil) {
  276 + [[self.class sharedImageDownloader] cancelTaskForImageDownloadReceipt:receipt];
  277 + [self af_setImageDownloadReceipt:nil forState:state];
  278 + }
  279 +}
  280 +
  281 +- (void)cancelBackgroundImageDownloadTaskForState:(UIControlState)state {
  282 + AFImageDownloadReceipt *receipt = [self af_backgroundImageDownloadReceiptForState:state];
  283 + if (receipt != nil) {
  284 + [[self.class sharedImageDownloader] cancelTaskForImageDownloadReceipt:receipt];
  285 + [self af_setBackgroundImageDownloadReceipt:nil forState:state];
  286 + }
  287 +}
  288 +
  289 +- (BOOL)isActiveTaskURLEqualToURLRequest:(NSURLRequest *)urlRequest forState:(UIControlState)state {
  290 + AFImageDownloadReceipt *receipt = [self af_imageDownloadReceiptForState:state];
  291 + return [receipt.task.originalRequest.URL.absoluteString isEqualToString:urlRequest.URL.absoluteString];
  292 +}
  293 +
  294 +- (BOOL)isActiveBackgroundTaskURLEqualToURLRequest:(NSURLRequest *)urlRequest forState:(UIControlState)state {
  295 + AFImageDownloadReceipt *receipt = [self af_backgroundImageDownloadReceiptForState:state];
  296 + return [receipt.task.originalRequest.URL.absoluteString isEqualToString:urlRequest.URL.absoluteString];
  297 +}
  298 +
  299 +
  300 +@end
  301 +
  302 +#endif
... ...
Example/Pods/AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h 0 → 100644
  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 <UIKit/UIKit.h>
  28 +
  29 +@interface UIImage (AFNetworking)
  30 +
  31 ++ (UIImage*) safeImageWithData:(NSData*)data;
  32 +
  33 +@end
  34 +
  35 +#endif
... ...
Example/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h 0 → 100644
  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 <Foundation/Foundation.h>
  23 +
  24 +#import <TargetConditionals.h>
  25 +
  26 +#if TARGET_OS_IOS || TARGET_OS_TV
  27 +
  28 +#import <UIKit/UIKit.h>
  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
... ...
Example/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.m 0 → 100644
  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 <objc/runtime.h>
  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 + return objc_getAssociatedObject(self, @selector(sharedImageDownloader)) ?: [AFImageDownloader defaultInstance];
  52 +}
  53 +
  54 ++ (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader {
  55 + objc_setAssociatedObject(self, @selector(sharedImageDownloader), imageDownloader, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
  56 +}
  57 +
  58 +#pragma mark -
  59 +
  60 +- (void)setImageWithURL:(NSURL *)url {
  61 + [self setImageWithURL:url placeholderImage:nil];
  62 +}
  63 +
  64 +- (void)setImageWithURL:(NSURL *)url
  65 + placeholderImage:(UIImage *)placeholderImage
  66 +{
  67 + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
  68 + [request addValue:@"image/*" forHTTPHeaderField:@"Accept"];
  69 +
  70 + [self setImageWithURLRequest:request placeholderImage:placeholderImage success:nil failure:nil];
  71 +}
  72 +
  73 +- (void)setImageWithURLRequest:(NSURLRequest *)urlRequest
  74 + placeholderImage:(UIImage *)placeholderImage
  75 + success:(void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success
  76 + failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure
  77 +{
  78 +
  79 + if ([urlRequest URL] == nil) {
  80 + self.image = placeholderImage;
  81 + if (failure) {
  82 + NSError *error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorBadURL userInfo:nil];
  83 + failure(urlRequest, nil, error);
  84 + }
  85 + return;
  86 + }
  87 +
  88 + if ([self isActiveTaskURLEqualToURLRequest:urlRequest]){
  89 + return;
  90 + }
  91 +
  92 + [self cancelImageDownloadTask];
  93 +
  94 + AFImageDownloader *downloader = [[self class] sharedImageDownloader];
  95 + id <AFImageRequestCache> imageCache = downloader.imageCache;
  96 +
  97 + //Use the image from the image cache if it exists
  98 + UIImage *cachedImage = [imageCache imageforRequest:urlRequest withAdditionalIdentifier:nil];
  99 + if (cachedImage) {
  100 + if (success) {
  101 + success(urlRequest, nil, cachedImage);
  102 + } else {
  103 + self.image = cachedImage;
  104 + }
  105 + [self clearActiveDownloadInformation];
  106 + } else {
  107 + if (placeholderImage) {
  108 + self.image = placeholderImage;
  109 + }
  110 +
  111 + __weak __typeof(self)weakSelf = self;
  112 + NSUUID *downloadID = [NSUUID UUID];
  113 + AFImageDownloadReceipt *receipt;
  114 + receipt = [downloader
  115 + downloadImageForURLRequest:urlRequest
  116 + withReceiptID:downloadID
  117 + success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull responseObject) {
  118 + __strong __typeof(weakSelf)strongSelf = weakSelf;
  119 + if ([strongSelf.af_activeImageDownloadReceipt.receiptID isEqual:downloadID]) {
  120 + if (success) {
  121 + success(request, response, responseObject);
  122 + } else if(responseObject) {
  123 + strongSelf.image = responseObject;
  124 + }
  125 + [strongSelf clearActiveDownloadInformation];
  126 + }
  127 +
  128 + }
  129 + failure:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, NSError * _Nonnull error) {
  130 + __strong __typeof(weakSelf)strongSelf = weakSelf;
  131 + if ([strongSelf.af_activeImageDownloadReceipt.receiptID isEqual:downloadID]) {
  132 + if (failure) {
  133 + failure(request, response, error);
  134 + }
  135 + [strongSelf clearActiveDownloadInformation];
  136 + }
  137 + }];
  138 +
  139 + self.af_activeImageDownloadReceipt = receipt;
  140 + }
  141 +}
  142 +
  143 +- (void)cancelImageDownloadTask {
  144 + if (self.af_activeImageDownloadReceipt != nil) {
  145 + [[self.class sharedImageDownloader] cancelTaskForImageDownloadReceipt:self.af_activeImageDownloadReceipt];
  146 + [self clearActiveDownloadInformation];
  147 + }
  148 +}
  149 +
  150 +- (void)clearActiveDownloadInformation {
  151 + self.af_activeImageDownloadReceipt = nil;
  152 +}
  153 +
  154 +- (BOOL)isActiveTaskURLEqualToURLRequest:(NSURLRequest *)urlRequest {
  155 + return [self.af_activeImageDownloadReceipt.task.originalRequest.URL.absoluteString isEqualToString:urlRequest.URL.absoluteString];
  156 +}
  157 +
  158 +@end
  159 +
  160 +#endif
... ...
Example/Pods/AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h 0 → 100644
  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 <UIKit/UIKit.h>
  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
... ...
Example/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h 0 → 100644
  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 <Foundation/Foundation.h>
  23 +
  24 +#import <TargetConditionals.h>
  25 +
  26 +#if TARGET_OS_IOS || TARGET_OS_TV
  27 +
  28 +#import <UIKit/UIKit.h>
  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
... ...
Example/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.m 0 → 100644
  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 <objc/runtime.h>
  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 + if (task.state == NSURLSessionTaskStateCompleted) {
  59 + return;
  60 + }
  61 +
  62 + [task addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesSentContext];
  63 + [task addObserver:self forKeyPath:@"countOfBytesSent" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesSentContext];
  64 +
  65 + [self af_setUploadProgressAnimated:animated];
  66 +}
  67 +
  68 +- (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task
  69 + animated:(BOOL)animated
  70 +{
  71 + if (task.state == NSURLSessionTaskStateCompleted) {
  72 + return;
  73 + }
  74 +
  75 + [task addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesReceivedContext];
  76 + [task addObserver:self forKeyPath:@"countOfBytesReceived" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesReceivedContext];
  77 +
  78 + [self af_setDownloadProgressAnimated:animated];
  79 +}
  80 +
  81 +#pragma mark - NSKeyValueObserving
  82 +
  83 +- (void)observeValueForKeyPath:(NSString *)keyPath
  84 + ofObject:(id)object
  85 + change:(__unused NSDictionary *)change
  86 + context:(void *)context
  87 +{
  88 + if (context == AFTaskCountOfBytesSentContext || context == AFTaskCountOfBytesReceivedContext) {
  89 + if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesSent))]) {
  90 + if ([object countOfBytesExpectedToSend] > 0) {
  91 + dispatch_async(dispatch_get_main_queue(), ^{
  92 + [self setProgress:[object countOfBytesSent] / ([object countOfBytesExpectedToSend] * 1.0f) animated:self.af_uploadProgressAnimated];
  93 + });
  94 + }
  95 + }
  96 +
  97 + if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesReceived))]) {
  98 + if ([object countOfBytesExpectedToReceive] > 0) {
  99 + dispatch_async(dispatch_get_main_queue(), ^{
  100 + [self setProgress:[object countOfBytesReceived] / ([object countOfBytesExpectedToReceive] * 1.0f) animated:self.af_downloadProgressAnimated];
  101 + });
  102 + }
  103 + }
  104 +
  105 + if ([keyPath isEqualToString:NSStringFromSelector(@selector(state))]) {
  106 + if ([(NSURLSessionTask *)object state] == NSURLSessionTaskStateCompleted) {
  107 + @try {
  108 + [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(state))];
  109 +
  110 + if (context == AFTaskCountOfBytesSentContext) {
  111 + [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesSent))];
  112 + }
  113 +
  114 + if (context == AFTaskCountOfBytesReceivedContext) {
  115 + [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesReceived))];
  116 + }
  117 + }
  118 + @catch (NSException * __unused exception) {}
  119 + }
  120 + }
  121 + }
  122 +}
  123 +
  124 +@end
  125 +
  126 +#endif
... ...
Example/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h 0 → 100644
  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 <Foundation/Foundation.h>
  24 +
  25 +#import <TargetConditionals.h>
  26 +
  27 +#if TARGET_OS_IOS
  28 +
  29 +#import <UIKit/UIKit.h>
  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
... ...
Example/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m 0 → 100644
  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 <objc/runtime.h>
  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 + UIRefreshControl *refreshControl = self.refreshControl;
  75 + if (task.state == NSURLSessionTaskStateRunning) {
  76 + [refreshControl beginRefreshing];
  77 +
  78 + [notificationCenter addObserver:self selector:@selector(af_beginRefreshing) name:AFNetworkingTaskDidResumeNotification object:task];
  79 + [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidCompleteNotification object:task];
  80 + [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidSuspendNotification object:task];
  81 + } else {
  82 + [refreshControl endRefreshing];
  83 + }
  84 + }
  85 +}
  86 +
  87 +#pragma mark -
  88 +
  89 +- (void)af_beginRefreshing {
  90 + dispatch_async(dispatch_get_main_queue(), ^{
  91 + [self.refreshControl beginRefreshing];
  92 + });
  93 +}
  94 +
  95 +- (void)af_endRefreshing {
  96 + dispatch_async(dispatch_get_main_queue(), ^{
  97 + [self.refreshControl endRefreshing];
  98 + });
  99 +}
  100 +
  101 +#pragma mark -
  102 +
  103 +- (void)dealloc {
  104 + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
  105 +
  106 + [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil];
  107 + [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil];
  108 + [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil];
  109 +}
  110 +
  111 +@end
  112 +
  113 +#endif
... ...
Example/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h 0 → 100644
  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 <Foundation/Foundation.h>
  23 +
  24 +#import <TargetConditionals.h>
  25 +
  26 +#if TARGET_OS_IOS
  27 +
  28 +#import <UIKit/UIKit.h>
  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
... ...
Example/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.m 0 → 100644
  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 <objc/runtime.h>
  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 + return objc_getAssociatedObject(self, @selector(sessionManager)) ?: _af_defaultHTTPSessionManager;
  62 +}
  63 +
  64 +- (void)setSessionManager:(AFHTTPSessionManager *)sessionManager {
  65 + objc_setAssociatedObject(self, @selector(sessionManager), sessionManager, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
  66 +}
  67 +
  68 +- (AFHTTPResponseSerializer <AFURLResponseSerialization> *)responseSerializer {
  69 + static AFHTTPResponseSerializer <AFURLResponseSerialization> *_af_defaultResponseSerializer = nil;
  70 + static dispatch_once_t onceToken;
  71 + dispatch_once(&onceToken, ^{
  72 + _af_defaultResponseSerializer = [AFHTTPResponseSerializer serializer];
  73 + });
  74 +
  75 + return objc_getAssociatedObject(self, @selector(responseSerializer)) ?: _af_defaultResponseSerializer;
  76 +}
  77 +
  78 +- (void)setResponseSerializer:(AFHTTPResponseSerializer<AFURLResponseSerialization> *)responseSerializer {
  79 + objc_setAssociatedObject(self, @selector(responseSerializer), responseSerializer, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
  80 +}
  81 +
  82 +#pragma mark -
  83 +
  84 +- (void)loadRequest:(NSURLRequest *)request
  85 + progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress
  86 + success:(NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success
  87 + failure:(void (^)(NSError *error))failure
  88 +{
  89 + [self loadRequest:request MIMEType:nil textEncodingName:nil progress:progress success:^NSData *(NSHTTPURLResponse *response, NSData *data) {
  90 + NSStringEncoding stringEncoding = NSUTF8StringEncoding;
  91 + if (response.textEncodingName) {
  92 + CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)response.textEncodingName);
  93 + if (encoding != kCFStringEncodingInvalidId) {
  94 + stringEncoding = CFStringConvertEncodingToNSStringEncoding(encoding);
  95 + }
  96 + }
  97 +
  98 + NSString *string = [[NSString alloc] initWithData:data encoding:stringEncoding];
  99 + if (success) {
  100 + string = success(response, string);
  101 + }
  102 +
  103 + return [string dataUsingEncoding:stringEncoding];
  104 + } failure:failure];
  105 +}
  106 +
  107 +- (void)loadRequest:(NSURLRequest *)request
  108 + MIMEType:(NSString *)MIMEType
  109 + textEncodingName:(NSString *)textEncodingName
  110 + progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress
  111 + success:(NSData * (^)(NSHTTPURLResponse *response, NSData *data))success
  112 + failure:(void (^)(NSError *error))failure
  113 +{
  114 + NSParameterAssert(request);
  115 +
  116 + if (self.af_URLSessionTask.state == NSURLSessionTaskStateRunning || self.af_URLSessionTask.state == NSURLSessionTaskStateSuspended) {
  117 + [self.af_URLSessionTask cancel];
  118 + }
  119 + self.af_URLSessionTask = nil;
  120 +
  121 + __weak __typeof(self)weakSelf = self;
  122 + __block NSURLSessionDataTask *dataTask;
  123 + dataTask = [self.sessionManager
  124 + dataTaskWithRequest:request
  125 + uploadProgress:nil
  126 + downloadProgress:nil
  127 + completionHandler:^(NSURLResponse * _Nonnull response, id _Nonnull responseObject, NSError * _Nullable error) {
  128 + __strong __typeof(weakSelf) strongSelf = weakSelf;
  129 + if (error) {
  130 + if (failure) {
  131 + failure(error);
  132 + }
  133 + } else {
  134 + if (success) {
  135 + success((NSHTTPURLResponse *)response, responseObject);
  136 + }
  137 + [strongSelf loadData:responseObject MIMEType:MIMEType textEncodingName:textEncodingName baseURL:[dataTask.currentRequest URL]];
  138 +
  139 + if ([strongSelf.delegate respondsToSelector:@selector(webViewDidFinishLoad:)]) {
  140 + [strongSelf.delegate webViewDidFinishLoad:strongSelf];
  141 + }
  142 + }
  143 + }];
  144 + self.af_URLSessionTask = dataTask;
  145 + if (progress != nil) {
  146 + *progress = [self.sessionManager downloadProgressForTask:dataTask];
  147 + }
  148 + [self.af_URLSessionTask resume];
  149 +
  150 + if ([self.delegate respondsToSelector:@selector(webViewDidStartLoad:)]) {
  151 + [self.delegate webViewDidStartLoad:self];
  152 + }
  153 +}
  154 +
  155 +@end
  156 +
  157 +#endif
... ...
Example/Pods/Local Podspecs/CNLivePublishContent.podspec.json
1 1 {
2 2 "name": "CNLivePublishContent",
3   - "version": "0.1.0",
4   - "summary": "A short description of CNLivePublishContent.",
5   - "description": "TODO: Add long description of the pod here.",
6   - "homepage": "https://github.com/殷巧娟/CNLivePublishContent",
  3 + "version": "0.0.1",
  4 + "summary": "测试组件化",
  5 + "homepage": "http://bj.gitlab.cnlive.com/ios-team/CNLivePublishContents",
7 6 "license": {
8 7 "type": "MIT",
9 8 "file": "LICENSE"
... ... @@ -12,11 +11,20 @@
12 11 "殷巧娟": "1427945373@qq.com"
13 12 },
14 13 "source": {
15   - "git": "https://github.com/殷巧娟/CNLivePublishContent.git",
16   - "tag": "0.1.0"
  14 + "git": "http://bj.gitlab.cnlive.com/ios-team/CNLivePublishContents.git",
  15 + "tag": "0.0.1"
17 16 },
18 17 "platforms": {
19   - "ios": "8.0"
  18 + "ios": "9.0"
20 19 },
21   - "source_files": "CNLivePublishContent/Classes/**/*"
  20 + "source_files": "CNLivePublishContent/Classes/**/*.{h,m}",
  21 + "frameworks": [
  22 + "UIKit",
  23 + "Foundation"
  24 + ],
  25 + "dependencies": {
  26 + "AFNetworking": [
  27 +
  28 + ]
  29 + }
22 30 }
... ...
Example/Pods/Manifest.lock
1 1 PODS:
2   - - CNLivePublishContent (0.1.0)
  2 + - AFNetworking (3.2.1):
  3 + - AFNetworking/NSURLSession (= 3.2.1)
  4 + - AFNetworking/Reachability (= 3.2.1)
  5 + - AFNetworking/Security (= 3.2.1)
  6 + - AFNetworking/Serialization (= 3.2.1)
  7 + - AFNetworking/UIKit (= 3.2.1)
  8 + - AFNetworking/NSURLSession (3.2.1):
  9 + - AFNetworking/Reachability
  10 + - AFNetworking/Security
  11 + - AFNetworking/Serialization
  12 + - AFNetworking/Reachability (3.2.1)
  13 + - AFNetworking/Security (3.2.1)
  14 + - AFNetworking/Serialization (3.2.1)
  15 + - AFNetworking/UIKit (3.2.1):
  16 + - AFNetworking/NSURLSession
  17 + - CNLivePublishContent (0.0.1):
  18 + - AFNetworking
3 19  
4 20 DEPENDENCIES:
  21 + - AFNetworking
5 22 - CNLivePublishContent (from `../`)
6 23  
  24 +SPEC REPOS:
  25 + https://github.com/cocoapods/specs.git:
  26 + - AFNetworking
  27 +
7 28 EXTERNAL SOURCES:
8 29 CNLivePublishContent:
9 30 :path: "../"
10 31  
11 32 SPEC CHECKSUMS:
12   - CNLivePublishContent: efc4d0c9e97d82c10cbb9a0f46c529746aba9a16
  33 + AFNetworking: b6f891fdfaed196b46c7a83cf209e09697b94057
  34 + CNLivePublishContent: 150e8b7a22533392991c94cb1f48c29ce636ffa2
13 35  
14   -PODFILE CHECKSUM: efac94bc6984e6197fee85d997a2f2e01b62a039
  36 +PODFILE CHECKSUM: 63184c0b0bc99c2f33e9180bc374c50d728e4a35
15 37  
16 38 COCOAPODS: 1.5.3
... ...
Example/Pods/Pods.xcodeproj/project.pbxproj
... ... @@ -7,188 +7,352 @@
7 7 objects = {
8 8  
9 9 /* Begin PBXBuildFile section */
10   - 199818674B4AEA5670BA25AD9400B14A /* Pods-CNLivePublishContent_Example-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = A98533A4379497FD4E0C285CA2F7B56E /* Pods-CNLivePublishContent_Example-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; };
11   - 208D1CC3C704D8D3322B1450BEF4D9B1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D6DFF15000AFE2A371BF499E7AFDA808 /* Foundation.framework */; };
12   - 23CC76C4526811D5A3B51D52567367C5 /* CNLivePublishContent-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 0C0CDA4DF377FE9B4EC9B0ABB3F8C584 /* CNLivePublishContent-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; };
13   - 3C409600071D0152CE5D9A8DA9C00820 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D6DFF15000AFE2A371BF499E7AFDA808 /* Foundation.framework */; };
14   - 4E0455FE21B7DEE300A2D934 /* YQJTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E0455F821B7DEE300A2D934 /* YQJTest.m */; };
15   - 4E04560021B7DEE300A2D934 /* YQJTest.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E0455FA21B7DEE300A2D934 /* YQJTest.h */; };
16   - 7DE63A1F998683E0AEEE41EE6C1BB3A6 /* Pods-CNLivePublishContent_Tests-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = E2861D05CFE6B3A84C7044909EE26035 /* Pods-CNLivePublishContent_Tests-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; };
17   - 7E0C5A4DB7D2F502E2BAAF759C12B50A /* Pods-CNLivePublishContent_Example-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 806B7A4A2134DC7EEB9C2F58642ECD7F /* Pods-CNLivePublishContent_Example-dummy.m */; };
18   - 8D8EC7DF8F024D7B55FB8EAD45B8BA4A /* Pods-CNLivePublishContent_Tests-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B56CFCC9EAF366F03AC9CFE348D9D58 /* Pods-CNLivePublishContent_Tests-dummy.m */; };
19   - D0C7D0F5C3A5B1E810539218F5BE8264 /* CNLivePublishContent-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 8014DA110BF7F457F9A136B80A7B894E /* CNLivePublishContent-dummy.m */; };
20   - E12A6222EBE7826361ACA060047F5745 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D6DFF15000AFE2A371BF499E7AFDA808 /* Foundation.framework */; };
  10 + 00B5FE91BE9DE9E2BACFA5C72517182F /* Pods-CNLivePublishContent_Example-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = A98533A4379497FD4E0C285CA2F7B56E /* Pods-CNLivePublishContent_Example-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; };
  11 + 00E2C1092D2255BB25E45DF004D3E7E5 /* UIWebView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = E79F20FA67EF326AC8DE380E6118EBF4 /* UIWebView+AFNetworking.m */; };
  12 + 00ED59EE2784CE922358E57E241A6C75 /* UIRefreshControl+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 940F9DBBD5FB7E51683C5858A06D1B91 /* UIRefreshControl+AFNetworking.m */; };
  13 + 0D58399A6DC61099900309A4449F7891 /* AFURLSessionManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 72C208217BB6EAB64559C0AC437E799C /* AFURLSessionManager.m */; };
  14 + 11EAB2A17E2712DB04831AD0FFD6A5DB /* AFURLResponseSerialization.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A821F310F9CBCED06C1D6DEC3103B24 /* AFURLResponseSerialization.m */; };
  15 + 137A6E8841A2429C00CBFA701695197E /* AFNetworkReachabilityManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 1AB3C1AE13FE37CFF6F471AF2B1E701D /* AFNetworkReachabilityManager.m */; };
  16 + 146B923ABED8ABBAE25A960876698AF7 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B234B3D6CCF479B936C41E947A49AA62 /* Foundation.framework */; };
  17 + 15304B6383EF69EC4E3DE45F8613BE2E /* UIRefreshControl+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = C90CE9B626C1720C9ADB8FF999E47D68 /* UIRefreshControl+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; };
  18 + 15F1AB626337FECD0B9CFAAD90FAC342 /* AFNetworkActivityIndicatorManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 443C446A800F6280C03E64AF14170EC0 /* AFNetworkActivityIndicatorManager.m */; };
  19 + 1C7CB086EBAC66BA416E2E1AC7CF197F /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 695564614B55CEEC9BCFB223C0781E46 /* UIKit.framework */; };
  20 + 1DED0CC29970F878261799A26EF463BB /* CNLivePublishContent-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 79081AD8422817466BE162D409861670 /* CNLivePublishContent-dummy.m */; };
  21 + 23331C9D43DE08E12CB7750F9781D84C /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B234B3D6CCF479B936C41E947A49AA62 /* Foundation.framework */; };
  22 + 24C902F46B1A630D344D4FA287DA05C7 /* AFNetworking.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 040C09B94F19533FBD391278CB20185D /* AFNetworking.framework */; };
  23 + 2C06A2EDBAE6B3C9DF4302E17A9A72C0 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B234B3D6CCF479B936C41E947A49AA62 /* Foundation.framework */; };
  24 + 2E68973739E2AE713059A22F94238C60 /* AFURLResponseSerialization.h in Headers */ = {isa = PBXBuildFile; fileRef = CFB2918FE96D6AE88B6CA1AB13D6E730 /* AFURLResponseSerialization.h */; settings = {ATTRIBUTES = (Public, ); }; };
  25 + 328CCD10C2469209E1D2DD55268E154D /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C97BFEE825E260FD2CB926EB42CF21CE /* SystemConfiguration.framework */; };
  26 + 3CC1558D8899A2E13A968D4C403CD793 /* AFCompatibilityMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C8AE42D5A69E862E48EC78FF350078 /* AFCompatibilityMacros.h */; settings = {ATTRIBUTES = (Public, ); }; };
  27 + 402EB64C59857FE252DC98844643C420 /* UIButton+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = E5CE85E1EB18AE94164507FF5D433CE6 /* UIButton+AFNetworking.m */; };
  28 + 41FD4D0D6101210E26DDDCDD17FBB7C3 /* UIImageView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A23D5B238032195CA6F925D556B9F96 /* UIImageView+AFNetworking.m */; };
  29 + 437D16EC401C087F549FA709C91CF786 /* CNLivePublishContent-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = FE190B1BDA96365D405860A48D8C8C86 /* CNLivePublishContent-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; };
  30 + 5A4C39ACCE4CE7B6C69C736F48087759 /* AFHTTPSessionManager.m in Sources */ = {isa = PBXBuildFile; fileRef = CC88013A13A80BA08140FC1D0FC17CAD /* AFHTTPSessionManager.m */; };
  31 + 5BD586FD5A79C8F85C9B6F20E9D90D90 /* Pods-CNLivePublishContent_Tests-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = E2861D05CFE6B3A84C7044909EE26035 /* Pods-CNLivePublishContent_Tests-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; };
  32 + 616166BD57B8707EC940068BF5E1AA0A /* AFImageDownloader.h in Headers */ = {isa = PBXBuildFile; fileRef = CC18ED6BD8558D5E0970879CD6A9291E /* AFImageDownloader.h */; settings = {ATTRIBUTES = (Public, ); }; };
  33 + 63A7B518E880C7AACABCD20AFA247C8C /* AFSecurityPolicy.m in Sources */ = {isa = PBXBuildFile; fileRef = 559947ACFC2291BE83F8DEC005B7101D /* AFSecurityPolicy.m */; };
  34 + 6499BE821A569363EA3F09B2EA06882A /* YQJTest.h in Headers */ = {isa = PBXBuildFile; fileRef = 84795C057289AA4ADF694D7E2C0A7844 /* YQJTest.h */; settings = {ATTRIBUTES = (Public, ); }; };
  35 + 66340E06FB146280E83112B966E563C3 /* AFNetworkReachabilityManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 353BE42A5F94DADECC35B1DBDA6A1231 /* AFNetworkReachabilityManager.h */; settings = {ATTRIBUTES = (Public, ); }; };
  36 + 6A5E05D187005E863177B45D58905C71 /* AFImageDownloader.m in Sources */ = {isa = PBXBuildFile; fileRef = 2658E99DDD8EA7B96318F002C7B157B0 /* AFImageDownloader.m */; };
  37 + 6C7C6C542448137FC3B6CEA04386780C /* AFHTTPSessionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 09BDA8426E671B3F1385057205E67201 /* AFHTTPSessionManager.h */; settings = {ATTRIBUTES = (Public, ); }; };
  38 + 78F5D40D5B8E9FC40FB257953EA945BA /* UIImage+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = AB81F5B5A19D6F63D51E00BB9E746058 /* UIImage+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; };
  39 + 7964C4CDB394B0C4DCFEC7D92E14D71A /* Pods-CNLivePublishContent_Tests-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B56CFCC9EAF366F03AC9CFE348D9D58 /* Pods-CNLivePublishContent_Tests-dummy.m */; };
  40 + 839FA294A4A7A2C23B0149D5F947BAB3 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F6839DA55EA6731EB2DFFA59518EE4A7 /* Security.framework */; };
  41 + 8826A0887EEE1A618FA3BA34989E05B5 /* AFNetworking-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B111A72E572F236A399CC7F2E7D3E85 /* AFNetworking-dummy.m */; };
  42 + 88A52F2DE87FAAEF79B420CC9B6BDE80 /* AFNetworking-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = BF1D89BEED3766388A77B2FCB9912393 /* AFNetworking-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; };
  43 + 8AD9F8FE36978CB4348E402207950883 /* AFAutoPurgingImageCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 6361979267EDE0860632095FC6EA4D87 /* AFAutoPurgingImageCache.h */; settings = {ATTRIBUTES = (Public, ); }; };
  44 + 901790CB7729E8871AE5DE99E486792B /* AFSecurityPolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = BB00ADDE9C30E36EB99FA89E831E4590 /* AFSecurityPolicy.h */; settings = {ATTRIBUTES = (Public, ); }; };
  45 + 9486D80CC092F8ACB2355D5C94A155E3 /* AFAutoPurgingImageCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 1174ABA877619CC640989D6AC9A07DF1 /* AFAutoPurgingImageCache.m */; };
  46 + 9D380619079479C622272E2C77FCD289 /* AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 0929494D86649284B6A56EAB3F91B303 /* AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; };
  47 + A39E1924915C53C49E7220F72AD96BBB /* UIKit+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = F1423F692F2541CFE55253BC467F0025 /* UIKit+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; };
  48 + A6788BD629798B6F13289D01BD549782 /* YQJTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 255176BDE664FDC3EEF3EE888A26EB86 /* YQJTest.m */; };
  49 + AA24F65AF676F6428D3F2B0D3A03B816 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B744E8CFDCDC5D9B41CC93E86AF702B1 /* CoreGraphics.framework */; };
  50 + B27AB9936E094171E3A6371570FDD397 /* Pods-CNLivePublishContent_Example-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 806B7A4A2134DC7EEB9C2F58642ECD7F /* Pods-CNLivePublishContent_Example-dummy.m */; };
  51 + BEE7FD5C1C06AF3670E0FB75F996DDF7 /* UIButton+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D1C251DFB2D3B0E60259BE56A85C5BA /* UIButton+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; };
  52 + C8D816A742203B5D50B79348DFDDE4BD /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 443AC79FE304CEF4E800C982B445221E /* MobileCoreServices.framework */; };
  53 + CB3028664CA23A1480C18C7A86CFDAF4 /* UIActivityIndicatorView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = BE62D258251F0E3CC57836C93584D335 /* UIActivityIndicatorView+AFNetworking.m */; };
  54 + CB3CA20E3732A095F5515E0621D8719C /* AFURLRequestSerialization.m in Sources */ = {isa = PBXBuildFile; fileRef = FAF9AB0D2DE5398A86009837A2760BAD /* AFURLRequestSerialization.m */; };
  55 + CB633AF10D27AD0971F3E34470B0BB01 /* UIWebView+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 9FB33A30129B406EB1BD224B6B630B80 /* UIWebView+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; };
  56 + D014A5430789C5F0FFCF490D53B22897 /* UIActivityIndicatorView+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 0AF376080E12057AC937F6E1F0D7CB5D /* UIActivityIndicatorView+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; };
  57 + D491FD44351A11016A957CA81ABE0EC5 /* AFURLRequestSerialization.h in Headers */ = {isa = PBXBuildFile; fileRef = 05BFBAF94DDF04E8BDBF6323835FB9BC /* AFURLRequestSerialization.h */; settings = {ATTRIBUTES = (Public, ); }; };
  58 + DF74915F8F367134FA4277BE9A2F52DB /* UIProgressView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 0EF0F7569C1C4BFC3EF2C9DA3D50CC0B /* UIProgressView+AFNetworking.m */; };
  59 + E72F2473AF602610ACD6608E0C4C0100 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B234B3D6CCF479B936C41E947A49AA62 /* Foundation.framework */; };
  60 + F2D2FE3B9DB1610D8EFAB393A3412DB7 /* UIImageView+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 17FCADC02A41266A8F7ECA471386ABB3 /* UIImageView+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; };
  61 + FCB209DFAFF4721A4AA51197AB2D7016 /* UIProgressView+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AD7A9F5902061F94EEC77455DF6D75F /* UIProgressView+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; };
  62 + FE66EF8D47514D23E7551E2C95C765D8 /* AFURLSessionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = D2F00E33B5224A2ABFD1744688638A40 /* AFURLSessionManager.h */; settings = {ATTRIBUTES = (Public, ); }; };
  63 + FF12B4BE37652AC565ED618C106CFE10 /* AFNetworkActivityIndicatorManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 9D82029FB8774862A89BC6CD31A855F2 /* AFNetworkActivityIndicatorManager.h */; settings = {ATTRIBUTES = (Public, ); }; };
21 64 /* End PBXBuildFile section */
22 65  
23 66 /* Begin PBXContainerItemProxy section */
24   - 6BEC831ACC9336C52EF6AAD48929E32B /* PBXContainerItemProxy */ = {
  67 + 10BE38FA9FD4A66416A251C2E70DB3D9 /* PBXContainerItemProxy */ = {
25 68 isa = PBXContainerItemProxy;
26 69 containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */;
27 70 proxyType = 1;
28   - remoteGlobalIDString = 96DBB0CC5E59A3C1D354E11541A3ECFA;
  71 + remoteGlobalIDString = EAE60BD2ADA8DCB217E116ADB628185C;
  72 + remoteInfo = AFNetworking;
  73 + };
  74 + 638D96951986081978219D0D28C4CB95 /* PBXContainerItemProxy */ = {
  75 + isa = PBXContainerItemProxy;
  76 + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */;
  77 + proxyType = 1;
  78 + remoteGlobalIDString = EAE60BD2ADA8DCB217E116ADB628185C;
  79 + remoteInfo = AFNetworking;
  80 + };
  81 + 74EE7622974628230979B1E2FAC31F70 /* PBXContainerItemProxy */ = {
  82 + isa = PBXContainerItemProxy;
  83 + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */;
  84 + proxyType = 1;
  85 + remoteGlobalIDString = EAE60BD2ADA8DCB217E116ADB628185C;
  86 + remoteInfo = AFNetworking;
  87 + };
  88 + A8E7BDA73E29AD4E427F3B81E733E91F /* PBXContainerItemProxy */ = {
  89 + isa = PBXContainerItemProxy;
  90 + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */;
  91 + proxyType = 1;
  92 + remoteGlobalIDString = 55576F17EDFA6D5770450CB4A5A1512F;
29 93 remoteInfo = "Pods-CNLivePublishContent_Example";
30 94 };
31   - C47C26D8F7A7A10B639FCBA54A322E44 /* PBXContainerItemProxy */ = {
  95 + BC29346D1257CE0E429385393E7F4830 /* PBXContainerItemProxy */ = {
32 96 isa = PBXContainerItemProxy;
33 97 containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */;
34 98 proxyType = 1;
35   - remoteGlobalIDString = 53014DEFF54C52A0CA58002ACFDEEF5B;
  99 + remoteGlobalIDString = 0129596E3166712D604DAF3AF140E4C2;
36 100 remoteInfo = CNLivePublishContent;
37 101 };
38 102 /* End PBXContainerItemProxy section */
39 103  
40 104 /* Begin PBXFileReference section */
  105 + 00E5835696EFE5662E1E5E3B6FCB51C0 /* Pods_CNLivePublishContent_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_CNLivePublishContent_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
  106 + 040C09B94F19533FBD391278CB20185D /* AFNetworking.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = AFNetworking.framework; sourceTree = BUILT_PRODUCTS_DIR; };
  107 + 05BFBAF94DDF04E8BDBF6323835FB9BC /* AFURLRequestSerialization.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFURLRequestSerialization.h; path = AFNetworking/AFURLRequestSerialization.h; sourceTree = "<group>"; };
41 108 07944192B1ACCE474532D4AC5B213C83 /* Pods-CNLivePublishContent_Tests.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.module; path = "Pods-CNLivePublishContent_Tests.modulemap"; sourceTree = "<group>"; };
42   - 0C0CDA4DF377FE9B4EC9B0ABB3F8C584 /* CNLivePublishContent-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "CNLivePublishContent-umbrella.h"; sourceTree = "<group>"; };
  109 + 0929494D86649284B6A56EAB3F91B303 /* AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFNetworking.h; path = AFNetworking/AFNetworking.h; sourceTree = "<group>"; };
  110 + 09BDA8426E671B3F1385057205E67201 /* AFHTTPSessionManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFHTTPSessionManager.h; path = AFNetworking/AFHTTPSessionManager.h; sourceTree = "<group>"; };
  111 + 0AF376080E12057AC937F6E1F0D7CB5D /* UIActivityIndicatorView+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIActivityIndicatorView+AFNetworking.h"; path = "UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h"; sourceTree = "<group>"; };
  112 + 0EF0F7569C1C4BFC3EF2C9DA3D50CC0B /* UIProgressView+AFNetworking.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIProgressView+AFNetworking.m"; path = "UIKit+AFNetworking/UIProgressView+AFNetworking.m"; sourceTree = "<group>"; };
  113 + 1174ABA877619CC640989D6AC9A07DF1 /* AFAutoPurgingImageCache.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFAutoPurgingImageCache.m; path = "UIKit+AFNetworking/AFAutoPurgingImageCache.m"; sourceTree = "<group>"; };
43 114 11EF7B4D96108B0737E2DE3314E4E078 /* Pods-CNLivePublishContent_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-CNLivePublishContent_Example.release.xcconfig"; sourceTree = "<group>"; };
  115 + 14D08F7F28CEDCEF2AFC8BBDB71F26FB /* AFNetworking.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = AFNetworking.xcconfig; sourceTree = "<group>"; };
  116 + 17FCADC02A41266A8F7ECA471386ABB3 /* UIImageView+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIImageView+AFNetworking.h"; path = "UIKit+AFNetworking/UIImageView+AFNetworking.h"; sourceTree = "<group>"; };
  117 + 1AB3C1AE13FE37CFF6F471AF2B1E701D /* AFNetworkReachabilityManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFNetworkReachabilityManager.m; path = AFNetworking/AFNetworkReachabilityManager.m; sourceTree = "<group>"; };
44 118 1C9335BE61B442F6D1AB0A3CC50BABEF /* Pods-CNLivePublishContent_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-CNLivePublishContent_Tests.release.xcconfig"; sourceTree = "<group>"; };
  119 + 1D70C948F3D659D5A708EECA7E406277 /* Pods_CNLivePublishContent_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_CNLivePublishContent_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; };
45 120 1DAF2307943F6D77C96929BE990D624A /* Pods-CNLivePublishContent_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-CNLivePublishContent_Tests.debug.xcconfig"; sourceTree = "<group>"; };
46   - 1E780EE58BC7E2D12D138575E3D3A247 /* CNLivePublishContent.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = CNLivePublishContent.xcconfig; sourceTree = "<group>"; };
47 121 1F2873F36BF0A613CE91EB42AF4E5212 /* Pods-CNLivePublishContent_Example-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-CNLivePublishContent_Example-frameworks.sh"; sourceTree = "<group>"; };
  122 + 255176BDE664FDC3EEF3EE888A26EB86 /* YQJTest.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = YQJTest.m; path = CNLivePublishContent/Classes/YQJTest.m; sourceTree = "<group>"; };
  123 + 2658E99DDD8EA7B96318F002C7B157B0 /* AFImageDownloader.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFImageDownloader.m; path = "UIKit+AFNetworking/AFImageDownloader.m"; sourceTree = "<group>"; };
48 124 26F72D9395C2536C85B50ACF6A2D8143 /* Pods-CNLivePublishContent_Tests-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-CNLivePublishContent_Tests-acknowledgements.markdown"; sourceTree = "<group>"; };
49   - 299467A3465BD33076036CD2E9DF4857 /* CNLivePublishContent-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "CNLivePublishContent-prefix.pch"; sourceTree = "<group>"; };
  125 + 2A23D5B238032195CA6F925D556B9F96 /* UIImageView+AFNetworking.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIImageView+AFNetworking.m"; path = "UIKit+AFNetworking/UIImageView+AFNetworking.m"; sourceTree = "<group>"; };
50 126 2A3E6348FEBA5380341707C178C0FB7B /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
  127 + 2A821F310F9CBCED06C1D6DEC3103B24 /* AFURLResponseSerialization.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFURLResponseSerialization.m; path = AFNetworking/AFURLResponseSerialization.m; sourceTree = "<group>"; };
  128 + 353BE42A5F94DADECC35B1DBDA6A1231 /* AFNetworkReachabilityManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFNetworkReachabilityManager.h; path = AFNetworking/AFNetworkReachabilityManager.h; sourceTree = "<group>"; };
  129 + 399878391EC8C0D048B77CE955F3DC79 /* CNLivePublishContent.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.module; path = CNLivePublishContent.modulemap; sourceTree = "<group>"; };
51 130 3B56CFCC9EAF366F03AC9CFE348D9D58 /* Pods-CNLivePublishContent_Tests-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Pods-CNLivePublishContent_Tests-dummy.m"; sourceTree = "<group>"; };
52 131 3EC14C57AFB7CED3F535897B0B293DB6 /* Pods-CNLivePublishContent_Tests-resources.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-CNLivePublishContent_Tests-resources.sh"; sourceTree = "<group>"; };
53   - 4E0455F821B7DEE300A2D934 /* YQJTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YQJTest.m; sourceTree = "<group>"; };
54   - 4E0455FA21B7DEE300A2D934 /* YQJTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YQJTest.h; sourceTree = "<group>"; };
55   - 4F61505A92E8798E55729DA6A8AD8FCE /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
56   - 686A8894865E70129D5817788CA447B1 /* CNLivePublishContent.podspec */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; path = CNLivePublishContent.podspec; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
  132 + 443AC79FE304CEF4E800C982B445221E /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/System/Library/Frameworks/MobileCoreServices.framework; sourceTree = DEVELOPER_DIR; };
  133 + 443C446A800F6280C03E64AF14170EC0 /* AFNetworkActivityIndicatorManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFNetworkActivityIndicatorManager.m; path = "UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m"; sourceTree = "<group>"; };
  134 + 4E13FB5BD4DCDFC7D26ABF44FE960295 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
  135 + 559947ACFC2291BE83F8DEC005B7101D /* AFSecurityPolicy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFSecurityPolicy.m; path = AFNetworking/AFSecurityPolicy.m; sourceTree = "<group>"; };
  136 + 5B63784F7C53EE287DA2961A49BEDC17 /* AFNetworking.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = AFNetworking.framework; sourceTree = BUILT_PRODUCTS_DIR; };
  137 + 5D1C251DFB2D3B0E60259BE56A85C5BA /* UIButton+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIButton+AFNetworking.h"; path = "UIKit+AFNetworking/UIButton+AFNetworking.h"; sourceTree = "<group>"; };
  138 + 5E5745F4D848C4830D92C516D14C03A3 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
  139 + 6361979267EDE0860632095FC6EA4D87 /* AFAutoPurgingImageCache.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFAutoPurgingImageCache.h; path = "UIKit+AFNetworking/AFAutoPurgingImageCache.h"; sourceTree = "<group>"; };
  140 + 695564614B55CEEC9BCFB223C0781E46 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; };
57 141 696C7A16EB627EF2713A1F1BDA249196 /* Pods-CNLivePublishContent_Example-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-CNLivePublishContent_Example-acknowledgements.plist"; sourceTree = "<group>"; };
58   - 6D97962A7815C456C5F2A90D0E3FBB61 /* Pods_CNLivePublishContent_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_CNLivePublishContent_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
59   - 75F6F0105D56C88C9854AB59B0B296C6 /* Pods_CNLivePublishContent_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_CNLivePublishContent_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; };
  142 + 6F93218F251C55BC9FB3371044124253 /* CNLivePublishContent.podspec */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; path = CNLivePublishContent.podspec; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
  143 + 712E674D09C6841F3EFBE929303414E4 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
  144 + 72C208217BB6EAB64559C0AC437E799C /* AFURLSessionManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFURLSessionManager.m; path = AFNetworking/AFURLSessionManager.m; sourceTree = "<group>"; };
  145 + 73DB2FF987F90BF5D4852EAF943F08A5 /* CNLivePublishContent.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CNLivePublishContent.framework; sourceTree = BUILT_PRODUCTS_DIR; };
  146 + 79081AD8422817466BE162D409861670 /* CNLivePublishContent-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "CNLivePublishContent-dummy.m"; sourceTree = "<group>"; };
  147 + 7AD7A9F5902061F94EEC77455DF6D75F /* UIProgressView+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIProgressView+AFNetworking.h"; path = "UIKit+AFNetworking/UIProgressView+AFNetworking.h"; sourceTree = "<group>"; };
60 148 7CC642218BC299E377916CB18576223B /* Pods-CNLivePublishContent_Example-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-CNLivePublishContent_Example-acknowledgements.markdown"; sourceTree = "<group>"; };
61   - 8014DA110BF7F457F9A136B80A7B894E /* CNLivePublishContent-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "CNLivePublishContent-dummy.m"; sourceTree = "<group>"; };
62 149 806B7A4A2134DC7EEB9C2F58642ECD7F /* Pods-CNLivePublishContent_Example-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Pods-CNLivePublishContent_Example-dummy.m"; sourceTree = "<group>"; };
  150 + 84795C057289AA4ADF694D7E2C0A7844 /* YQJTest.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = YQJTest.h; path = CNLivePublishContent/Classes/YQJTest.h; sourceTree = "<group>"; };
  151 + 8B111A72E572F236A399CC7F2E7D3E85 /* AFNetworking-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "AFNetworking-dummy.m"; sourceTree = "<group>"; };
63 152 8FF4421A63C121EA527105F89696F126 /* Pods-CNLivePublishContent_Example-resources.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-CNLivePublishContent_Example-resources.sh"; sourceTree = "<group>"; };
64   - 93978FC9BD80D93E52A09035A9EE2B1E /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
65 153 93A4A3777CF96A4AAC1D13BA6DCCEA73 /* Podfile */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; name = Podfile; path = ../Podfile; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
  154 + 940F9DBBD5FB7E51683C5858A06D1B91 /* UIRefreshControl+AFNetworking.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIRefreshControl+AFNetworking.m"; path = "UIKit+AFNetworking/UIRefreshControl+AFNetworking.m"; sourceTree = "<group>"; };
66 155 9AD4F3EAC9A590DA10A0DDE1BEEC85A6 /* Pods-CNLivePublishContent_Tests-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-CNLivePublishContent_Tests-frameworks.sh"; sourceTree = "<group>"; };
  156 + 9D2C5EF7DC3534CD5503A820E58D39F7 /* CNLivePublishContent-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "CNLivePublishContent-prefix.pch"; sourceTree = "<group>"; };
  157 + 9D82029FB8774862A89BC6CD31A855F2 /* AFNetworkActivityIndicatorManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFNetworkActivityIndicatorManager.h; path = "UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h"; sourceTree = "<group>"; };
  158 + 9FB33A30129B406EB1BD224B6B630B80 /* UIWebView+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIWebView+AFNetworking.h"; path = "UIKit+AFNetworking/UIWebView+AFNetworking.h"; sourceTree = "<group>"; };
67 159 A98533A4379497FD4E0C285CA2F7B56E /* Pods-CNLivePublishContent_Example-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Pods-CNLivePublishContent_Example-umbrella.h"; sourceTree = "<group>"; };
  160 + A9D8CE8A5B7231642B4C0869AB97B2AC /* CNLivePublishContent.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = CNLivePublishContent.xcconfig; sourceTree = "<group>"; };
  161 + AB81F5B5A19D6F63D51E00BB9E746058 /* UIImage+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIImage+AFNetworking.h"; path = "UIKit+AFNetworking/UIImage+AFNetworking.h"; sourceTree = "<group>"; };
  162 + ACFA5C092B8DD591CA30AA394993ABEE /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
  163 + B234B3D6CCF479B936C41E947A49AA62 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; };
  164 + B744E8CFDCDC5D9B41CC93E86AF702B1 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/System/Library/Frameworks/CoreGraphics.framework; sourceTree = DEVELOPER_DIR; };
68 165 B7AECF0C7AF013ED6080E205CA11B046 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
  166 + BB00ADDE9C30E36EB99FA89E831E4590 /* AFSecurityPolicy.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFSecurityPolicy.h; path = AFNetworking/AFSecurityPolicy.h; sourceTree = "<group>"; };
  167 + BE62D258251F0E3CC57836C93584D335 /* UIActivityIndicatorView+AFNetworking.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIActivityIndicatorView+AFNetworking.m"; path = "UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m"; sourceTree = "<group>"; };
  168 + BF1D89BEED3766388A77B2FCB9912393 /* AFNetworking-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "AFNetworking-umbrella.h"; sourceTree = "<group>"; };
69 169 C68C10F080BCB4BB67EFF63349322381 /* Pods-CNLivePublishContent_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-CNLivePublishContent_Example.debug.xcconfig"; sourceTree = "<group>"; };
70   - C7283129B24F62DB5CCB98A10ECB0A6B /* CNLivePublishContent.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.module; path = CNLivePublishContent.modulemap; sourceTree = "<group>"; };
  170 + C90CE9B626C1720C9ADB8FF999E47D68 /* UIRefreshControl+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIRefreshControl+AFNetworking.h"; path = "UIKit+AFNetworking/UIRefreshControl+AFNetworking.h"; sourceTree = "<group>"; };
  171 + C97BFEE825E260FD2CB926EB42CF21CE /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/System/Library/Frameworks/SystemConfiguration.framework; sourceTree = DEVELOPER_DIR; };
  172 + C981116C7B3C73AA73246E5DDFC7D154 /* AFNetworking.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.module; path = AFNetworking.modulemap; sourceTree = "<group>"; };
  173 + CC18ED6BD8558D5E0970879CD6A9291E /* AFImageDownloader.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFImageDownloader.h; path = "UIKit+AFNetworking/AFImageDownloader.h"; sourceTree = "<group>"; };
  174 + CC88013A13A80BA08140FC1D0FC17CAD /* AFHTTPSessionManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFHTTPSessionManager.m; path = AFNetworking/AFHTTPSessionManager.m; sourceTree = "<group>"; };
  175 + CFB2918FE96D6AE88B6CA1AB13D6E730 /* AFURLResponseSerialization.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFURLResponseSerialization.h; path = AFNetworking/AFURLResponseSerialization.h; sourceTree = "<group>"; };
71 176 D0D2AB6F36097F75D3E210BCEB86DB36 /* Pods-CNLivePublishContent_Example.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.module; path = "Pods-CNLivePublishContent_Example.modulemap"; sourceTree = "<group>"; };
72   - D6DFF15000AFE2A371BF499E7AFDA808 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; };
73   - E04AA531B14ABA36CC223071C1569D02 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
  177 + D2F00E33B5224A2ABFD1744688638A40 /* AFURLSessionManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFURLSessionManager.h; path = AFNetworking/AFURLSessionManager.h; sourceTree = "<group>"; };
  178 + D5E9CBCE5E4D8713E454C38B818B6765 /* AFNetworking-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "AFNetworking-prefix.pch"; sourceTree = "<group>"; };
  179 + E1C8AE42D5A69E862E48EC78FF350078 /* AFCompatibilityMacros.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFCompatibilityMacros.h; path = AFNetworking/AFCompatibilityMacros.h; sourceTree = "<group>"; };
74 180 E2383FF4887CBAF2ED8265B6142BB128 /* Pods-CNLivePublishContent_Tests-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-CNLivePublishContent_Tests-acknowledgements.plist"; sourceTree = "<group>"; };
75 181 E2861D05CFE6B3A84C7044909EE26035 /* Pods-CNLivePublishContent_Tests-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Pods-CNLivePublishContent_Tests-umbrella.h"; sourceTree = "<group>"; };
76   - F9986288E069808D66372A7D56BADAF3 /* CNLivePublishContent.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CNLivePublishContent.framework; sourceTree = BUILT_PRODUCTS_DIR; };
  182 + E5CE85E1EB18AE94164507FF5D433CE6 /* UIButton+AFNetworking.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIButton+AFNetworking.m"; path = "UIKit+AFNetworking/UIButton+AFNetworking.m"; sourceTree = "<group>"; };
  183 + E79F20FA67EF326AC8DE380E6118EBF4 /* UIWebView+AFNetworking.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIWebView+AFNetworking.m"; path = "UIKit+AFNetworking/UIWebView+AFNetworking.m"; sourceTree = "<group>"; };
  184 + F1423F692F2541CFE55253BC467F0025 /* UIKit+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIKit+AFNetworking.h"; path = "UIKit+AFNetworking/UIKit+AFNetworking.h"; sourceTree = "<group>"; };
  185 + F6839DA55EA6731EB2DFFA59518EE4A7 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/System/Library/Frameworks/Security.framework; sourceTree = DEVELOPER_DIR; };
  186 + FAF9AB0D2DE5398A86009837A2760BAD /* AFURLRequestSerialization.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFURLRequestSerialization.m; path = AFNetworking/AFURLRequestSerialization.m; sourceTree = "<group>"; };
  187 + FE190B1BDA96365D405860A48D8C8C86 /* CNLivePublishContent-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "CNLivePublishContent-umbrella.h"; sourceTree = "<group>"; };
77 188 /* End PBXFileReference section */
78 189  
79 190 /* Begin PBXFrameworksBuildPhase section */
80   - 31F81AA4A22EC4D3D3B9C414718BF6CB /* Frameworks */ = {
  191 + 122F5A6B6466238A3BB663FC58A217E6 /* Frameworks */ = {
  192 + isa = PBXFrameworksBuildPhase;
  193 + buildActionMask = 2147483647;
  194 + files = (
  195 + 2C06A2EDBAE6B3C9DF4302E17A9A72C0 /* Foundation.framework in Frameworks */,
  196 + );
  197 + runOnlyForDeploymentPostprocessing = 0;
  198 + };
  199 + 201C4131525D709A2C0FE414167327DC /* Frameworks */ = {
81 200 isa = PBXFrameworksBuildPhase;
82 201 buildActionMask = 2147483647;
83 202 files = (
84   - E12A6222EBE7826361ACA060047F5745 /* Foundation.framework in Frameworks */,
  203 + AA24F65AF676F6428D3F2B0D3A03B816 /* CoreGraphics.framework in Frameworks */,
  204 + 146B923ABED8ABBAE25A960876698AF7 /* Foundation.framework in Frameworks */,
  205 + C8D816A742203B5D50B79348DFDDE4BD /* MobileCoreServices.framework in Frameworks */,
  206 + 839FA294A4A7A2C23B0149D5F947BAB3 /* Security.framework in Frameworks */,
  207 + 328CCD10C2469209E1D2DD55268E154D /* SystemConfiguration.framework in Frameworks */,
85 208 );
86 209 runOnlyForDeploymentPostprocessing = 0;
87 210 };
88   - BBD05078A10259185D27E41DE2F1F090 /* Frameworks */ = {
  211 + 75ED884444C020D2FFDE451161BE6FC8 /* Frameworks */ = {
89 212 isa = PBXFrameworksBuildPhase;
90 213 buildActionMask = 2147483647;
91 214 files = (
92   - 3C409600071D0152CE5D9A8DA9C00820 /* Foundation.framework in Frameworks */,
  215 + 23331C9D43DE08E12CB7750F9781D84C /* Foundation.framework in Frameworks */,
93 216 );
94 217 runOnlyForDeploymentPostprocessing = 0;
95 218 };
96   - DA44F0B6F5071FCCD7662713FED303E3 /* Frameworks */ = {
  219 + 8059771A9E49BAE310D15CFAD01F6862 /* Frameworks */ = {
97 220 isa = PBXFrameworksBuildPhase;
98 221 buildActionMask = 2147483647;
99 222 files = (
100   - 208D1CC3C704D8D3322B1450BEF4D9B1 /* Foundation.framework in Frameworks */,
  223 + 24C902F46B1A630D344D4FA287DA05C7 /* AFNetworking.framework in Frameworks */,
  224 + E72F2473AF602610ACD6608E0C4C0100 /* Foundation.framework in Frameworks */,
  225 + 1C7CB086EBAC66BA416E2E1AC7CF197F /* UIKit.framework in Frameworks */,
101 226 );
102 227 runOnlyForDeploymentPostprocessing = 0;
103 228 };
104 229 /* End PBXFrameworksBuildPhase section */
105 230  
106 231 /* Begin PBXGroup section */
107   - 33C8845945518B60972892B9C61472F0 /* CNLivePublishContent */ = {
  232 + 0A60ECF3F4E8D3031BA678BF90A20EEA /* UIKit */ = {
108 233 isa = PBXGroup;
109 234 children = (
110   - 4E0455F521B7DEE300A2D934 /* CNLivePublishContent */,
111   - D7DA1A34768D1EDFA437BC8EEF72E134 /* Pod */,
112   - 8432E3A8FB101082CFCEF141A0685BD6 /* Support Files */,
  235 + 6361979267EDE0860632095FC6EA4D87 /* AFAutoPurgingImageCache.h */,
  236 + 1174ABA877619CC640989D6AC9A07DF1 /* AFAutoPurgingImageCache.m */,
  237 + CC18ED6BD8558D5E0970879CD6A9291E /* AFImageDownloader.h */,
  238 + 2658E99DDD8EA7B96318F002C7B157B0 /* AFImageDownloader.m */,
  239 + 9D82029FB8774862A89BC6CD31A855F2 /* AFNetworkActivityIndicatorManager.h */,
  240 + 443C446A800F6280C03E64AF14170EC0 /* AFNetworkActivityIndicatorManager.m */,
  241 + 0AF376080E12057AC937F6E1F0D7CB5D /* UIActivityIndicatorView+AFNetworking.h */,
  242 + BE62D258251F0E3CC57836C93584D335 /* UIActivityIndicatorView+AFNetworking.m */,
  243 + 5D1C251DFB2D3B0E60259BE56A85C5BA /* UIButton+AFNetworking.h */,
  244 + E5CE85E1EB18AE94164507FF5D433CE6 /* UIButton+AFNetworking.m */,
  245 + AB81F5B5A19D6F63D51E00BB9E746058 /* UIImage+AFNetworking.h */,
  246 + 17FCADC02A41266A8F7ECA471386ABB3 /* UIImageView+AFNetworking.h */,
  247 + 2A23D5B238032195CA6F925D556B9F96 /* UIImageView+AFNetworking.m */,
  248 + F1423F692F2541CFE55253BC467F0025 /* UIKit+AFNetworking.h */,
  249 + 7AD7A9F5902061F94EEC77455DF6D75F /* UIProgressView+AFNetworking.h */,
  250 + 0EF0F7569C1C4BFC3EF2C9DA3D50CC0B /* UIProgressView+AFNetworking.m */,
  251 + C90CE9B626C1720C9ADB8FF999E47D68 /* UIRefreshControl+AFNetworking.h */,
  252 + 940F9DBBD5FB7E51683C5858A06D1B91 /* UIRefreshControl+AFNetworking.m */,
  253 + 9FB33A30129B406EB1BD224B6B630B80 /* UIWebView+AFNetworking.h */,
  254 + E79F20FA67EF326AC8DE380E6118EBF4 /* UIWebView+AFNetworking.m */,
113 255 );
114   - name = CNLivePublishContent;
115   - path = ../..;
  256 + name = UIKit;
116 257 sourceTree = "<group>";
117 258 };
118   - 44D5347904CF754D6785B84253F2574A /* iOS */ = {
  259 + 13965F8687FD7A91F311216D63A437A5 /* Reachability */ = {
119 260 isa = PBXGroup;
120 261 children = (
121   - D6DFF15000AFE2A371BF499E7AFDA808 /* Foundation.framework */,
  262 + 353BE42A5F94DADECC35B1DBDA6A1231 /* AFNetworkReachabilityManager.h */,
  263 + 1AB3C1AE13FE37CFF6F471AF2B1E701D /* AFNetworkReachabilityManager.m */,
122 264 );
123   - name = iOS;
  265 + name = Reachability;
124 266 sourceTree = "<group>";
125 267 };
126   - 4E0455F521B7DEE300A2D934 /* CNLivePublishContent */ = {
  268 + 297CA8023A4FD0BD9EE1CA68BE9526F7 /* Support Files */ = {
127 269 isa = PBXGroup;
128 270 children = (
129   - 4E0455F621B7DEE300A2D934 /* Classes */,
130   - 4E0455FB21B7DEE300A2D934 /* Assets */,
  271 + C981116C7B3C73AA73246E5DDFC7D154 /* AFNetworking.modulemap */,
  272 + 14D08F7F28CEDCEF2AFC8BBDB71F26FB /* AFNetworking.xcconfig */,
  273 + 8B111A72E572F236A399CC7F2E7D3E85 /* AFNetworking-dummy.m */,
  274 + D5E9CBCE5E4D8713E454C38B818B6765 /* AFNetworking-prefix.pch */,
  275 + BF1D89BEED3766388A77B2FCB9912393 /* AFNetworking-umbrella.h */,
  276 + ACFA5C092B8DD591CA30AA394993ABEE /* Info.plist */,
131 277 );
132   - path = CNLivePublishContent;
  278 + name = "Support Files";
  279 + path = "../Target Support Files/AFNetworking";
133 280 sourceTree = "<group>";
134 281 };
135   - 4E0455F621B7DEE300A2D934 /* Classes */ = {
  282 + 4A55D54F916A2EED638B0C709CAD6A75 /* Development Pods */ = {
136 283 isa = PBXGroup;
137 284 children = (
138   - 4E0455F821B7DEE300A2D934 /* YQJTest.m */,
139   - 4E0455FA21B7DEE300A2D934 /* YQJTest.h */,
  285 + F9CB4C3091AE675484E3F226BC3A3A74 /* CNLivePublishContent */,
140 286 );
141   - path = Classes;
  287 + name = "Development Pods";
142 288 sourceTree = "<group>";
143 289 };
144   - 4E0455FB21B7DEE300A2D934 /* Assets */ = {
  290 + 56E9713EBFB9E4DBD2688FAA96865897 /* Pod */ = {
145 291 isa = PBXGroup;
146 292 children = (
  293 + 6F93218F251C55BC9FB3371044124253 /* CNLivePublishContent.podspec */,
  294 + 5E5745F4D848C4830D92C516D14C03A3 /* LICENSE */,
  295 + 712E674D09C6841F3EFBE929303414E4 /* README.md */,
147 296 );
148   - path = Assets;
  297 + name = Pod;
149 298 sourceTree = "<group>";
150 299 };
151   - 66585D833CA10452EB9FAEADDB1D927F /* Products */ = {
  300 + 641BDD347DE7B8BB81D6CA5727C6EC5A /* Pods */ = {
152 301 isa = PBXGroup;
153 302 children = (
154   - F9986288E069808D66372A7D56BADAF3 /* CNLivePublishContent.framework */,
155   - 75F6F0105D56C88C9854AB59B0B296C6 /* Pods_CNLivePublishContent_Example.framework */,
156   - 6D97962A7815C456C5F2A90D0E3FBB61 /* Pods_CNLivePublishContent_Tests.framework */,
  303 + F0BFE09BCA49DD2E63F4E0637DD7991D /* AFNetworking */,
157 304 );
158   - name = Products;
  305 + name = Pods;
159 306 sourceTree = "<group>";
160 307 };
161   - 7DB346D0F39D3F0E887471402A8071AB = {
  308 + 67798BE6655A71228C504A1EE4CC9F59 /* iOS */ = {
162 309 isa = PBXGroup;
163 310 children = (
164   - 93A4A3777CF96A4AAC1D13BA6DCCEA73 /* Podfile */,
165   - 9AD5313C32C860D4C6DB04E2BA3F0D54 /* Development Pods */,
166   - BC3CA7F9E30CC8F7E2DD044DD34432FC /* Frameworks */,
167   - 66585D833CA10452EB9FAEADDB1D927F /* Products */,
168   - E240CF00AEDFDF15B1F66579E55755C9 /* Targets Support Files */,
  311 + B744E8CFDCDC5D9B41CC93E86AF702B1 /* CoreGraphics.framework */,
  312 + B234B3D6CCF479B936C41E947A49AA62 /* Foundation.framework */,
  313 + 443AC79FE304CEF4E800C982B445221E /* MobileCoreServices.framework */,
  314 + F6839DA55EA6731EB2DFFA59518EE4A7 /* Security.framework */,
  315 + C97BFEE825E260FD2CB926EB42CF21CE /* SystemConfiguration.framework */,
  316 + 695564614B55CEEC9BCFB223C0781E46 /* UIKit.framework */,
169 317 );
  318 + name = iOS;
170 319 sourceTree = "<group>";
171 320 };
172   - 8432E3A8FB101082CFCEF141A0685BD6 /* Support Files */ = {
  321 + 6952B7954D6AB15E46D4E68FD16AD504 /* Support Files */ = {
173 322 isa = PBXGroup;
174 323 children = (
175   - C7283129B24F62DB5CCB98A10ECB0A6B /* CNLivePublishContent.modulemap */,
176   - 1E780EE58BC7E2D12D138575E3D3A247 /* CNLivePublishContent.xcconfig */,
177   - 8014DA110BF7F457F9A136B80A7B894E /* CNLivePublishContent-dummy.m */,
178   - 299467A3465BD33076036CD2E9DF4857 /* CNLivePublishContent-prefix.pch */,
179   - 0C0CDA4DF377FE9B4EC9B0ABB3F8C584 /* CNLivePublishContent-umbrella.h */,
180   - 4F61505A92E8798E55729DA6A8AD8FCE /* Info.plist */,
  324 + 399878391EC8C0D048B77CE955F3DC79 /* CNLivePublishContent.modulemap */,
  325 + A9D8CE8A5B7231642B4C0869AB97B2AC /* CNLivePublishContent.xcconfig */,
  326 + 79081AD8422817466BE162D409861670 /* CNLivePublishContent-dummy.m */,
  327 + 9D2C5EF7DC3534CD5503A820E58D39F7 /* CNLivePublishContent-prefix.pch */,
  328 + FE190B1BDA96365D405860A48D8C8C86 /* CNLivePublishContent-umbrella.h */,
  329 + 4E13FB5BD4DCDFC7D26ABF44FE960295 /* Info.plist */,
181 330 );
182 331 name = "Support Files";
183 332 path = "Example/Pods/Target Support Files/CNLivePublishContent";
184 333 sourceTree = "<group>";
185 334 };
186   - 9AD5313C32C860D4C6DB04E2BA3F0D54 /* Development Pods */ = {
  335 + 7DB346D0F39D3F0E887471402A8071AB = {
  336 + isa = PBXGroup;
  337 + children = (
  338 + 93A4A3777CF96A4AAC1D13BA6DCCEA73 /* Podfile */,
  339 + 4A55D54F916A2EED638B0C709CAD6A75 /* Development Pods */,
  340 + AD37EE3CE22F2D6A660B5BD65007E786 /* Frameworks */,
  341 + 641BDD347DE7B8BB81D6CA5727C6EC5A /* Pods */,
  342 + F6EA74295556F5787F271FD6A0522EDB /* Products */,
  343 + E240CF00AEDFDF15B1F66579E55755C9 /* Targets Support Files */,
  344 + );
  345 + sourceTree = "<group>";
  346 + };
  347 + 86CCD87478E929509958BE9B86F7685E /* Serialization */ = {
187 348 isa = PBXGroup;
188 349 children = (
189   - 33C8845945518B60972892B9C61472F0 /* CNLivePublishContent */,
  350 + 05BFBAF94DDF04E8BDBF6323835FB9BC /* AFURLRequestSerialization.h */,
  351 + FAF9AB0D2DE5398A86009837A2760BAD /* AFURLRequestSerialization.m */,
  352 + CFB2918FE96D6AE88B6CA1AB13D6E730 /* AFURLResponseSerialization.h */,
  353 + 2A821F310F9CBCED06C1D6DEC3103B24 /* AFURLResponseSerialization.m */,
190 354 );
191   - name = "Development Pods";
  355 + name = Serialization;
192 356 sourceTree = "<group>";
193 357 };
194 358 9BE3A70CF1BA82CAA948FD98D92A8EE1 /* Pods-CNLivePublishContent_Example */ = {
... ... @@ -209,14 +373,27 @@
209 373 path = "Target Support Files/Pods-CNLivePublishContent_Example";
210 374 sourceTree = "<group>";
211 375 };
212   - BC3CA7F9E30CC8F7E2DD044DD34432FC /* Frameworks */ = {
  376 + AD37EE3CE22F2D6A660B5BD65007E786 /* Frameworks */ = {
213 377 isa = PBXGroup;
214 378 children = (
215   - 44D5347904CF754D6785B84253F2574A /* iOS */,
  379 + 040C09B94F19533FBD391278CB20185D /* AFNetworking.framework */,
  380 + 67798BE6655A71228C504A1EE4CC9F59 /* iOS */,
216 381 );
217 382 name = Frameworks;
218 383 sourceTree = "<group>";
219 384 };
  385 + BAA7C8FD05AEAB93C732F63AC9D55B84 /* NSURLSession */ = {
  386 + isa = PBXGroup;
  387 + children = (
  388 + E1C8AE42D5A69E862E48EC78FF350078 /* AFCompatibilityMacros.h */,
  389 + 09BDA8426E671B3F1385057205E67201 /* AFHTTPSessionManager.h */,
  390 + CC88013A13A80BA08140FC1D0FC17CAD /* AFHTTPSessionManager.m */,
  391 + D2F00E33B5224A2ABFD1744688638A40 /* AFURLSessionManager.h */,
  392 + 72C208217BB6EAB64559C0AC437E799C /* AFURLSessionManager.m */,
  393 + );
  394 + name = NSURLSession;
  395 + sourceTree = "<group>";
  396 + };
220 397 D1C4B32027AB17C57458990E512EB3B3 /* Pods-CNLivePublishContent_Tests */ = {
221 398 isa = PBXGroup;
222 399 children = (
... ... @@ -235,110 +412,194 @@
235 412 path = "Target Support Files/Pods-CNLivePublishContent_Tests";
236 413 sourceTree = "<group>";
237 414 };
238   - D7DA1A34768D1EDFA437BC8EEF72E134 /* Pod */ = {
  415 + E240CF00AEDFDF15B1F66579E55755C9 /* Targets Support Files */ = {
239 416 isa = PBXGroup;
240 417 children = (
241   - 686A8894865E70129D5817788CA447B1 /* CNLivePublishContent.podspec */,
242   - E04AA531B14ABA36CC223071C1569D02 /* LICENSE */,
243   - 93978FC9BD80D93E52A09035A9EE2B1E /* README.md */,
  418 + 9BE3A70CF1BA82CAA948FD98D92A8EE1 /* Pods-CNLivePublishContent_Example */,
  419 + D1C4B32027AB17C57458990E512EB3B3 /* Pods-CNLivePublishContent_Tests */,
244 420 );
245   - name = Pod;
  421 + name = "Targets Support Files";
246 422 sourceTree = "<group>";
247 423 };
248   - E240CF00AEDFDF15B1F66579E55755C9 /* Targets Support Files */ = {
  424 + F0BFE09BCA49DD2E63F4E0637DD7991D /* AFNetworking */ = {
249 425 isa = PBXGroup;
250 426 children = (
251   - 9BE3A70CF1BA82CAA948FD98D92A8EE1 /* Pods-CNLivePublishContent_Example */,
252   - D1C4B32027AB17C57458990E512EB3B3 /* Pods-CNLivePublishContent_Tests */,
  427 + 0929494D86649284B6A56EAB3F91B303 /* AFNetworking.h */,
  428 + BAA7C8FD05AEAB93C732F63AC9D55B84 /* NSURLSession */,
  429 + 13965F8687FD7A91F311216D63A437A5 /* Reachability */,
  430 + FDD76C32F8844B0A4F72AD3FC063818F /* Security */,
  431 + 86CCD87478E929509958BE9B86F7685E /* Serialization */,
  432 + 297CA8023A4FD0BD9EE1CA68BE9526F7 /* Support Files */,
  433 + 0A60ECF3F4E8D3031BA678BF90A20EEA /* UIKit */,
253 434 );
254   - name = "Targets Support Files";
  435 + path = AFNetworking;
  436 + sourceTree = "<group>";
  437 + };
  438 + F6EA74295556F5787F271FD6A0522EDB /* Products */ = {
  439 + isa = PBXGroup;
  440 + children = (
  441 + 5B63784F7C53EE287DA2961A49BEDC17 /* AFNetworking.framework */,
  442 + 73DB2FF987F90BF5D4852EAF943F08A5 /* CNLivePublishContent.framework */,
  443 + 1D70C948F3D659D5A708EECA7E406277 /* Pods_CNLivePublishContent_Example.framework */,
  444 + 00E5835696EFE5662E1E5E3B6FCB51C0 /* Pods_CNLivePublishContent_Tests.framework */,
  445 + );
  446 + name = Products;
  447 + sourceTree = "<group>";
  448 + };
  449 + F9CB4C3091AE675484E3F226BC3A3A74 /* CNLivePublishContent */ = {
  450 + isa = PBXGroup;
  451 + children = (
  452 + 84795C057289AA4ADF694D7E2C0A7844 /* YQJTest.h */,
  453 + 255176BDE664FDC3EEF3EE888A26EB86 /* YQJTest.m */,
  454 + 56E9713EBFB9E4DBD2688FAA96865897 /* Pod */,
  455 + 6952B7954D6AB15E46D4E68FD16AD504 /* Support Files */,
  456 + );
  457 + name = CNLivePublishContent;
  458 + path = ../..;
  459 + sourceTree = "<group>";
  460 + };
  461 + FDD76C32F8844B0A4F72AD3FC063818F /* Security */ = {
  462 + isa = PBXGroup;
  463 + children = (
  464 + BB00ADDE9C30E36EB99FA89E831E4590 /* AFSecurityPolicy.h */,
  465 + 559947ACFC2291BE83F8DEC005B7101D /* AFSecurityPolicy.m */,
  466 + );
  467 + name = Security;
255 468 sourceTree = "<group>";
256 469 };
257 470 /* End PBXGroup section */
258 471  
259 472 /* Begin PBXHeadersBuildPhase section */
260   - 8B8F1F3AF90D7906CF7E9C7B4B10FE6C /* Headers */ = {
  473 + 0E8E0B7E5BB08884CC80B2FB2B86818C /* Headers */ = {
261 474 isa = PBXHeadersBuildPhase;
262 475 buildActionMask = 2147483647;
263 476 files = (
264   - 23CC76C4526811D5A3B51D52567367C5 /* CNLivePublishContent-umbrella.h in Headers */,
265   - 4E04560021B7DEE300A2D934 /* YQJTest.h in Headers */,
  477 + 00B5FE91BE9DE9E2BACFA5C72517182F /* Pods-CNLivePublishContent_Example-umbrella.h in Headers */,
266 478 );
267 479 runOnlyForDeploymentPostprocessing = 0;
268 480 };
269   - 9033E862748488BE72A1C38F8BF11ECE /* Headers */ = {
  481 + 11176E8CC0F33E647945707BCCF194F2 /* Headers */ = {
270 482 isa = PBXHeadersBuildPhase;
271 483 buildActionMask = 2147483647;
272 484 files = (
273   - 199818674B4AEA5670BA25AD9400B14A /* Pods-CNLivePublishContent_Example-umbrella.h in Headers */,
  485 + 5BD586FD5A79C8F85C9B6F20E9D90D90 /* Pods-CNLivePublishContent_Tests-umbrella.h in Headers */,
274 486 );
275 487 runOnlyForDeploymentPostprocessing = 0;
276 488 };
277   - EE24ACE30639ED255D95480F9D33653F /* Headers */ = {
  489 + 20D65A402D1AE33BBDD983CADA49F8C9 /* Headers */ = {
278 490 isa = PBXHeadersBuildPhase;
279 491 buildActionMask = 2147483647;
280 492 files = (
281   - 7DE63A1F998683E0AEEE41EE6C1BB3A6 /* Pods-CNLivePublishContent_Tests-umbrella.h in Headers */,
  493 + 437D16EC401C087F549FA709C91CF786 /* CNLivePublishContent-umbrella.h in Headers */,
  494 + 6499BE821A569363EA3F09B2EA06882A /* YQJTest.h in Headers */,
  495 + );
  496 + runOnlyForDeploymentPostprocessing = 0;
  497 + };
  498 + B5E140C985F3196798D57F2A7DB76ECD /* Headers */ = {
  499 + isa = PBXHeadersBuildPhase;
  500 + buildActionMask = 2147483647;
  501 + files = (
  502 + 8AD9F8FE36978CB4348E402207950883 /* AFAutoPurgingImageCache.h in Headers */,
  503 + 3CC1558D8899A2E13A968D4C403CD793 /* AFCompatibilityMacros.h in Headers */,
  504 + 6C7C6C542448137FC3B6CEA04386780C /* AFHTTPSessionManager.h in Headers */,
  505 + 616166BD57B8707EC940068BF5E1AA0A /* AFImageDownloader.h in Headers */,
  506 + FF12B4BE37652AC565ED618C106CFE10 /* AFNetworkActivityIndicatorManager.h in Headers */,
  507 + 88A52F2DE87FAAEF79B420CC9B6BDE80 /* AFNetworking-umbrella.h in Headers */,
  508 + 9D380619079479C622272E2C77FCD289 /* AFNetworking.h in Headers */,
  509 + 66340E06FB146280E83112B966E563C3 /* AFNetworkReachabilityManager.h in Headers */,
  510 + 901790CB7729E8871AE5DE99E486792B /* AFSecurityPolicy.h in Headers */,
  511 + D491FD44351A11016A957CA81ABE0EC5 /* AFURLRequestSerialization.h in Headers */,
  512 + 2E68973739E2AE713059A22F94238C60 /* AFURLResponseSerialization.h in Headers */,
  513 + FE66EF8D47514D23E7551E2C95C765D8 /* AFURLSessionManager.h in Headers */,
  514 + D014A5430789C5F0FFCF490D53B22897 /* UIActivityIndicatorView+AFNetworking.h in Headers */,
  515 + BEE7FD5C1C06AF3670E0FB75F996DDF7 /* UIButton+AFNetworking.h in Headers */,
  516 + 78F5D40D5B8E9FC40FB257953EA945BA /* UIImage+AFNetworking.h in Headers */,
  517 + F2D2FE3B9DB1610D8EFAB393A3412DB7 /* UIImageView+AFNetworking.h in Headers */,
  518 + A39E1924915C53C49E7220F72AD96BBB /* UIKit+AFNetworking.h in Headers */,
  519 + FCB209DFAFF4721A4AA51197AB2D7016 /* UIProgressView+AFNetworking.h in Headers */,
  520 + 15304B6383EF69EC4E3DE45F8613BE2E /* UIRefreshControl+AFNetworking.h in Headers */,
  521 + CB633AF10D27AD0971F3E34470B0BB01 /* UIWebView+AFNetworking.h in Headers */,
282 522 );
283 523 runOnlyForDeploymentPostprocessing = 0;
284 524 };
285 525 /* End PBXHeadersBuildPhase section */
286 526  
287 527 /* Begin PBXNativeTarget section */
288   - 21D400ECEB783EFB86E95FF2C674D6A1 /* Pods-CNLivePublishContent_Tests */ = {
  528 + 0129596E3166712D604DAF3AF140E4C2 /* CNLivePublishContent */ = {
289 529 isa = PBXNativeTarget;
290   - buildConfigurationList = 20CA38EE2EFA75F5625B7F9A3FC860E4 /* Build configuration list for PBXNativeTarget "Pods-CNLivePublishContent_Tests" */;
  530 + buildConfigurationList = 565610290BC02A1EA9383D220B6A742B /* Build configuration list for PBXNativeTarget "CNLivePublishContent" */;
291 531 buildPhases = (
292   - EE24ACE30639ED255D95480F9D33653F /* Headers */,
293   - DE7313C6E16DE4E5A2819D1E4F97264E /* Sources */,
294   - 31F81AA4A22EC4D3D3B9C414718BF6CB /* Frameworks */,
295   - 7B68BA9ACCEA99E171C7C5A8E62D0750 /* Resources */,
  532 + 20D65A402D1AE33BBDD983CADA49F8C9 /* Headers */,
  533 + 067CBEC0AF0D0AC193B2E646F22F4DBC /* Sources */,
  534 + 8059771A9E49BAE310D15CFAD01F6862 /* Frameworks */,
  535 + F5C79AEC70006E957E77A43554A9ABBC /* Resources */,
296 536 );
297 537 buildRules = (
298 538 );
299 539 dependencies = (
300   - F7C5B573ED5A9511470F5C84D70B4FF3 /* PBXTargetDependency */,
  540 + D3F4E7B90AA6567DF2D82F63373C9B4C /* PBXTargetDependency */,
301 541 );
302   - name = "Pods-CNLivePublishContent_Tests";
303   - productName = "Pods-CNLivePublishContent_Tests";
304   - productReference = 6D97962A7815C456C5F2A90D0E3FBB61 /* Pods_CNLivePublishContent_Tests.framework */;
  542 + name = CNLivePublishContent;
  543 + productName = CNLivePublishContent;
  544 + productReference = 73DB2FF987F90BF5D4852EAF943F08A5 /* CNLivePublishContent.framework */;
305 545 productType = "com.apple.product-type.framework";
306 546 };
307   - 53014DEFF54C52A0CA58002ACFDEEF5B /* CNLivePublishContent */ = {
  547 + 372412E1F5E11671595F2FCAE8C052BD /* Pods-CNLivePublishContent_Tests */ = {
308 548 isa = PBXNativeTarget;
309   - buildConfigurationList = 9F833024D052981976E7CD614FDC047C /* Build configuration list for PBXNativeTarget "CNLivePublishContent" */;
  549 + buildConfigurationList = E0F3EA5CE7DFAD07D828D8C5A8A718E7 /* Build configuration list for PBXNativeTarget "Pods-CNLivePublishContent_Tests" */;
310 550 buildPhases = (
311   - 8B8F1F3AF90D7906CF7E9C7B4B10FE6C /* Headers */,
312   - 2B6EAEB3DFE6676AFB7F1F622F68B65D /* Sources */,
313   - BBD05078A10259185D27E41DE2F1F090 /* Frameworks */,
314   - 9DC99BF2E91825C00FADA86D65A5B415 /* Resources */,
  551 + 11176E8CC0F33E647945707BCCF194F2 /* Headers */,
  552 + 7BD60E7F276F99C3E9C00078C4087F26 /* Sources */,
  553 + 75ED884444C020D2FFDE451161BE6FC8 /* Frameworks */,
  554 + 6B39BD9235A2B80414EF985EC5D165DB /* Resources */,
315 555 );
316 556 buildRules = (
317 557 );
318 558 dependencies = (
  559 + 6E3CB6A8150CDB6E3255319CFBC8A413 /* PBXTargetDependency */,
  560 + C9F616E89D4FF64E6D7E30B9F67AF945 /* PBXTargetDependency */,
319 561 );
320   - name = CNLivePublishContent;
321   - productName = CNLivePublishContent;
322   - productReference = F9986288E069808D66372A7D56BADAF3 /* CNLivePublishContent.framework */;
  562 + name = "Pods-CNLivePublishContent_Tests";
  563 + productName = "Pods-CNLivePublishContent_Tests";
  564 + productReference = 00E5835696EFE5662E1E5E3B6FCB51C0 /* Pods_CNLivePublishContent_Tests.framework */;
323 565 productType = "com.apple.product-type.framework";
324 566 };
325   - 96DBB0CC5E59A3C1D354E11541A3ECFA /* Pods-CNLivePublishContent_Example */ = {
  567 + 55576F17EDFA6D5770450CB4A5A1512F /* Pods-CNLivePublishContent_Example */ = {
326 568 isa = PBXNativeTarget;
327   - buildConfigurationList = 0D5BB5C269806AEEA5BB4FDD76DE132C /* Build configuration list for PBXNativeTarget "Pods-CNLivePublishContent_Example" */;
  569 + buildConfigurationList = 31C66CE74F19C7D8A8F842B6B902D672 /* Build configuration list for PBXNativeTarget "Pods-CNLivePublishContent_Example" */;
328 570 buildPhases = (
329   - 9033E862748488BE72A1C38F8BF11ECE /* Headers */,
330   - 34EDB5E17CF9BA16B2135C15689480F8 /* Sources */,
331   - DA44F0B6F5071FCCD7662713FED303E3 /* Frameworks */,
332   - 9C80AA2FA2C4F1C0BF03923D9ECEBF2D /* Resources */,
  571 + 0E8E0B7E5BB08884CC80B2FB2B86818C /* Headers */,
  572 + B7B9C97376D5966EF20F6AD1D71AEB96 /* Sources */,
  573 + 122F5A6B6466238A3BB663FC58A217E6 /* Frameworks */,
  574 + 386EF2FE75B42E45032AB298237D3921 /* Resources */,
333 575 );
334 576 buildRules = (
335 577 );
336 578 dependencies = (
337   - 4E77180672CC6B49E8C408EC3BA1A54C /* PBXTargetDependency */,
  579 + C8AD328705C1AB5C8B29138FF6EBFD33 /* PBXTargetDependency */,
  580 + 99E407B6E999010E520C5BA84EB76C63 /* PBXTargetDependency */,
338 581 );
339 582 name = "Pods-CNLivePublishContent_Example";
340 583 productName = "Pods-CNLivePublishContent_Example";
341   - productReference = 75F6F0105D56C88C9854AB59B0B296C6 /* Pods_CNLivePublishContent_Example.framework */;
  584 + productReference = 1D70C948F3D659D5A708EECA7E406277 /* Pods_CNLivePublishContent_Example.framework */;
  585 + productType = "com.apple.product-type.framework";
  586 + };
  587 + EAE60BD2ADA8DCB217E116ADB628185C /* AFNetworking */ = {
  588 + isa = PBXNativeTarget;
  589 + buildConfigurationList = 8289B039CF0D8B5A385C13089893A356 /* Build configuration list for PBXNativeTarget "AFNetworking" */;
  590 + buildPhases = (
  591 + B5E140C985F3196798D57F2A7DB76ECD /* Headers */,
  592 + 07C7A3674C96B85AD8EA6C6D71BC549B /* Sources */,
  593 + 201C4131525D709A2C0FE414167327DC /* Frameworks */,
  594 + 8F134AE083847A523C4AE149B84307BF /* Resources */,
  595 + );
  596 + buildRules = (
  597 + );
  598 + dependencies = (
  599 + );
  600 + name = AFNetworking;
  601 + productName = AFNetworking;
  602 + productReference = 5B63784F7C53EE287DA2961A49BEDC17 /* AFNetworking.framework */;
342 603 productType = "com.apple.product-type.framework";
343 604 };
344 605 /* End PBXNativeTarget section */
... ... @@ -358,33 +619,41 @@
358 619 en,
359 620 );
360 621 mainGroup = 7DB346D0F39D3F0E887471402A8071AB;
361   - productRefGroup = 66585D833CA10452EB9FAEADDB1D927F /* Products */;
  622 + productRefGroup = F6EA74295556F5787F271FD6A0522EDB /* Products */;
362 623 projectDirPath = "";
363 624 projectRoot = "";
364 625 targets = (
365   - 53014DEFF54C52A0CA58002ACFDEEF5B /* CNLivePublishContent */,
366   - 96DBB0CC5E59A3C1D354E11541A3ECFA /* Pods-CNLivePublishContent_Example */,
367   - 21D400ECEB783EFB86E95FF2C674D6A1 /* Pods-CNLivePublishContent_Tests */,
  626 + EAE60BD2ADA8DCB217E116ADB628185C /* AFNetworking */,
  627 + 0129596E3166712D604DAF3AF140E4C2 /* CNLivePublishContent */,
  628 + 55576F17EDFA6D5770450CB4A5A1512F /* Pods-CNLivePublishContent_Example */,
  629 + 372412E1F5E11671595F2FCAE8C052BD /* Pods-CNLivePublishContent_Tests */,
368 630 );
369 631 };
370 632 /* End PBXProject section */
371 633  
372 634 /* Begin PBXResourcesBuildPhase section */
373   - 7B68BA9ACCEA99E171C7C5A8E62D0750 /* Resources */ = {
  635 + 386EF2FE75B42E45032AB298237D3921 /* Resources */ = {
  636 + isa = PBXResourcesBuildPhase;
  637 + buildActionMask = 2147483647;
  638 + files = (
  639 + );
  640 + runOnlyForDeploymentPostprocessing = 0;
  641 + };
  642 + 6B39BD9235A2B80414EF985EC5D165DB /* Resources */ = {
374 643 isa = PBXResourcesBuildPhase;
375 644 buildActionMask = 2147483647;
376 645 files = (
377 646 );
378 647 runOnlyForDeploymentPostprocessing = 0;
379 648 };
380   - 9C80AA2FA2C4F1C0BF03923D9ECEBF2D /* Resources */ = {
  649 + 8F134AE083847A523C4AE149B84307BF /* Resources */ = {
381 650 isa = PBXResourcesBuildPhase;
382 651 buildActionMask = 2147483647;
383 652 files = (
384 653 );
385 654 runOnlyForDeploymentPostprocessing = 0;
386 655 };
387   - 9DC99BF2E91825C00FADA86D65A5B415 /* Resources */ = {
  656 + F5C79AEC70006E957E77A43554A9ABBC /* Resources */ = {
388 657 isa = PBXResourcesBuildPhase;
389 658 buildActionMask = 2147483647;
390 659 files = (
... ... @@ -394,52 +663,93 @@
394 663 /* End PBXResourcesBuildPhase section */
395 664  
396 665 /* Begin PBXSourcesBuildPhase section */
397   - 2B6EAEB3DFE6676AFB7F1F622F68B65D /* Sources */ = {
  666 + 067CBEC0AF0D0AC193B2E646F22F4DBC /* Sources */ = {
398 667 isa = PBXSourcesBuildPhase;
399 668 buildActionMask = 2147483647;
400 669 files = (
401   - D0C7D0F5C3A5B1E810539218F5BE8264 /* CNLivePublishContent-dummy.m in Sources */,
402   - 4E0455FE21B7DEE300A2D934 /* YQJTest.m in Sources */,
  670 + 1DED0CC29970F878261799A26EF463BB /* CNLivePublishContent-dummy.m in Sources */,
  671 + A6788BD629798B6F13289D01BD549782 /* YQJTest.m in Sources */,
403 672 );
404 673 runOnlyForDeploymentPostprocessing = 0;
405 674 };
406   - 34EDB5E17CF9BA16B2135C15689480F8 /* Sources */ = {
  675 + 07C7A3674C96B85AD8EA6C6D71BC549B /* Sources */ = {
407 676 isa = PBXSourcesBuildPhase;
408 677 buildActionMask = 2147483647;
409 678 files = (
410   - 7E0C5A4DB7D2F502E2BAAF759C12B50A /* Pods-CNLivePublishContent_Example-dummy.m in Sources */,
  679 + 9486D80CC092F8ACB2355D5C94A155E3 /* AFAutoPurgingImageCache.m in Sources */,
  680 + 5A4C39ACCE4CE7B6C69C736F48087759 /* AFHTTPSessionManager.m in Sources */,
  681 + 6A5E05D187005E863177B45D58905C71 /* AFImageDownloader.m in Sources */,
  682 + 15F1AB626337FECD0B9CFAAD90FAC342 /* AFNetworkActivityIndicatorManager.m in Sources */,
  683 + 8826A0887EEE1A618FA3BA34989E05B5 /* AFNetworking-dummy.m in Sources */,
  684 + 137A6E8841A2429C00CBFA701695197E /* AFNetworkReachabilityManager.m in Sources */,
  685 + 63A7B518E880C7AACABCD20AFA247C8C /* AFSecurityPolicy.m in Sources */,
  686 + CB3CA20E3732A095F5515E0621D8719C /* AFURLRequestSerialization.m in Sources */,
  687 + 11EAB2A17E2712DB04831AD0FFD6A5DB /* AFURLResponseSerialization.m in Sources */,
  688 + 0D58399A6DC61099900309A4449F7891 /* AFURLSessionManager.m in Sources */,
  689 + CB3028664CA23A1480C18C7A86CFDAF4 /* UIActivityIndicatorView+AFNetworking.m in Sources */,
  690 + 402EB64C59857FE252DC98844643C420 /* UIButton+AFNetworking.m in Sources */,
  691 + 41FD4D0D6101210E26DDDCDD17FBB7C3 /* UIImageView+AFNetworking.m in Sources */,
  692 + DF74915F8F367134FA4277BE9A2F52DB /* UIProgressView+AFNetworking.m in Sources */,
  693 + 00ED59EE2784CE922358E57E241A6C75 /* UIRefreshControl+AFNetworking.m in Sources */,
  694 + 00E2C1092D2255BB25E45DF004D3E7E5 /* UIWebView+AFNetworking.m in Sources */,
411 695 );
412 696 runOnlyForDeploymentPostprocessing = 0;
413 697 };
414   - DE7313C6E16DE4E5A2819D1E4F97264E /* Sources */ = {
  698 + 7BD60E7F276F99C3E9C00078C4087F26 /* Sources */ = {
415 699 isa = PBXSourcesBuildPhase;
416 700 buildActionMask = 2147483647;
417 701 files = (
418   - 8D8EC7DF8F024D7B55FB8EAD45B8BA4A /* Pods-CNLivePublishContent_Tests-dummy.m in Sources */,
  702 + 7964C4CDB394B0C4DCFEC7D92E14D71A /* Pods-CNLivePublishContent_Tests-dummy.m in Sources */,
  703 + );
  704 + runOnlyForDeploymentPostprocessing = 0;
  705 + };
  706 + B7B9C97376D5966EF20F6AD1D71AEB96 /* Sources */ = {
  707 + isa = PBXSourcesBuildPhase;
  708 + buildActionMask = 2147483647;
  709 + files = (
  710 + B27AB9936E094171E3A6371570FDD397 /* Pods-CNLivePublishContent_Example-dummy.m in Sources */,
419 711 );
420 712 runOnlyForDeploymentPostprocessing = 0;
421 713 };
422 714 /* End PBXSourcesBuildPhase section */
423 715  
424 716 /* Begin PBXTargetDependency section */
425   - 4E77180672CC6B49E8C408EC3BA1A54C /* PBXTargetDependency */ = {
  717 + 6E3CB6A8150CDB6E3255319CFBC8A413 /* PBXTargetDependency */ = {
  718 + isa = PBXTargetDependency;
  719 + name = AFNetworking;
  720 + target = EAE60BD2ADA8DCB217E116ADB628185C /* AFNetworking */;
  721 + targetProxy = 10BE38FA9FD4A66416A251C2E70DB3D9 /* PBXContainerItemProxy */;
  722 + };
  723 + 99E407B6E999010E520C5BA84EB76C63 /* PBXTargetDependency */ = {
426 724 isa = PBXTargetDependency;
427 725 name = CNLivePublishContent;
428   - target = 53014DEFF54C52A0CA58002ACFDEEF5B /* CNLivePublishContent */;
429   - targetProxy = C47C26D8F7A7A10B639FCBA54A322E44 /* PBXContainerItemProxy */;
  726 + target = 0129596E3166712D604DAF3AF140E4C2 /* CNLivePublishContent */;
  727 + targetProxy = BC29346D1257CE0E429385393E7F4830 /* PBXContainerItemProxy */;
  728 + };
  729 + C8AD328705C1AB5C8B29138FF6EBFD33 /* PBXTargetDependency */ = {
  730 + isa = PBXTargetDependency;
  731 + name = AFNetworking;
  732 + target = EAE60BD2ADA8DCB217E116ADB628185C /* AFNetworking */;
  733 + targetProxy = 638D96951986081978219D0D28C4CB95 /* PBXContainerItemProxy */;
430 734 };
431   - F7C5B573ED5A9511470F5C84D70B4FF3 /* PBXTargetDependency */ = {
  735 + C9F616E89D4FF64E6D7E30B9F67AF945 /* PBXTargetDependency */ = {
432 736 isa = PBXTargetDependency;
433 737 name = "Pods-CNLivePublishContent_Example";
434   - target = 96DBB0CC5E59A3C1D354E11541A3ECFA /* Pods-CNLivePublishContent_Example */;
435   - targetProxy = 6BEC831ACC9336C52EF6AAD48929E32B /* PBXContainerItemProxy */;
  738 + target = 55576F17EDFA6D5770450CB4A5A1512F /* Pods-CNLivePublishContent_Example */;
  739 + targetProxy = A8E7BDA73E29AD4E427F3B81E733E91F /* PBXContainerItemProxy */;
  740 + };
  741 + D3F4E7B90AA6567DF2D82F63373C9B4C /* PBXTargetDependency */ = {
  742 + isa = PBXTargetDependency;
  743 + name = AFNetworking;
  744 + target = EAE60BD2ADA8DCB217E116ADB628185C /* AFNetworking */;
  745 + targetProxy = 74EE7622974628230979B1E2FAC31F70 /* PBXContainerItemProxy */;
436 746 };
437 747 /* End PBXTargetDependency section */
438 748  
439 749 /* Begin XCBuildConfiguration section */
440   - 6F179C11BC8462CD5831BA140F5B0073 /* Release */ = {
  750 + 1843215834F5986609CD5856CFF60501 /* Release */ = {
441 751 isa = XCBuildConfiguration;
442   - baseConfigurationReference = 1C9335BE61B442F6D1AB0A3CC50BABEF /* Pods-CNLivePublishContent_Tests.release.xcconfig */;
  752 + baseConfigurationReference = 11EF7B4D96108B0737E2DE3314E4E078 /* Pods-CNLivePublishContent_Example.release.xcconfig */;
443 753 buildSettings = {
444 754 ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO;
445 755 CODE_SIGN_IDENTITY = "";
... ... @@ -451,12 +761,12 @@
451 761 DYLIB_COMPATIBILITY_VERSION = 1;
452 762 DYLIB_CURRENT_VERSION = 1;
453 763 DYLIB_INSTALL_NAME_BASE = "@rpath";
454   - INFOPLIST_FILE = "Target Support Files/Pods-CNLivePublishContent_Tests/Info.plist";
  764 + INFOPLIST_FILE = "Target Support Files/Pods-CNLivePublishContent_Example/Info.plist";
455 765 INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
456   - IPHONEOS_DEPLOYMENT_TARGET = 8.0;
  766 + IPHONEOS_DEPLOYMENT_TARGET = 9.0;
457 767 LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
458 768 MACH_O_TYPE = staticlib;
459   - MODULEMAP_FILE = "Target Support Files/Pods-CNLivePublishContent_Tests/Pods-CNLivePublishContent_Tests.modulemap";
  769 + MODULEMAP_FILE = "Target Support Files/Pods-CNLivePublishContent_Example/Pods-CNLivePublishContent_Example.modulemap";
460 770 OTHER_LDFLAGS = "";
461 771 OTHER_LIBTOOLFLAGS = "";
462 772 PODS_ROOT = "$(SRCROOT)";
... ... @@ -471,9 +781,9 @@
471 781 };
472 782 name = Release;
473 783 };
474   - 78EEAC066F2F601461DD7DFBC5D37E97 /* Debug */ = {
  784 + 5184FC30B3970AE203A02597EA9DCBD8 /* Debug */ = {
475 785 isa = XCBuildConfiguration;
476   - baseConfigurationReference = 1E780EE58BC7E2D12D138575E3D3A247 /* CNLivePublishContent.xcconfig */;
  786 + baseConfigurationReference = A9D8CE8A5B7231642B4C0869AB97B2AC /* CNLivePublishContent.xcconfig */;
477 787 buildSettings = {
478 788 CODE_SIGN_IDENTITY = "";
479 789 "CODE_SIGN_IDENTITY[sdk=appletvos*]" = "";
... ... @@ -487,8 +797,9 @@
487 797 GCC_PREFIX_HEADER = "Target Support Files/CNLivePublishContent/CNLivePublishContent-prefix.pch";
488 798 INFOPLIST_FILE = "Target Support Files/CNLivePublishContent/Info.plist";
489 799 INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
490   - IPHONEOS_DEPLOYMENT_TARGET = 8.0;
  800 + IPHONEOS_DEPLOYMENT_TARGET = 9.0;
491 801 LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
  802 + MACH_O_TYPE = staticlib;
492 803 MODULEMAP_FILE = "Target Support Files/CNLivePublishContent/CNLivePublishContent.modulemap";
493 804 PRODUCT_MODULE_NAME = CNLivePublishContent;
494 805 PRODUCT_NAME = CNLivePublishContent;
... ... @@ -501,7 +812,40 @@
501 812 };
502 813 name = Debug;
503 814 };
504   - 85B95B1234E227C814CCC2C7902D0916 /* Release */ = {
  815 + 5229405B05FF6B657D04BA602DA53837 /* Debug */ = {
  816 + isa = XCBuildConfiguration;
  817 + baseConfigurationReference = 1DAF2307943F6D77C96929BE990D624A /* Pods-CNLivePublishContent_Tests.debug.xcconfig */;
  818 + buildSettings = {
  819 + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO;
  820 + CODE_SIGN_IDENTITY = "";
  821 + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = "";
  822 + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
  823 + "CODE_SIGN_IDENTITY[sdk=watchos*]" = "";
  824 + CURRENT_PROJECT_VERSION = 1;
  825 + DEFINES_MODULE = YES;
  826 + DYLIB_COMPATIBILITY_VERSION = 1;
  827 + DYLIB_CURRENT_VERSION = 1;
  828 + DYLIB_INSTALL_NAME_BASE = "@rpath";
  829 + INFOPLIST_FILE = "Target Support Files/Pods-CNLivePublishContent_Tests/Info.plist";
  830 + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
  831 + IPHONEOS_DEPLOYMENT_TARGET = 9.0;
  832 + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
  833 + MACH_O_TYPE = staticlib;
  834 + MODULEMAP_FILE = "Target Support Files/Pods-CNLivePublishContent_Tests/Pods-CNLivePublishContent_Tests.modulemap";
  835 + OTHER_LDFLAGS = "";
  836 + OTHER_LIBTOOLFLAGS = "";
  837 + PODS_ROOT = "$(SRCROOT)";
  838 + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}";
  839 + PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
  840 + SDKROOT = iphoneos;
  841 + SKIP_INSTALL = YES;
  842 + TARGETED_DEVICE_FAMILY = "1,2";
  843 + VERSIONING_SYSTEM = "apple-generic";
  844 + VERSION_INFO_PREFIX = "";
  845 + };
  846 + name = Debug;
  847 + };
  848 + 5DE19CECB206ACCCACF04D62F93FFDA6 /* Release */ = {
505 849 isa = XCBuildConfiguration;
506 850 buildSettings = {
507 851 ALWAYS_SEARCH_USER_PATHS = NO;
... ... @@ -551,7 +895,7 @@
551 895 GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
552 896 GCC_WARN_UNUSED_FUNCTION = YES;
553 897 GCC_WARN_UNUSED_VARIABLE = YES;
554   - IPHONEOS_DEPLOYMENT_TARGET = 8.0;
  898 + IPHONEOS_DEPLOYMENT_TARGET = 9.0;
555 899 MTL_ENABLE_DEBUG_INFO = NO;
556 900 MTL_FAST_MATH = YES;
557 901 PRODUCT_NAME = "$(TARGET_NAME)";
... ... @@ -562,72 +906,7 @@
562 906 };
563 907 name = Release;
564 908 };
565   - 8BEFD3C4823C93BE25A26E27E3709B41 /* Release */ = {
566   - isa = XCBuildConfiguration;
567   - baseConfigurationReference = 1E780EE58BC7E2D12D138575E3D3A247 /* CNLivePublishContent.xcconfig */;
568   - buildSettings = {
569   - CODE_SIGN_IDENTITY = "";
570   - "CODE_SIGN_IDENTITY[sdk=appletvos*]" = "";
571   - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
572   - "CODE_SIGN_IDENTITY[sdk=watchos*]" = "";
573   - CURRENT_PROJECT_VERSION = 1;
574   - DEFINES_MODULE = YES;
575   - DYLIB_COMPATIBILITY_VERSION = 1;
576   - DYLIB_CURRENT_VERSION = 1;
577   - DYLIB_INSTALL_NAME_BASE = "@rpath";
578   - GCC_PREFIX_HEADER = "Target Support Files/CNLivePublishContent/CNLivePublishContent-prefix.pch";
579   - INFOPLIST_FILE = "Target Support Files/CNLivePublishContent/Info.plist";
580   - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
581   - IPHONEOS_DEPLOYMENT_TARGET = 8.0;
582   - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
583   - MODULEMAP_FILE = "Target Support Files/CNLivePublishContent/CNLivePublishContent.modulemap";
584   - PRODUCT_MODULE_NAME = CNLivePublishContent;
585   - PRODUCT_NAME = CNLivePublishContent;
586   - SDKROOT = iphoneos;
587   - SKIP_INSTALL = YES;
588   - SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) ";
589   - TARGETED_DEVICE_FAMILY = "1,2";
590   - VALIDATE_PRODUCT = YES;
591   - VERSIONING_SYSTEM = "apple-generic";
592   - VERSION_INFO_PREFIX = "";
593   - };
594   - name = Release;
595   - };
596   - 9271BE75C990EC87EA89EB63C209F2C7 /* Release */ = {
597   - isa = XCBuildConfiguration;
598   - baseConfigurationReference = 11EF7B4D96108B0737E2DE3314E4E078 /* Pods-CNLivePublishContent_Example.release.xcconfig */;
599   - buildSettings = {
600   - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO;
601   - CODE_SIGN_IDENTITY = "";
602   - "CODE_SIGN_IDENTITY[sdk=appletvos*]" = "";
603   - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
604   - "CODE_SIGN_IDENTITY[sdk=watchos*]" = "";
605   - CURRENT_PROJECT_VERSION = 1;
606   - DEFINES_MODULE = YES;
607   - DYLIB_COMPATIBILITY_VERSION = 1;
608   - DYLIB_CURRENT_VERSION = 1;
609   - DYLIB_INSTALL_NAME_BASE = "@rpath";
610   - INFOPLIST_FILE = "Target Support Files/Pods-CNLivePublishContent_Example/Info.plist";
611   - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
612   - IPHONEOS_DEPLOYMENT_TARGET = 8.0;
613   - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
614   - MACH_O_TYPE = staticlib;
615   - MODULEMAP_FILE = "Target Support Files/Pods-CNLivePublishContent_Example/Pods-CNLivePublishContent_Example.modulemap";
616   - OTHER_LDFLAGS = "";
617   - OTHER_LIBTOOLFLAGS = "";
618   - PODS_ROOT = "$(SRCROOT)";
619   - PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}";
620   - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
621   - SDKROOT = iphoneos;
622   - SKIP_INSTALL = YES;
623   - TARGETED_DEVICE_FAMILY = "1,2";
624   - VALIDATE_PRODUCT = YES;
625   - VERSIONING_SYSTEM = "apple-generic";
626   - VERSION_INFO_PREFIX = "";
627   - };
628   - name = Release;
629   - };
630   - A73625DEBD810B78234FA1958C191C8C /* Debug */ = {
  909 + 858D01EEFE984249A9581D18DBEA53F1 /* Debug */ = {
631 910 isa = XCBuildConfiguration;
632 911 buildSettings = {
633 912 ALWAYS_SEARCH_USER_PATHS = NO;
... ... @@ -680,7 +959,7 @@
680 959 GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
681 960 GCC_WARN_UNUSED_FUNCTION = YES;
682 961 GCC_WARN_UNUSED_VARIABLE = YES;
683   - IPHONEOS_DEPLOYMENT_TARGET = 8.0;
  962 + IPHONEOS_DEPLOYMENT_TARGET = 9.0;
684 963 MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
685 964 MTL_FAST_MATH = YES;
686 965 ONLY_ACTIVE_ARCH = YES;
... ... @@ -693,11 +972,10 @@
693 972 };
694 973 name = Debug;
695 974 };
696   - D6E658B823460E1A092ADDD2BE1B713C /* Debug */ = {
  975 + 8D2DCA929D6EAACBC099C6391F176FAB /* Release */ = {
697 976 isa = XCBuildConfiguration;
698   - baseConfigurationReference = C68C10F080BCB4BB67EFF63349322381 /* Pods-CNLivePublishContent_Example.debug.xcconfig */;
  977 + baseConfigurationReference = 14D08F7F28CEDCEF2AFC8BBDB71F26FB /* AFNetworking.xcconfig */;
699 978 buildSettings = {
700   - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO;
701 979 CODE_SIGN_IDENTITY = "";
702 980 "CODE_SIGN_IDENTITY[sdk=appletvos*]" = "";
703 981 "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
... ... @@ -707,12 +985,74 @@
707 985 DYLIB_COMPATIBILITY_VERSION = 1;
708 986 DYLIB_CURRENT_VERSION = 1;
709 987 DYLIB_INSTALL_NAME_BASE = "@rpath";
710   - INFOPLIST_FILE = "Target Support Files/Pods-CNLivePublishContent_Example/Info.plist";
  988 + GCC_PREFIX_HEADER = "Target Support Files/AFNetworking/AFNetworking-prefix.pch";
  989 + INFOPLIST_FILE = "Target Support Files/AFNetworking/Info.plist";
  990 + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
  991 + IPHONEOS_DEPLOYMENT_TARGET = 8.0;
  992 + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
  993 + MODULEMAP_FILE = "Target Support Files/AFNetworking/AFNetworking.modulemap";
  994 + PRODUCT_MODULE_NAME = AFNetworking;
  995 + PRODUCT_NAME = AFNetworking;
  996 + SDKROOT = iphoneos;
  997 + SKIP_INSTALL = YES;
  998 + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) ";
  999 + TARGETED_DEVICE_FAMILY = "1,2";
  1000 + VALIDATE_PRODUCT = YES;
  1001 + VERSIONING_SYSTEM = "apple-generic";
  1002 + VERSION_INFO_PREFIX = "";
  1003 + };
  1004 + name = Release;
  1005 + };
  1006 + 9F05FB7480ECA0237560017761177F3A /* Debug */ = {
  1007 + isa = XCBuildConfiguration;
  1008 + baseConfigurationReference = 14D08F7F28CEDCEF2AFC8BBDB71F26FB /* AFNetworking.xcconfig */;
  1009 + buildSettings = {
  1010 + CODE_SIGN_IDENTITY = "";
  1011 + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = "";
  1012 + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
  1013 + "CODE_SIGN_IDENTITY[sdk=watchos*]" = "";
  1014 + CURRENT_PROJECT_VERSION = 1;
  1015 + DEFINES_MODULE = YES;
  1016 + DYLIB_COMPATIBILITY_VERSION = 1;
  1017 + DYLIB_CURRENT_VERSION = 1;
  1018 + DYLIB_INSTALL_NAME_BASE = "@rpath";
  1019 + GCC_PREFIX_HEADER = "Target Support Files/AFNetworking/AFNetworking-prefix.pch";
  1020 + INFOPLIST_FILE = "Target Support Files/AFNetworking/Info.plist";
711 1021 INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
712 1022 IPHONEOS_DEPLOYMENT_TARGET = 8.0;
713 1023 LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
  1024 + MODULEMAP_FILE = "Target Support Files/AFNetworking/AFNetworking.modulemap";
  1025 + PRODUCT_MODULE_NAME = AFNetworking;
  1026 + PRODUCT_NAME = AFNetworking;
  1027 + SDKROOT = iphoneos;
  1028 + SKIP_INSTALL = YES;
  1029 + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) ";
  1030 + TARGETED_DEVICE_FAMILY = "1,2";
  1031 + VERSIONING_SYSTEM = "apple-generic";
  1032 + VERSION_INFO_PREFIX = "";
  1033 + };
  1034 + name = Debug;
  1035 + };
  1036 + ACDE442C7C149EBA631C730D00C6FCAD /* Release */ = {
  1037 + isa = XCBuildConfiguration;
  1038 + baseConfigurationReference = 1C9335BE61B442F6D1AB0A3CC50BABEF /* Pods-CNLivePublishContent_Tests.release.xcconfig */;
  1039 + buildSettings = {
  1040 + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO;
  1041 + CODE_SIGN_IDENTITY = "";
  1042 + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = "";
  1043 + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
  1044 + "CODE_SIGN_IDENTITY[sdk=watchos*]" = "";
  1045 + CURRENT_PROJECT_VERSION = 1;
  1046 + DEFINES_MODULE = YES;
  1047 + DYLIB_COMPATIBILITY_VERSION = 1;
  1048 + DYLIB_CURRENT_VERSION = 1;
  1049 + DYLIB_INSTALL_NAME_BASE = "@rpath";
  1050 + INFOPLIST_FILE = "Target Support Files/Pods-CNLivePublishContent_Tests/Info.plist";
  1051 + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
  1052 + IPHONEOS_DEPLOYMENT_TARGET = 9.0;
  1053 + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
714 1054 MACH_O_TYPE = staticlib;
715   - MODULEMAP_FILE = "Target Support Files/Pods-CNLivePublishContent_Example/Pods-CNLivePublishContent_Example.modulemap";
  1055 + MODULEMAP_FILE = "Target Support Files/Pods-CNLivePublishContent_Tests/Pods-CNLivePublishContent_Tests.modulemap";
716 1056 OTHER_LDFLAGS = "";
717 1057 OTHER_LIBTOOLFLAGS = "";
718 1058 PODS_ROOT = "$(SRCROOT)";
... ... @@ -721,14 +1061,47 @@
721 1061 SDKROOT = iphoneos;
722 1062 SKIP_INSTALL = YES;
723 1063 TARGETED_DEVICE_FAMILY = "1,2";
  1064 + VALIDATE_PRODUCT = YES;
724 1065 VERSIONING_SYSTEM = "apple-generic";
725 1066 VERSION_INFO_PREFIX = "";
726 1067 };
727   - name = Debug;
  1068 + name = Release;
728 1069 };
729   - FDD795B3C642219662009E4A0DBCE297 /* Debug */ = {
  1070 + BAD679F1D8D93112BC0230F672D178A5 /* Release */ = {
730 1071 isa = XCBuildConfiguration;
731   - baseConfigurationReference = 1DAF2307943F6D77C96929BE990D624A /* Pods-CNLivePublishContent_Tests.debug.xcconfig */;
  1072 + baseConfigurationReference = A9D8CE8A5B7231642B4C0869AB97B2AC /* CNLivePublishContent.xcconfig */;
  1073 + buildSettings = {
  1074 + CODE_SIGN_IDENTITY = "";
  1075 + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = "";
  1076 + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
  1077 + "CODE_SIGN_IDENTITY[sdk=watchos*]" = "";
  1078 + CURRENT_PROJECT_VERSION = 1;
  1079 + DEFINES_MODULE = YES;
  1080 + DYLIB_COMPATIBILITY_VERSION = 1;
  1081 + DYLIB_CURRENT_VERSION = 1;
  1082 + DYLIB_INSTALL_NAME_BASE = "@rpath";
  1083 + GCC_PREFIX_HEADER = "Target Support Files/CNLivePublishContent/CNLivePublishContent-prefix.pch";
  1084 + INFOPLIST_FILE = "Target Support Files/CNLivePublishContent/Info.plist";
  1085 + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
  1086 + IPHONEOS_DEPLOYMENT_TARGET = 9.0;
  1087 + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
  1088 + MACH_O_TYPE = staticlib;
  1089 + MODULEMAP_FILE = "Target Support Files/CNLivePublishContent/CNLivePublishContent.modulemap";
  1090 + PRODUCT_MODULE_NAME = CNLivePublishContent;
  1091 + PRODUCT_NAME = CNLivePublishContent;
  1092 + SDKROOT = iphoneos;
  1093 + SKIP_INSTALL = YES;
  1094 + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) ";
  1095 + TARGETED_DEVICE_FAMILY = "1,2";
  1096 + VALIDATE_PRODUCT = YES;
  1097 + VERSIONING_SYSTEM = "apple-generic";
  1098 + VERSION_INFO_PREFIX = "";
  1099 + };
  1100 + name = Release;
  1101 + };
  1102 + C9ED161BEF030713C1411102837EC6BB /* Debug */ = {
  1103 + isa = XCBuildConfiguration;
  1104 + baseConfigurationReference = C68C10F080BCB4BB67EFF63349322381 /* Pods-CNLivePublishContent_Example.debug.xcconfig */;
732 1105 buildSettings = {
733 1106 ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO;
734 1107 CODE_SIGN_IDENTITY = "";
... ... @@ -740,12 +1113,12 @@
740 1113 DYLIB_COMPATIBILITY_VERSION = 1;
741 1114 DYLIB_CURRENT_VERSION = 1;
742 1115 DYLIB_INSTALL_NAME_BASE = "@rpath";
743   - INFOPLIST_FILE = "Target Support Files/Pods-CNLivePublishContent_Tests/Info.plist";
  1116 + INFOPLIST_FILE = "Target Support Files/Pods-CNLivePublishContent_Example/Info.plist";
744 1117 INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
745   - IPHONEOS_DEPLOYMENT_TARGET = 8.0;
  1118 + IPHONEOS_DEPLOYMENT_TARGET = 9.0;
746 1119 LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
747 1120 MACH_O_TYPE = staticlib;
748   - MODULEMAP_FILE = "Target Support Files/Pods-CNLivePublishContent_Tests/Pods-CNLivePublishContent_Tests.modulemap";
  1121 + MODULEMAP_FILE = "Target Support Files/Pods-CNLivePublishContent_Example/Pods-CNLivePublishContent_Example.modulemap";
749 1122 OTHER_LDFLAGS = "";
750 1123 OTHER_LIBTOOLFLAGS = "";
751 1124 PODS_ROOT = "$(SRCROOT)";
... ... @@ -762,38 +1135,47 @@
762 1135 /* End XCBuildConfiguration section */
763 1136  
764 1137 /* Begin XCConfigurationList section */
765   - 0D5BB5C269806AEEA5BB4FDD76DE132C /* Build configuration list for PBXNativeTarget "Pods-CNLivePublishContent_Example" */ = {
  1138 + 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */ = {
766 1139 isa = XCConfigurationList;
767 1140 buildConfigurations = (
768   - D6E658B823460E1A092ADDD2BE1B713C /* Debug */,
769   - 9271BE75C990EC87EA89EB63C209F2C7 /* Release */,
  1141 + 858D01EEFE984249A9581D18DBEA53F1 /* Debug */,
  1142 + 5DE19CECB206ACCCACF04D62F93FFDA6 /* Release */,
770 1143 );
771 1144 defaultConfigurationIsVisible = 0;
772 1145 defaultConfigurationName = Release;
773 1146 };
774   - 20CA38EE2EFA75F5625B7F9A3FC860E4 /* Build configuration list for PBXNativeTarget "Pods-CNLivePublishContent_Tests" */ = {
  1147 + 31C66CE74F19C7D8A8F842B6B902D672 /* Build configuration list for PBXNativeTarget "Pods-CNLivePublishContent_Example" */ = {
775 1148 isa = XCConfigurationList;
776 1149 buildConfigurations = (
777   - FDD795B3C642219662009E4A0DBCE297 /* Debug */,
778   - 6F179C11BC8462CD5831BA140F5B0073 /* Release */,
  1150 + C9ED161BEF030713C1411102837EC6BB /* Debug */,
  1151 + 1843215834F5986609CD5856CFF60501 /* Release */,
779 1152 );
780 1153 defaultConfigurationIsVisible = 0;
781 1154 defaultConfigurationName = Release;
782 1155 };
783   - 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */ = {
  1156 + 565610290BC02A1EA9383D220B6A742B /* Build configuration list for PBXNativeTarget "CNLivePublishContent" */ = {
  1157 + isa = XCConfigurationList;
  1158 + buildConfigurations = (
  1159 + 5184FC30B3970AE203A02597EA9DCBD8 /* Debug */,
  1160 + BAD679F1D8D93112BC0230F672D178A5 /* Release */,
  1161 + );
  1162 + defaultConfigurationIsVisible = 0;
  1163 + defaultConfigurationName = Release;
  1164 + };
  1165 + 8289B039CF0D8B5A385C13089893A356 /* Build configuration list for PBXNativeTarget "AFNetworking" */ = {
784 1166 isa = XCConfigurationList;
785 1167 buildConfigurations = (
786   - A73625DEBD810B78234FA1958C191C8C /* Debug */,
787   - 85B95B1234E227C814CCC2C7902D0916 /* Release */,
  1168 + 9F05FB7480ECA0237560017761177F3A /* Debug */,
  1169 + 8D2DCA929D6EAACBC099C6391F176FAB /* Release */,
788 1170 );
789 1171 defaultConfigurationIsVisible = 0;
790 1172 defaultConfigurationName = Release;
791 1173 };
792   - 9F833024D052981976E7CD614FDC047C /* Build configuration list for PBXNativeTarget "CNLivePublishContent" */ = {
  1174 + E0F3EA5CE7DFAD07D828D8C5A8A718E7 /* Build configuration list for PBXNativeTarget "Pods-CNLivePublishContent_Tests" */ = {
793 1175 isa = XCConfigurationList;
794 1176 buildConfigurations = (
795   - 78EEAC066F2F601461DD7DFBC5D37E97 /* Debug */,
796   - 8BEFD3C4823C93BE25A26E27E3709B41 /* Release */,
  1177 + 5229405B05FF6B657D04BA602DA53837 /* Debug */,
  1178 + ACDE442C7C149EBA631C730D00C6FCAD /* Release */,
797 1179 );
798 1180 defaultConfigurationIsVisible = 0;
799 1181 defaultConfigurationName = Release;
... ...
Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/CNLivePublishContent 2.xcscheme 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<Scheme
  3 + LastUpgradeVersion = "1000"
  4 + version = "1.3">
  5 + <BuildAction
  6 + parallelizeBuildables = "YES"
  7 + buildImplicitDependencies = "YES">
  8 + <BuildActionEntries>
  9 + <BuildActionEntry
  10 + buildForTesting = "YES"
  11 + buildForRunning = "YES"
  12 + buildForProfiling = "YES"
  13 + buildForArchiving = "YES"
  14 + buildForAnalyzing = "YES">
  15 + <BuildableReference
  16 + BuildableIdentifier = "primary"
  17 + BlueprintIdentifier = "53014DEFF54C52A0CA58002ACFDEEF5B"
  18 + BuildableName = "CNLivePublishContent.framework"
  19 + BlueprintName = "CNLivePublishContent"
  20 + ReferencedContainer = "container:Pods.xcodeproj">
  21 + </BuildableReference>
  22 + </BuildActionEntry>
  23 + </BuildActionEntries>
  24 + </BuildAction>
  25 + <TestAction
  26 + buildConfiguration = "Debug"
  27 + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
  28 + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
  29 + shouldUseLaunchSchemeArgsEnv = "YES">
  30 + <Testables>
  31 + </Testables>
  32 + <AdditionalOptions>
  33 + </AdditionalOptions>
  34 + </TestAction>
  35 + <LaunchAction
  36 + buildConfiguration = "Debug"
  37 + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
  38 + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
  39 + launchStyle = "0"
  40 + useCustomWorkingDirectory = "NO"
  41 + ignoresPersistentStateOnLaunch = "NO"
  42 + debugDocumentVersioning = "YES"
  43 + debugServiceExtension = "internal"
  44 + allowLocationSimulation = "YES">
  45 + <MacroExpansion>
  46 + <BuildableReference
  47 + BuildableIdentifier = "primary"
  48 + BlueprintIdentifier = "53014DEFF54C52A0CA58002ACFDEEF5B"
  49 + BuildableName = "CNLivePublishContent.framework"
  50 + BlueprintName = "CNLivePublishContent"
  51 + ReferencedContainer = "container:Pods.xcodeproj">
  52 + </BuildableReference>
  53 + </MacroExpansion>
  54 + <AdditionalOptions>
  55 + </AdditionalOptions>
  56 + </LaunchAction>
  57 + <ProfileAction
  58 + buildConfiguration = "Release"
  59 + shouldUseLaunchSchemeArgsEnv = "YES"
  60 + savedToolIdentifier = ""
  61 + useCustomWorkingDirectory = "NO"
  62 + debugDocumentVersioning = "YES">
  63 + <MacroExpansion>
  64 + <BuildableReference
  65 + BuildableIdentifier = "primary"
  66 + BlueprintIdentifier = "53014DEFF54C52A0CA58002ACFDEEF5B"
  67 + BuildableName = "CNLivePublishContent.framework"
  68 + BlueprintName = "CNLivePublishContent"
  69 + ReferencedContainer = "container:Pods.xcodeproj">
  70 + </BuildableReference>
  71 + </MacroExpansion>
  72 + </ProfileAction>
  73 + <AnalyzeAction
  74 + buildConfiguration = "Debug">
  75 + </AnalyzeAction>
  76 + <ArchiveAction
  77 + buildConfiguration = "Release"
  78 + revealArchiveInOrganizer = "YES">
  79 + </ArchiveAction>
  80 +</Scheme>
... ...
Example/Pods/Target Support Files/AFNetworking/AFNetworking-dummy.m 0 → 100644
  1 +#import <Foundation/Foundation.h>
  2 +@interface PodsDummy_AFNetworking : NSObject
  3 +@end
  4 +@implementation PodsDummy_AFNetworking
  5 +@end
... ...
Example/Pods/Target Support Files/AFNetworking/AFNetworking-prefix.pch 0 → 100644
  1 +#ifdef __OBJC__
  2 +#import <UIKit/UIKit.h>
  3 +#else
  4 +#ifndef FOUNDATION_EXPORT
  5 +#if defined(__cplusplus)
  6 +#define FOUNDATION_EXPORT extern "C"
  7 +#else
  8 +#define FOUNDATION_EXPORT extern
  9 +#endif
  10 +#endif
  11 +#endif
  12 +
  13 +#ifndef TARGET_OS_IOS
  14 + #define TARGET_OS_IOS TARGET_OS_IPHONE
  15 +#endif
  16 +
  17 +#ifndef TARGET_OS_WATCH
  18 + #define TARGET_OS_WATCH 0
  19 +#endif
  20 +
  21 +#ifndef TARGET_OS_TV
  22 + #define TARGET_OS_TV 0
  23 +#endif
... ...
Example/Pods/Target Support Files/AFNetworking/AFNetworking-umbrella.h 0 → 100644
  1 +#ifdef __OBJC__
  2 +#import <UIKit/UIKit.h>
  3 +#else
  4 +#ifndef FOUNDATION_EXPORT
  5 +#if defined(__cplusplus)
  6 +#define FOUNDATION_EXPORT extern "C"
  7 +#else
  8 +#define FOUNDATION_EXPORT extern
  9 +#endif
  10 +#endif
  11 +#endif
  12 +
  13 +#import "AFNetworking.h"
  14 +#import "AFHTTPSessionManager.h"
  15 +#import "AFURLSessionManager.h"
  16 +#import "AFCompatibilityMacros.h"
  17 +#import "AFNetworkReachabilityManager.h"
  18 +#import "AFSecurityPolicy.h"
  19 +#import "AFURLRequestSerialization.h"
  20 +#import "AFURLResponseSerialization.h"
  21 +#import "AFAutoPurgingImageCache.h"
  22 +#import "AFImageDownloader.h"
  23 +#import "AFNetworkActivityIndicatorManager.h"
  24 +#import "UIActivityIndicatorView+AFNetworking.h"
  25 +#import "UIButton+AFNetworking.h"
  26 +#import "UIImage+AFNetworking.h"
  27 +#import "UIImageView+AFNetworking.h"
  28 +#import "UIKit+AFNetworking.h"
  29 +#import "UIProgressView+AFNetworking.h"
  30 +#import "UIRefreshControl+AFNetworking.h"
  31 +#import "UIWebView+AFNetworking.h"
  32 +
  33 +FOUNDATION_EXPORT double AFNetworkingVersionNumber;
  34 +FOUNDATION_EXPORT const unsigned char AFNetworkingVersionString[];
  35 +
... ...
Example/Pods/Target Support Files/AFNetworking/AFNetworking.modulemap 0 → 100644
  1 +framework module AFNetworking {
  2 + umbrella header "AFNetworking-umbrella.h"
  3 +
  4 + export *
  5 + module * { export * }
  6 +}
... ...
Example/Pods/Target Support Files/AFNetworking/AFNetworking.xcconfig 0 → 100644
  1 +CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking
  2 +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
  3 +OTHER_LDFLAGS = -framework "CoreGraphics" -framework "MobileCoreServices" -framework "Security" -framework "SystemConfiguration"
  4 +PODS_BUILD_DIR = ${BUILD_DIR}
  5 +PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
  6 +PODS_ROOT = ${SRCROOT}
  7 +PODS_TARGET_SRCROOT = ${PODS_ROOT}/AFNetworking
  8 +PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
  9 +SKIP_INSTALL = YES
... ...
Example/Pods/Target Support Files/AFNetworking/Info.plist 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  3 +<plist version="1.0">
  4 +<dict>
  5 + <key>CFBundleDevelopmentRegion</key>
  6 + <string>en</string>
  7 + <key>CFBundleExecutable</key>
  8 + <string>${EXECUTABLE_NAME}</string>
  9 + <key>CFBundleIdentifier</key>
  10 + <string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
  11 + <key>CFBundleInfoDictionaryVersion</key>
  12 + <string>6.0</string>
  13 + <key>CFBundleName</key>
  14 + <string>${PRODUCT_NAME}</string>
  15 + <key>CFBundlePackageType</key>
  16 + <string>FMWK</string>
  17 + <key>CFBundleShortVersionString</key>
  18 + <string>3.2.1</string>
  19 + <key>CFBundleSignature</key>
  20 + <string>????</string>
  21 + <key>CFBundleVersion</key>
  22 + <string>${CURRENT_PROJECT_VERSION}</string>
  23 + <key>NSPrincipalClass</key>
  24 + <string></string>
  25 +</dict>
  26 +</plist>
... ...
Example/Pods/Target Support Files/CNLivePublishContent/CNLivePublishContent-umbrella.h
... ... @@ -10,6 +10,7 @@
10 10 #endif
11 11 #endif
12 12  
  13 +#import "YQJTest.h"
13 14  
14 15 FOUNDATION_EXPORT double CNLivePublishContentVersionNumber;
15 16 FOUNDATION_EXPORT const unsigned char CNLivePublishContentVersionString[];
... ...
Example/Pods/Target Support Files/CNLivePublishContent/CNLivePublishContent.xcconfig
1 1 CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/CNLivePublishContent
  2 +FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking"
2 3 GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
  4 +OTHER_LDFLAGS = -framework "Foundation" -framework "UIKit"
3 5 PODS_BUILD_DIR = ${BUILD_DIR}
4 6 PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
5 7 PODS_ROOT = ${SRCROOT}
... ...
Example/Pods/Target Support Files/CNLivePublishContent/Info.plist
... ... @@ -15,7 +15,7 @@
15 15 <key>CFBundlePackageType</key>
16 16 <string>FMWK</string>
17 17 <key>CFBundleShortVersionString</key>
18   - <string>0.1.0</string>
  18 + <string>0.0.1</string>
19 19 <key>CFBundleSignature</key>
20 20 <string>????</string>
21 21 <key>CFBundleVersion</key>
... ...
Example/Pods/Target Support Files/Pods-CNLivePublishContent_Example/Pods-CNLivePublishContent_Example-acknowledgements.markdown
1 1 # Acknowledgements
2 2 This application makes use of the following third party libraries:
3 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 +
4 27 ## CNLivePublishContent
5 28  
6 29 Copyright (c) 2018 殷巧娟 <1427945373@qq.com>
... ...
Example/Pods/Target Support Files/Pods-CNLivePublishContent_Example/Pods-CNLivePublishContent_Example-acknowledgements.plist
... ... @@ -14,6 +14,35 @@
14 14 </dict>
15 15 <dict>
16 16 <key>FooterText</key>
  17 + <string>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 +</string>
  37 + <key>License</key>
  38 + <string>MIT</string>
  39 + <key>Title</key>
  40 + <string>AFNetworking</string>
  41 + <key>Type</key>
  42 + <string>PSGroupSpecifier</string>
  43 + </dict>
  44 + <dict>
  45 + <key>FooterText</key>
17 46 <string>Copyright (c) 2018 殷巧娟 &lt;1427945373@qq.com&gt;
18 47  
19 48 Permission is hereby granted, free of charge, to any person obtaining a copy
... ...
Example/Pods/Target Support Files/Pods-CNLivePublishContent_Example/Pods-CNLivePublishContent_Example-frameworks.sh
... ... @@ -143,9 +143,11 @@ strip_invalid_archs() {
143 143  
144 144  
145 145 if [[ "$CONFIGURATION" == "Debug" ]]; then
  146 + install_framework "${BUILT_PRODUCTS_DIR}/AFNetworking/AFNetworking.framework"
146 147 install_framework "${BUILT_PRODUCTS_DIR}/CNLivePublishContent/CNLivePublishContent.framework"
147 148 fi
148 149 if [[ "$CONFIGURATION" == "Release" ]]; then
  150 + install_framework "${BUILT_PRODUCTS_DIR}/AFNetworking/AFNetworking.framework"
149 151 install_framework "${BUILT_PRODUCTS_DIR}/CNLivePublishContent/CNLivePublishContent.framework"
150 152 fi
151 153 if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then
... ...
Example/Pods/Target Support Files/Pods-CNLivePublishContent_Example/Pods-CNLivePublishContent_Example.debug.xcconfig
1   -FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CNLivePublishContent"
  1 +FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking" "${PODS_CONFIGURATION_BUILD_DIR}/CNLivePublishContent"
2 2 GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
3 3 LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
4   -OTHER_CFLAGS = $(inherited) -iquote "${PODS_CONFIGURATION_BUILD_DIR}/CNLivePublishContent/CNLivePublishContent.framework/Headers"
5   -OTHER_LDFLAGS = $(inherited) -framework "CNLivePublishContent"
  4 +OTHER_CFLAGS = $(inherited) -iquote "${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking/AFNetworking.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/CNLivePublishContent/CNLivePublishContent.framework/Headers"
  5 +OTHER_LDFLAGS = $(inherited) -framework "AFNetworking" -framework "CNLivePublishContent"
6 6 PODS_BUILD_DIR = ${BUILD_DIR}
7 7 PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
8 8 PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
... ...
Example/Pods/Target Support Files/Pods-CNLivePublishContent_Example/Pods-CNLivePublishContent_Example.release.xcconfig
1   -FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CNLivePublishContent"
  1 +FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking" "${PODS_CONFIGURATION_BUILD_DIR}/CNLivePublishContent"
2 2 GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
3 3 LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
4   -OTHER_CFLAGS = $(inherited) -iquote "${PODS_CONFIGURATION_BUILD_DIR}/CNLivePublishContent/CNLivePublishContent.framework/Headers"
5   -OTHER_LDFLAGS = $(inherited) -framework "CNLivePublishContent"
  4 +OTHER_CFLAGS = $(inherited) -iquote "${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking/AFNetworking.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/CNLivePublishContent/CNLivePublishContent.framework/Headers"
  5 +OTHER_LDFLAGS = $(inherited) -framework "AFNetworking" -framework "CNLivePublishContent"
6 6 PODS_BUILD_DIR = ${BUILD_DIR}
7 7 PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
8 8 PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
... ...
Example/Pods/Target Support Files/Pods-CNLivePublishContent_Tests/Pods-CNLivePublishContent_Tests-acknowledgements.markdown
1 1 # Acknowledgements
2 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 +
3 26 Generated by CocoaPods - https://cocoapods.org
... ...
Example/Pods/Target Support Files/Pods-CNLivePublishContent_Tests/Pods-CNLivePublishContent_Tests-acknowledgements.plist
... ... @@ -14,6 +14,35 @@
14 14 </dict>
15 15 <dict>
16 16 <key>FooterText</key>
  17 + <string>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 +</string>
  37 + <key>License</key>
  38 + <string>MIT</string>
  39 + <key>Title</key>
  40 + <string>AFNetworking</string>
  41 + <key>Type</key>
  42 + <string>PSGroupSpecifier</string>
  43 + </dict>
  44 + <dict>
  45 + <key>FooterText</key>
17 46 <string>Generated by CocoaPods - https://cocoapods.org</string>
18 47 <key>Title</key>
19 48 <string></string>
... ...
Example/Pods/Target Support Files/Pods-CNLivePublishContent_Tests/Pods-CNLivePublishContent_Tests-frameworks.sh
... ... @@ -141,6 +141,13 @@ strip_invalid_archs() {
141 141 STRIP_BINARY_RETVAL=1
142 142 }
143 143  
  144 +
  145 +if [[ "$CONFIGURATION" == "Debug" ]]; then
  146 + install_framework "${BUILT_PRODUCTS_DIR}/AFNetworking/AFNetworking.framework"
  147 +fi
  148 +if [[ "$CONFIGURATION" == "Release" ]]; then
  149 + install_framework "${BUILT_PRODUCTS_DIR}/AFNetworking/AFNetworking.framework"
  150 +fi
144 151 if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then
145 152 wait
146 153 fi
... ...
Example/Pods/Target Support Files/Pods-CNLivePublishContent_Tests/Pods-CNLivePublishContent_Tests.debug.xcconfig
1   -FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CNLivePublishContent"
  1 +FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking" "${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking" "${PODS_CONFIGURATION_BUILD_DIR}/CNLivePublishContent"
2 2 GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
3 3 LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
4   -OTHER_CFLAGS = $(inherited) -iquote "${PODS_CONFIGURATION_BUILD_DIR}/CNLivePublishContent/CNLivePublishContent.framework/Headers"
  4 +OTHER_CFLAGS = $(inherited) -iquote "${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking/AFNetworking.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking/AFNetworking.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/CNLivePublishContent/CNLivePublishContent.framework/Headers"
  5 +OTHER_LDFLAGS = $(inherited) -framework "AFNetworking"
5 6 PODS_BUILD_DIR = ${BUILD_DIR}
6 7 PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
7 8 PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
... ...
Example/Pods/Target Support Files/Pods-CNLivePublishContent_Tests/Pods-CNLivePublishContent_Tests.release.xcconfig
1   -FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CNLivePublishContent"
  1 +FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking" "${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking" "${PODS_CONFIGURATION_BUILD_DIR}/CNLivePublishContent"
2 2 GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
3 3 LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
4   -OTHER_CFLAGS = $(inherited) -iquote "${PODS_CONFIGURATION_BUILD_DIR}/CNLivePublishContent/CNLivePublishContent.framework/Headers"
  4 +OTHER_CFLAGS = $(inherited) -iquote "${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking/AFNetworking.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking/AFNetworking.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/CNLivePublishContent/CNLivePublishContent.framework/Headers"
  5 +OTHER_LDFLAGS = $(inherited) -framework "AFNetworking"
5 6 PODS_BUILD_DIR = ${BUILD_DIR}
6 7 PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
7 8 PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
... ...