weclouds 2 年之前
当前提交
50fce4bc1a
共有 100 个文件被更改,包括 12870 次插入0 次删除
  1. 15 0
      Podfile
  2. 75 0
      Podfile.lock
  3. 295 0
      Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.h
  4. 361 0
      Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.m
  5. 206 0
      Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.h
  6. 263 0
      Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.m
  7. 41 0
      Pods/AFNetworking/AFNetworking/AFNetworking.h
  8. 154 0
      Pods/AFNetworking/AFNetworking/AFSecurityPolicy.h
  9. 353 0
      Pods/AFNetworking/AFNetworking/AFSecurityPolicy.m
  10. 479 0
      Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.h
  11. 1376 0
      Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.m
  12. 311 0
      Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.h
  13. 805 0
      Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.m
  14. 500 0
      Pods/AFNetworking/AFNetworking/AFURLSessionManager.h
  15. 1244 0
      Pods/AFNetworking/AFNetworking/AFURLSessionManager.m
  16. 19 0
      Pods/AFNetworking/LICENSE
  17. 320 0
      Pods/AFNetworking/README.md
  18. 149 0
      Pods/AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.h
  19. 201 0
      Pods/AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.m
  20. 157 0
      Pods/AFNetworking/UIKit+AFNetworking/AFImageDownloader.h
  21. 391 0
      Pods/AFNetworking/UIKit+AFNetworking/AFImageDownloader.m
  22. 103 0
      Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h
  23. 261 0
      Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m
  24. 48 0
      Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h
  25. 124 0
      Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m
  26. 175 0
      Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h
  27. 305 0
      Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.m
  28. 35 0
      Pods/AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h
  29. 109 0
      Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h
  30. 161 0
      Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.m
  31. 42 0
      Pods/AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h
  32. 64 0
      Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h
  33. 118 0
      Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.m
  34. 53 0
      Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h
  35. 122 0
      Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m
  36. 80 0
      Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h
  37. 162 0
      Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.m
  38. 551 0
      Pods/BabyBluetooth/Classes/objc/BabyBluetooth.h
  39. 668 0
      Pods/BabyBluetooth/Classes/objc/BabyBluetooth.m
  40. 137 0
      Pods/BabyBluetooth/Classes/objc/BabyCallback.h
  41. 34 0
      Pods/BabyBluetooth/Classes/objc/BabyCallback.m
  42. 92 0
      Pods/BabyBluetooth/Classes/objc/BabyCentralManager.h
  43. 483 0
      Pods/BabyBluetooth/Classes/objc/BabyCentralManager.m
  44. 77 0
      Pods/BabyBluetooth/Classes/objc/BabyDefine.h
  45. 16 0
      Pods/BabyBluetooth/Classes/objc/BabyDefine.m
  46. 67 0
      Pods/BabyBluetooth/Classes/objc/BabyOptions.h
  47. 51 0
      Pods/BabyBluetooth/Classes/objc/BabyOptions.m
  48. 74 0
      Pods/BabyBluetooth/Classes/objc/BabyPeripheralManager.h
  49. 234 0
      Pods/BabyBluetooth/Classes/objc/BabyPeripheralManager.m
  50. 47 0
      Pods/BabyBluetooth/Classes/objc/BabyRhythm.h
  51. 77 0
      Pods/BabyBluetooth/Classes/objc/BabyRhythm.m
  52. 42 0
      Pods/BabyBluetooth/Classes/objc/BabySpeaker.h
  53. 112 0
      Pods/BabyBluetooth/Classes/objc/BabySpeaker.m
  54. 34 0
      Pods/BabyBluetooth/Classes/objc/BabyToy.h
  55. 91 0
      Pods/BabyBluetooth/Classes/objc/BabyToy.m
  56. 22 0
      Pods/BabyBluetooth/LICENSE
  57. 242 0
      Pods/BabyBluetooth/README.md
  58. 1 0
      Pods/Headers/Private/AFNetworking/AFAutoPurgingImageCache.h
  59. 1 0
      Pods/Headers/Private/AFNetworking/AFHTTPSessionManager.h
  60. 1 0
      Pods/Headers/Private/AFNetworking/AFImageDownloader.h
  61. 1 0
      Pods/Headers/Private/AFNetworking/AFNetworkActivityIndicatorManager.h
  62. 1 0
      Pods/Headers/Private/AFNetworking/AFNetworkReachabilityManager.h
  63. 1 0
      Pods/Headers/Private/AFNetworking/AFNetworking.h
  64. 1 0
      Pods/Headers/Private/AFNetworking/AFSecurityPolicy.h
  65. 1 0
      Pods/Headers/Private/AFNetworking/AFURLRequestSerialization.h
  66. 1 0
      Pods/Headers/Private/AFNetworking/AFURLResponseSerialization.h
  67. 1 0
      Pods/Headers/Private/AFNetworking/AFURLSessionManager.h
  68. 1 0
      Pods/Headers/Private/AFNetworking/UIActivityIndicatorView+AFNetworking.h
  69. 1 0
      Pods/Headers/Private/AFNetworking/UIButton+AFNetworking.h
  70. 1 0
      Pods/Headers/Private/AFNetworking/UIImage+AFNetworking.h
  71. 1 0
      Pods/Headers/Private/AFNetworking/UIImageView+AFNetworking.h
  72. 1 0
      Pods/Headers/Private/AFNetworking/UIKit+AFNetworking.h
  73. 1 0
      Pods/Headers/Private/AFNetworking/UIProgressView+AFNetworking.h
  74. 1 0
      Pods/Headers/Private/AFNetworking/UIRefreshControl+AFNetworking.h
  75. 1 0
      Pods/Headers/Private/AFNetworking/UIWebView+AFNetworking.h
  76. 1 0
      Pods/Headers/Private/BabyBluetooth/BabyBluetooth.h
  77. 1 0
      Pods/Headers/Private/BabyBluetooth/BabyCallback.h
  78. 1 0
      Pods/Headers/Private/BabyBluetooth/BabyCentralManager.h
  79. 1 0
      Pods/Headers/Private/BabyBluetooth/BabyDefine.h
  80. 1 0
      Pods/Headers/Private/BabyBluetooth/BabyOptions.h
  81. 1 0
      Pods/Headers/Private/BabyBluetooth/BabyPeripheralManager.h
  82. 1 0
      Pods/Headers/Private/BabyBluetooth/BabyRhythm.h
  83. 1 0
      Pods/Headers/Private/BabyBluetooth/BabySpeaker.h
  84. 1 0
      Pods/Headers/Private/BabyBluetooth/BabyToy.h
  85. 1 0
      Pods/Headers/Private/IQKeyboardManager/IQBarButtonItem.h
  86. 1 0
      Pods/Headers/Private/IQKeyboardManager/IQKeyboardManager.h
  87. 1 0
      Pods/Headers/Private/IQKeyboardManager/IQKeyboardManagerConstants.h
  88. 1 0
      Pods/Headers/Private/IQKeyboardManager/IQKeyboardManagerConstantsInternal.h
  89. 1 0
      Pods/Headers/Private/IQKeyboardManager/IQKeyboardReturnKeyHandler.h
  90. 1 0
      Pods/Headers/Private/IQKeyboardManager/IQNSArray+Sort.h
  91. 1 0
      Pods/Headers/Private/IQKeyboardManager/IQPreviousNextView.h
  92. 1 0
      Pods/Headers/Private/IQKeyboardManager/IQTextView.h
  93. 1 0
      Pods/Headers/Private/IQKeyboardManager/IQTitleBarButtonItem.h
  94. 1 0
      Pods/Headers/Private/IQKeyboardManager/IQToolbar.h
  95. 1 0
      Pods/Headers/Private/IQKeyboardManager/IQUIScrollView+Additions.h
  96. 1 0
      Pods/Headers/Private/IQKeyboardManager/IQUITextFieldView+Additions.h
  97. 1 0
      Pods/Headers/Private/IQKeyboardManager/IQUIView+Hierarchy.h
  98. 1 0
      Pods/Headers/Private/IQKeyboardManager/IQUIView+IQKeyboardToolbar.h
  99. 1 0
      Pods/Headers/Private/IQKeyboardManager/IQUIViewController+Additions.h
  100. 0 0
      Pods/Headers/Private/IQKeyboardManager/IQUIWindow+Hierarchy.h

+ 15 - 0
Podfile

@@ -0,0 +1,15 @@
+source 'https://github.com/CocoaPods/Specs.git'
+platform :ios, '8.0'
+target 'StreetLampProject' do
+pod 'MBProgressHUD', '~> 1.0.0'
+pod 'AFNetworking', '~> 3.1.0'
+pod 'Masonry', '~> 1.0.2'
+pod 'MJRefresh', '~> 3.1.12'
+pod 'SDWebImage', '~> 4.0.0'
+pod 'JSONModel', '~> 1.7.0'
+pod 'IQKeyboardManager', '~> 4.0.11'
+pod 'YYKit'
+pod 'YTKNetwork'
+pod 'BabyBluetooth', '~> 0.7.0'
+pod 'Toast', '~> 4.0.0'
+end

+ 75 - 0
Podfile.lock

@@ -0,0 +1,75 @@
+PODS:
+  - AFNetworking (3.1.0):
+    - AFNetworking/NSURLSession (= 3.1.0)
+    - AFNetworking/Reachability (= 3.1.0)
+    - AFNetworking/Security (= 3.1.0)
+    - AFNetworking/Serialization (= 3.1.0)
+    - AFNetworking/UIKit (= 3.1.0)
+  - AFNetworking/NSURLSession (3.1.0):
+    - AFNetworking/Reachability
+    - AFNetworking/Security
+    - AFNetworking/Serialization
+  - AFNetworking/Reachability (3.1.0)
+  - AFNetworking/Security (3.1.0)
+  - AFNetworking/Serialization (3.1.0)
+  - AFNetworking/UIKit (3.1.0):
+    - AFNetworking/NSURLSession
+  - BabyBluetooth (0.7.0)
+  - IQKeyboardManager (4.0.13)
+  - JSONModel (1.7.0)
+  - Masonry (1.0.2)
+  - MBProgressHUD (1.0.0)
+  - MJRefresh (3.1.17)
+  - SDWebImage (4.0.0):
+    - SDWebImage/Core (= 4.0.0)
+  - SDWebImage/Core (4.0.0)
+  - Toast (4.0.0)
+  - YTKNetwork (2.0.4):
+    - AFNetworking (~> 3.0)
+  - YYKit (1.0.9):
+    - YYKit/no-arc (= 1.0.9)
+  - YYKit/no-arc (1.0.9)
+
+DEPENDENCIES:
+  - AFNetworking (~> 3.1.0)
+  - BabyBluetooth (~> 0.7.0)
+  - IQKeyboardManager (~> 4.0.11)
+  - JSONModel (~> 1.7.0)
+  - Masonry (~> 1.0.2)
+  - MBProgressHUD (~> 1.0.0)
+  - MJRefresh (~> 3.1.12)
+  - SDWebImage (~> 4.0.0)
+  - Toast (~> 4.0.0)
+  - YTKNetwork
+  - YYKit
+
+SPEC REPOS:
+  https://github.com/CocoaPods/Specs.git:
+    - AFNetworking
+    - BabyBluetooth
+    - IQKeyboardManager
+    - JSONModel
+    - Masonry
+    - MBProgressHUD
+    - MJRefresh
+    - SDWebImage
+    - Toast
+    - YTKNetwork
+    - YYKit
+
+SPEC CHECKSUMS:
+  AFNetworking: 5e0e199f73d8626b11e79750991f5d173d1f8b67
+  BabyBluetooth: d50758aecf24d4a0ab9271d69f0f116d6bee51c9
+  IQKeyboardManager: 8eab4d8111418414619d1df8e4779ce5d0f8d7e2
+  JSONModel: 840bc0fcffb24b8454d2c026bf26fea454b8e98d
+  Masonry: 7c429b56da9d4ee0bbb3ed77a5ea710d6a5df39e
+  MBProgressHUD: 4890f671c94e8a0f3cf959aa731e9de2f036d71a
+  MJRefresh: ee5b68f639775462faba4db0fd243baf4d42c2cf
+  SDWebImage: 76a6348bdc74eb5a55dd08a091ef298e56b55e41
+  Toast: 91b396c56ee72a5790816f40d3a94dd357abc196
+  YTKNetwork: df8a7a5597bda1664a4efaa7ef871a818a887fe0
+  YYKit: 7cda43304a8dc3696c449041e2cb3107b4e236e7
+
+PODFILE CHECKSUM: ecf85c22590423d821968f446bf0b3d644e8c175
+
+COCOAPODS: 1.8.4

+ 295 - 0
Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.h

@@ -0,0 +1,295 @@
+// AFHTTPSessionManager.h
+// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import <Foundation/Foundation.h>
+#if !TARGET_OS_WATCH
+#import <SystemConfiguration/SystemConfiguration.h>
+#endif
+#import <TargetConditionals.h>
+
+#if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV
+#import <MobileCoreServices/MobileCoreServices.h>
+#else
+#import <CoreServices/CoreServices.h>
+#endif
+
+#import "AFURLSessionManager.h"
+
+/**
+ `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.
+
+ ## Subclassing Notes
+
+ 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.
+
+ For developers targeting iOS 6 or Mac OS X 10.8 or earlier, `AFHTTPRequestOperationManager` may be used to similar effect.
+
+ ## Methods to Override
+
+ To change the behavior of all data task operation construction, which is also used in the `GET` / `POST` / et al. convenience methods, override `dataTaskWithRequest:completionHandler:`.
+
+ ## Serialization
+
+ 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>`.
+
+ Responses received from the server are automatically validated and serialized by the `responseSerializers` property, which is an object conforming to `<AFURLResponseSerialization>`
+
+ ## URL Construction Using Relative Paths
+
+ 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:`.
+
+ Below are a few examples of how `baseURL` and relative paths interact:
+
+    NSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"];
+    [NSURL URLWithString:@"foo" relativeToURL:baseURL];                  // http://example.com/v1/foo
+    [NSURL URLWithString:@"foo?bar=baz" relativeToURL:baseURL];          // http://example.com/v1/foo?bar=baz
+    [NSURL URLWithString:@"/foo" relativeToURL:baseURL];                 // http://example.com/foo
+    [NSURL URLWithString:@"foo/" relativeToURL:baseURL];                 // http://example.com/v1/foo
+    [NSURL URLWithString:@"/foo/" relativeToURL:baseURL];                // http://example.com/foo/
+    [NSURL URLWithString:@"http://example2.com/" relativeToURL:baseURL]; // http://example2.com/
+
+ 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.
+
+ @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.
+ */
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface AFHTTPSessionManager : AFURLSessionManager <NSSecureCoding, NSCopying>
+
+/**
+ The URL used to construct requests from relative paths in methods like `requestWithMethod:URLString:parameters:`, and the `GET` / `POST` / et al. convenience methods.
+ */
+@property (readonly, nonatomic, strong, nullable) NSURL *baseURL;
+
+/**
+ 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.
+
+ @warning `requestSerializer` must not be `nil`.
+ */
+@property (nonatomic, strong) AFHTTPRequestSerializer <AFURLRequestSerialization> * requestSerializer;
+
+/**
+ 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`.
+
+ @warning `responseSerializer` must not be `nil`.
+ */
+@property (nonatomic, strong) AFHTTPResponseSerializer <AFURLResponseSerialization> * responseSerializer;
+
+///---------------------
+/// @name Initialization
+///---------------------
+
+/**
+ Creates and returns an `AFHTTPSessionManager` object.
+ */
++ (instancetype)manager;
+
+/**
+ Initializes an `AFHTTPSessionManager` object with the specified base URL.
+
+ @param url The base URL for the HTTP client.
+
+ @return The newly-initialized HTTP client
+ */
+- (instancetype)initWithBaseURL:(nullable NSURL *)url;
+
+/**
+ Initializes an `AFHTTPSessionManager` object with the specified base URL.
+
+ This is the designated initializer.
+
+ @param url The base URL for the HTTP client.
+ @param configuration The configuration used to create the managed session.
+
+ @return The newly-initialized HTTP client
+ */
+- (instancetype)initWithBaseURL:(nullable NSURL *)url
+           sessionConfiguration:(nullable NSURLSessionConfiguration *)configuration NS_DESIGNATED_INITIALIZER;
+
+///---------------------------
+/// @name Making HTTP Requests
+///---------------------------
+
+/**
+ Creates and runs an `NSURLSessionDataTask` with a `GET` request.
+
+ @param URLString The URL string used to create the request URL.
+ @param parameters The parameters to be encoded according to the client request serializer.
+ @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.
+ @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.
+
+ @see -dataTaskWithRequest:completionHandler:
+ */
+- (nullable NSURLSessionDataTask *)GET:(NSString *)URLString
+                   parameters:(nullable id)parameters
+                      success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
+                      failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE;
+
+
+/**
+ Creates and runs an `NSURLSessionDataTask` with a `GET` request.
+
+ @param URLString The URL string used to create the request URL.
+ @param parameters The parameters to be encoded according to the client request serializer.
+ @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.
+ @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.
+ @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.
+
+ @see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:
+ */
+- (nullable NSURLSessionDataTask *)GET:(NSString *)URLString
+                            parameters:(nullable id)parameters
+                              progress:(nullable void (^)(NSProgress *downloadProgress))downloadProgress
+                               success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
+                               failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
+
+/**
+ Creates and runs an `NSURLSessionDataTask` with a `HEAD` request.
+
+ @param URLString The URL string used to create the request URL.
+ @param parameters The parameters to be encoded according to the client request serializer.
+ @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.
+ @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.
+
+ @see -dataTaskWithRequest:completionHandler:
+ */
+- (nullable NSURLSessionDataTask *)HEAD:(NSString *)URLString
+                    parameters:(nullable id)parameters
+                       success:(nullable void (^)(NSURLSessionDataTask *task))success
+                       failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
+
+/**
+ Creates and runs an `NSURLSessionDataTask` with a `POST` request.
+
+ @param URLString The URL string used to create the request URL.
+ @param parameters The parameters to be encoded according to the client request serializer.
+ @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.
+ @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.
+
+ @see -dataTaskWithRequest:completionHandler:
+ */
+- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString
+                    parameters:(nullable id)parameters
+                       success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
+                       failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE;
+
+/**
+ Creates and runs an `NSURLSessionDataTask` with a `POST` request.
+
+ @param URLString The URL string used to create the request URL.
+ @param parameters The parameters to be encoded according to the client request serializer.
+ @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.
+ @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.
+ @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.
+
+ @see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:
+ */
+- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString
+                             parameters:(nullable id)parameters
+                               progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgress
+                                success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
+                                failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
+
+/**
+ Creates and runs an `NSURLSessionDataTask` with a multipart `POST` request.
+
+ @param URLString The URL string used to create the request URL.
+ @param parameters The parameters to be encoded according to the client request serializer.
+ @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.
+ @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.
+ @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.
+
+ @see -dataTaskWithRequest:completionHandler:
+ */
+- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString
+                    parameters:(nullable id)parameters
+     constructingBodyWithBlock:(nullable void (^)(id <AFMultipartFormData> formData))block
+                       success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
+                       failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE;
+
+/**
+ Creates and runs an `NSURLSessionDataTask` with a multipart `POST` request.
+
+ @param URLString The URL string used to create the request URL.
+ @param parameters The parameters to be encoded according to the client request serializer.
+ @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.
+ @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.
+ @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.
+ @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.
+
+ @see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:
+ */
+- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString
+                             parameters:(nullable id)parameters
+              constructingBodyWithBlock:(nullable void (^)(id <AFMultipartFormData> formData))block
+                               progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgress
+                                success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
+                                failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
+
+/**
+ Creates and runs an `NSURLSessionDataTask` with a `PUT` request.
+
+ @param URLString The URL string used to create the request URL.
+ @param parameters The parameters to be encoded according to the client request serializer.
+ @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.
+ @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.
+
+ @see -dataTaskWithRequest:completionHandler:
+ */
+- (nullable NSURLSessionDataTask *)PUT:(NSString *)URLString
+                   parameters:(nullable id)parameters
+                      success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
+                      failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
+
+/**
+ Creates and runs an `NSURLSessionDataTask` with a `PATCH` request.
+
+ @param URLString The URL string used to create the request URL.
+ @param parameters The parameters to be encoded according to the client request serializer.
+ @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.
+ @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.
+
+ @see -dataTaskWithRequest:completionHandler:
+ */
+- (nullable NSURLSessionDataTask *)PATCH:(NSString *)URLString
+                     parameters:(nullable id)parameters
+                        success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
+                        failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
+
+/**
+ Creates and runs an `NSURLSessionDataTask` with a `DELETE` request.
+
+ @param URLString The URL string used to create the request URL.
+ @param parameters The parameters to be encoded according to the client request serializer.
+ @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.
+ @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.
+
+ @see -dataTaskWithRequest:completionHandler:
+ */
+- (nullable NSURLSessionDataTask *)DELETE:(NSString *)URLString
+                      parameters:(nullable id)parameters
+                         success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
+                         failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 361 - 0
Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.m

@@ -0,0 +1,361 @@
+// AFHTTPSessionManager.m
+// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import "AFHTTPSessionManager.h"
+
+#import "AFURLRequestSerialization.h"
+#import "AFURLResponseSerialization.h"
+
+#import <Availability.h>
+#import <TargetConditionals.h>
+#import <Security/Security.h>
+
+#import <netinet/in.h>
+#import <netinet6/in6.h>
+#import <arpa/inet.h>
+#import <ifaddrs.h>
+#import <netdb.h>
+
+#if TARGET_OS_IOS || TARGET_OS_TV
+#import <UIKit/UIKit.h>
+#elif TARGET_OS_WATCH
+#import <WatchKit/WatchKit.h>
+#endif
+
+@interface AFHTTPSessionManager ()
+@property (readwrite, nonatomic, strong) NSURL *baseURL;
+@end
+
+@implementation AFHTTPSessionManager
+@dynamic responseSerializer;
+
++ (instancetype)manager {
+    return [[[self class] alloc] initWithBaseURL:nil];
+}
+
+- (instancetype)init {
+    return [self initWithBaseURL:nil];
+}
+
+- (instancetype)initWithBaseURL:(NSURL *)url {
+    return [self initWithBaseURL:url sessionConfiguration:nil];
+}
+
+- (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration {
+    return [self initWithBaseURL:nil sessionConfiguration:configuration];
+}
+
+- (instancetype)initWithBaseURL:(NSURL *)url
+           sessionConfiguration:(NSURLSessionConfiguration *)configuration
+{
+    self = [super initWithSessionConfiguration:configuration];
+    if (!self) {
+        return nil;
+    }
+
+    // Ensure terminal slash for baseURL path, so that NSURL +URLWithString:relativeToURL: works as expected
+    if ([[url path] length] > 0 && ![[url absoluteString] hasSuffix:@"/"]) {
+        url = [url URLByAppendingPathComponent:@""];
+    }
+
+    self.baseURL = url;
+
+    self.requestSerializer = [AFHTTPRequestSerializer serializer];
+    self.responseSerializer = [AFJSONResponseSerializer serializer];
+
+    return self;
+}
+
+#pragma mark -
+
+- (void)setRequestSerializer:(AFHTTPRequestSerializer <AFURLRequestSerialization> *)requestSerializer {
+    NSParameterAssert(requestSerializer);
+
+    _requestSerializer = requestSerializer;
+}
+
+- (void)setResponseSerializer:(AFHTTPResponseSerializer <AFURLResponseSerialization> *)responseSerializer {
+    NSParameterAssert(responseSerializer);
+
+    [super setResponseSerializer:responseSerializer];
+}
+
+#pragma mark -
+
+- (NSURLSessionDataTask *)GET:(NSString *)URLString
+                   parameters:(id)parameters
+                      success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
+                      failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
+{
+
+    return [self GET:URLString parameters:parameters progress:nil success:success failure:failure];
+}
+
+- (NSURLSessionDataTask *)GET:(NSString *)URLString
+                   parameters:(id)parameters
+                     progress:(void (^)(NSProgress * _Nonnull))downloadProgress
+                      success:(void (^)(NSURLSessionDataTask * _Nonnull, id _Nullable))success
+                      failure:(void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure
+{
+
+    NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"GET"
+                                                        URLString:URLString
+                                                       parameters:parameters
+                                                   uploadProgress:nil
+                                                 downloadProgress:downloadProgress
+                                                          success:success
+                                                          failure:failure];
+
+    [dataTask resume];
+
+    return dataTask;
+}
+
+- (NSURLSessionDataTask *)HEAD:(NSString *)URLString
+                    parameters:(id)parameters
+                       success:(void (^)(NSURLSessionDataTask *task))success
+                       failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
+{
+    NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"HEAD" URLString:URLString parameters:parameters uploadProgress:nil downloadProgress:nil success:^(NSURLSessionDataTask *task, __unused id responseObject) {
+        if (success) {
+            success(task);
+        }
+    } failure:failure];
+
+    [dataTask resume];
+
+    return dataTask;
+}
+
+- (NSURLSessionDataTask *)POST:(NSString *)URLString
+                    parameters:(id)parameters
+                       success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
+                       failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
+{
+    return [self POST:URLString parameters:parameters progress:nil success:success failure:failure];
+}
+
+- (NSURLSessionDataTask *)POST:(NSString *)URLString
+                    parameters:(id)parameters
+                      progress:(void (^)(NSProgress * _Nonnull))uploadProgress
+                       success:(void (^)(NSURLSessionDataTask * _Nonnull, id _Nullable))success
+                       failure:(void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure
+{
+    NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"POST" URLString:URLString parameters:parameters uploadProgress:uploadProgress downloadProgress:nil success:success failure:failure];
+
+    [dataTask resume];
+
+    return dataTask;
+}
+
+- (NSURLSessionDataTask *)POST:(NSString *)URLString
+                    parameters:(nullable id)parameters
+     constructingBodyWithBlock:(nullable void (^)(id<AFMultipartFormData> _Nonnull))block
+                       success:(nullable void (^)(NSURLSessionDataTask * _Nonnull, id _Nullable))success
+                       failure:(nullable void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure
+{
+    return [self POST:URLString parameters:parameters constructingBodyWithBlock:block progress:nil success:success failure:failure];
+}
+
+- (NSURLSessionDataTask *)POST:(NSString *)URLString
+                    parameters:(id)parameters
+     constructingBodyWithBlock:(void (^)(id <AFMultipartFormData> formData))block
+                      progress:(nullable void (^)(NSProgress * _Nonnull))uploadProgress
+                       success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
+                       failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
+{
+    NSError *serializationError = nil;
+    NSMutableURLRequest *request = [self.requestSerializer multipartFormRequestWithMethod:@"POST" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters constructingBodyWithBlock:block error:&serializationError];
+    if (serializationError) {
+        if (failure) {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wgnu"
+            dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{
+                failure(nil, serializationError);
+            });
+#pragma clang diagnostic pop
+        }
+
+        return nil;
+    }
+
+    __block NSURLSessionDataTask *task = [self uploadTaskWithStreamedRequest:request progress:uploadProgress completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) {
+        if (error) {
+            if (failure) {
+                failure(task, error);
+            }
+        } else {
+            if (success) {
+                success(task, responseObject);
+            }
+        }
+    }];
+
+    [task resume];
+
+    return task;
+}
+
+- (NSURLSessionDataTask *)PUT:(NSString *)URLString
+                   parameters:(id)parameters
+                      success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
+                      failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
+{
+    NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"PUT" URLString:URLString parameters:parameters uploadProgress:nil downloadProgress:nil success:success failure:failure];
+
+    [dataTask resume];
+
+    return dataTask;
+}
+
+- (NSURLSessionDataTask *)PATCH:(NSString *)URLString
+                     parameters:(id)parameters
+                        success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
+                        failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
+{
+    NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"PATCH" URLString:URLString parameters:parameters uploadProgress:nil downloadProgress:nil success:success failure:failure];
+
+    [dataTask resume];
+
+    return dataTask;
+}
+
+- (NSURLSessionDataTask *)DELETE:(NSString *)URLString
+                      parameters:(id)parameters
+                         success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
+                         failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
+{
+    NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"DELETE" URLString:URLString parameters:parameters uploadProgress:nil downloadProgress:nil success:success failure:failure];
+
+    [dataTask resume];
+
+    return dataTask;
+}
+
+- (NSURLSessionDataTask *)dataTaskWithHTTPMethod:(NSString *)method
+                                       URLString:(NSString *)URLString
+                                      parameters:(id)parameters
+                                  uploadProgress:(nullable void (^)(NSProgress *uploadProgress)) uploadProgress
+                                downloadProgress:(nullable void (^)(NSProgress *downloadProgress)) downloadProgress
+                                         success:(void (^)(NSURLSessionDataTask *, id))success
+                                         failure:(void (^)(NSURLSessionDataTask *, NSError *))failure
+{
+    NSError *serializationError = nil;
+    NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:method URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:&serializationError];
+    if (serializationError) {
+        if (failure) {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wgnu"
+            dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{
+                failure(nil, serializationError);
+            });
+#pragma clang diagnostic pop
+        }
+
+        return nil;
+    }
+
+    __block NSURLSessionDataTask *dataTask = nil;
+    dataTask = [self dataTaskWithRequest:request
+                          uploadProgress:uploadProgress
+                        downloadProgress:downloadProgress
+                       completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) {
+        if (error) {
+            if (failure) {
+                failure(dataTask, error);
+            }
+        } else {
+            if (success) {
+                success(dataTask, responseObject);
+            }
+        }
+    }];
+
+    return dataTask;
+}
+
+#pragma mark - NSObject
+
+- (NSString *)description {
+    return [NSString stringWithFormat:@"<%@: %p, baseURL: %@, session: %@, operationQueue: %@>", NSStringFromClass([self class]), self, [self.baseURL absoluteString], self.session, self.operationQueue];
+}
+
+#pragma mark - NSSecureCoding
+
++ (BOOL)supportsSecureCoding {
+    return YES;
+}
+
+- (instancetype)initWithCoder:(NSCoder *)decoder {
+    NSURL *baseURL = [decoder decodeObjectOfClass:[NSURL class] forKey:NSStringFromSelector(@selector(baseURL))];
+    NSURLSessionConfiguration *configuration = [decoder decodeObjectOfClass:[NSURLSessionConfiguration class] forKey:@"sessionConfiguration"];
+    if (!configuration) {
+        NSString *configurationIdentifier = [decoder decodeObjectOfClass:[NSString class] forKey:@"identifier"];
+        if (configurationIdentifier) {
+#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)
+            configuration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:configurationIdentifier];
+#else
+            configuration = [NSURLSessionConfiguration backgroundSessionConfiguration:configurationIdentifier];
+#endif
+        }
+    }
+
+    self = [self initWithBaseURL:baseURL sessionConfiguration:configuration];
+    if (!self) {
+        return nil;
+    }
+
+    self.requestSerializer = [decoder decodeObjectOfClass:[AFHTTPRequestSerializer class] forKey:NSStringFromSelector(@selector(requestSerializer))];
+    self.responseSerializer = [decoder decodeObjectOfClass:[AFHTTPResponseSerializer class] forKey:NSStringFromSelector(@selector(responseSerializer))];
+    AFSecurityPolicy *decodedPolicy = [decoder decodeObjectOfClass:[AFSecurityPolicy class] forKey:NSStringFromSelector(@selector(securityPolicy))];
+    if (decodedPolicy) {
+        self.securityPolicy = decodedPolicy;
+    }
+
+    return self;
+}
+
+- (void)encodeWithCoder:(NSCoder *)coder {
+    [super encodeWithCoder:coder];
+
+    [coder encodeObject:self.baseURL forKey:NSStringFromSelector(@selector(baseURL))];
+    if ([self.session.configuration conformsToProtocol:@protocol(NSCoding)]) {
+        [coder encodeObject:self.session.configuration forKey:@"sessionConfiguration"];
+    } else {
+        [coder encodeObject:self.session.configuration.identifier forKey:@"identifier"];
+    }
+    [coder encodeObject:self.requestSerializer forKey:NSStringFromSelector(@selector(requestSerializer))];
+    [coder encodeObject:self.responseSerializer forKey:NSStringFromSelector(@selector(responseSerializer))];
+    [coder encodeObject:self.securityPolicy forKey:NSStringFromSelector(@selector(securityPolicy))];
+}
+
+#pragma mark - NSCopying
+
+- (instancetype)copyWithZone:(NSZone *)zone {
+    AFHTTPSessionManager *HTTPClient = [[[self class] allocWithZone:zone] initWithBaseURL:self.baseURL sessionConfiguration:self.session.configuration];
+
+    HTTPClient.requestSerializer = [self.requestSerializer copyWithZone:zone];
+    HTTPClient.responseSerializer = [self.responseSerializer copyWithZone:zone];
+    HTTPClient.securityPolicy = [self.securityPolicy copyWithZone:zone];
+    return HTTPClient;
+}
+
+@end

+ 206 - 0
Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.h

@@ -0,0 +1,206 @@
+// AFNetworkReachabilityManager.h
+// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import <Foundation/Foundation.h>
+
+#if !TARGET_OS_WATCH
+#import <SystemConfiguration/SystemConfiguration.h>
+
+typedef NS_ENUM(NSInteger, AFNetworkReachabilityStatus) {
+    AFNetworkReachabilityStatusUnknown          = -1,
+    AFNetworkReachabilityStatusNotReachable     = 0,
+    AFNetworkReachabilityStatusReachableViaWWAN = 1,
+    AFNetworkReachabilityStatusReachableViaWiFi = 2,
+};
+
+NS_ASSUME_NONNULL_BEGIN
+
+/**
+ `AFNetworkReachabilityManager` monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces.
+
+ 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.
+
+ See Apple's Reachability Sample Code ( https://developer.apple.com/library/ios/samplecode/reachability/ )
+
+ @warning Instances of `AFNetworkReachabilityManager` must be started with `-startMonitoring` before reachability status can be determined.
+ */
+@interface AFNetworkReachabilityManager : NSObject
+
+/**
+ The current network reachability status.
+ */
+@property (readonly, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus;
+
+/**
+ Whether or not the network is currently reachable.
+ */
+@property (readonly, nonatomic, assign, getter = isReachable) BOOL reachable;
+
+/**
+ Whether or not the network is currently reachable via WWAN.
+ */
+@property (readonly, nonatomic, assign, getter = isReachableViaWWAN) BOOL reachableViaWWAN;
+
+/**
+ Whether or not the network is currently reachable via WiFi.
+ */
+@property (readonly, nonatomic, assign, getter = isReachableViaWiFi) BOOL reachableViaWiFi;
+
+///---------------------
+/// @name Initialization
+///---------------------
+
+/**
+ Returns the shared network reachability manager.
+ */
++ (instancetype)sharedManager;
+
+/**
+ Creates and returns a network reachability manager with the default socket address.
+ 
+ @return An initialized network reachability manager, actively monitoring the default socket address.
+ */
++ (instancetype)manager;
+
+/**
+ Creates and returns a network reachability manager for the specified domain.
+
+ @param domain The domain used to evaluate network reachability.
+
+ @return An initialized network reachability manager, actively monitoring the specified domain.
+ */
++ (instancetype)managerForDomain:(NSString *)domain;
+
+/**
+ Creates and returns a network reachability manager for the socket address.
+
+ @param address The socket address (`sockaddr_in6`) used to evaluate network reachability.
+
+ @return An initialized network reachability manager, actively monitoring the specified socket address.
+ */
++ (instancetype)managerForAddress:(const void *)address;
+
+/**
+ Initializes an instance of a network reachability manager from the specified reachability object.
+
+ @param reachability The reachability object to monitor.
+
+ @return An initialized network reachability manager, actively monitoring the specified reachability.
+ */
+- (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability NS_DESIGNATED_INITIALIZER;
+
+///--------------------------------------------------
+/// @name Starting & Stopping Reachability Monitoring
+///--------------------------------------------------
+
+/**
+ Starts monitoring for changes in network reachability status.
+ */
+- (void)startMonitoring;
+
+/**
+ Stops monitoring for changes in network reachability status.
+ */
+- (void)stopMonitoring;
+
+///-------------------------------------------------
+/// @name Getting Localized Reachability Description
+///-------------------------------------------------
+
+/**
+ Returns a localized string representation of the current network reachability status.
+ */
+- (NSString *)localizedNetworkReachabilityStatusString;
+
+///---------------------------------------------------
+/// @name Setting Network Reachability Change Callback
+///---------------------------------------------------
+
+/**
+ Sets a callback to be executed when the network availability of the `baseURL` host changes.
+
+ @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`.
+ */
+- (void)setReachabilityStatusChangeBlock:(nullable void (^)(AFNetworkReachabilityStatus status))block;
+
+@end
+
+///----------------
+/// @name Constants
+///----------------
+
+/**
+ ## Network Reachability
+
+ The following constants are provided by `AFNetworkReachabilityManager` as possible network reachability statuses.
+
+ enum {
+ AFNetworkReachabilityStatusUnknown,
+ AFNetworkReachabilityStatusNotReachable,
+ AFNetworkReachabilityStatusReachableViaWWAN,
+ AFNetworkReachabilityStatusReachableViaWiFi,
+ }
+
+ `AFNetworkReachabilityStatusUnknown`
+ The `baseURL` host reachability is not known.
+
+ `AFNetworkReachabilityStatusNotReachable`
+ The `baseURL` host cannot be reached.
+
+ `AFNetworkReachabilityStatusReachableViaWWAN`
+ The `baseURL` host can be reached via a cellular connection, such as EDGE or GPRS.
+
+ `AFNetworkReachabilityStatusReachableViaWiFi`
+ The `baseURL` host can be reached via a Wi-Fi connection.
+
+ ### Keys for Notification UserInfo Dictionary
+
+ Strings that are used as keys in a `userInfo` dictionary in a network reachability status change notification.
+
+ `AFNetworkingReachabilityNotificationStatusItem`
+ A key in the userInfo dictionary in a `AFNetworkingReachabilityDidChangeNotification` notification.
+ The corresponding value is an `NSNumber` object representing the `AFNetworkReachabilityStatus` value for the current reachability status.
+ */
+
+///--------------------
+/// @name Notifications
+///--------------------
+
+/**
+ Posted when network reachability changes.
+ 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.
+
+ @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`).
+ */
+FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityDidChangeNotification;
+FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityNotificationStatusItem;
+
+///--------------------
+/// @name Functions
+///--------------------
+
+/**
+ Returns a localized string representation of an `AFNetworkReachabilityStatus` value.
+ */
+FOUNDATION_EXPORT NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status);
+
+NS_ASSUME_NONNULL_END
+#endif

+ 263 - 0
Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.m

@@ -0,0 +1,263 @@
+// AFNetworkReachabilityManager.m
+// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import "AFNetworkReachabilityManager.h"
+#if !TARGET_OS_WATCH
+
+#import <netinet/in.h>
+#import <netinet6/in6.h>
+#import <arpa/inet.h>
+#import <ifaddrs.h>
+#import <netdb.h>
+
+NSString * const AFNetworkingReachabilityDidChangeNotification = @"com.alamofire.networking.reachability.change";
+NSString * const AFNetworkingReachabilityNotificationStatusItem = @"AFNetworkingReachabilityNotificationStatusItem";
+
+typedef void (^AFNetworkReachabilityStatusBlock)(AFNetworkReachabilityStatus status);
+
+NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status) {
+    switch (status) {
+        case AFNetworkReachabilityStatusNotReachable:
+            return NSLocalizedStringFromTable(@"Not Reachable", @"AFNetworking", nil);
+        case AFNetworkReachabilityStatusReachableViaWWAN:
+            return NSLocalizedStringFromTable(@"Reachable via WWAN", @"AFNetworking", nil);
+        case AFNetworkReachabilityStatusReachableViaWiFi:
+            return NSLocalizedStringFromTable(@"Reachable via WiFi", @"AFNetworking", nil);
+        case AFNetworkReachabilityStatusUnknown:
+        default:
+            return NSLocalizedStringFromTable(@"Unknown", @"AFNetworking", nil);
+    }
+}
+
+static AFNetworkReachabilityStatus AFNetworkReachabilityStatusForFlags(SCNetworkReachabilityFlags flags) {
+    BOOL isReachable = ((flags & kSCNetworkReachabilityFlagsReachable) != 0);
+    BOOL needsConnection = ((flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0);
+    BOOL canConnectionAutomatically = (((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0) || ((flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0));
+    BOOL canConnectWithoutUserInteraction = (canConnectionAutomatically && (flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0);
+    BOOL isNetworkReachable = (isReachable && (!needsConnection || canConnectWithoutUserInteraction));
+
+    AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusUnknown;
+    if (isNetworkReachable == NO) {
+        status = AFNetworkReachabilityStatusNotReachable;
+    }
+#if	TARGET_OS_IPHONE
+    else if ((flags & kSCNetworkReachabilityFlagsIsWWAN) != 0) {
+        status = AFNetworkReachabilityStatusReachableViaWWAN;
+    }
+#endif
+    else {
+        status = AFNetworkReachabilityStatusReachableViaWiFi;
+    }
+
+    return status;
+}
+
+/**
+ * Queue a status change notification for the main thread.
+ *
+ * This is done to ensure that the notifications are received in the same order
+ * as they are sent. If notifications are sent directly, it is possible that
+ * a queued notification (for an earlier status condition) is processed after
+ * the later update, resulting in the listener being left in the wrong state.
+ */
+static void AFPostReachabilityStatusChange(SCNetworkReachabilityFlags flags, AFNetworkReachabilityStatusBlock block) {
+    AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusForFlags(flags);
+    dispatch_async(dispatch_get_main_queue(), ^{
+        if (block) {
+            block(status);
+        }
+        NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
+        NSDictionary *userInfo = @{ AFNetworkingReachabilityNotificationStatusItem: @(status) };
+        [notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:userInfo];
+    });
+}
+
+static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNetworkReachabilityFlags flags, void *info) {
+    AFPostReachabilityStatusChange(flags, (__bridge AFNetworkReachabilityStatusBlock)info);
+}
+
+
+static const void * AFNetworkReachabilityRetainCallback(const void *info) {
+    return Block_copy(info);
+}
+
+static void AFNetworkReachabilityReleaseCallback(const void *info) {
+    if (info) {
+        Block_release(info);
+    }
+}
+
+@interface AFNetworkReachabilityManager ()
+@property (readonly, nonatomic, assign) SCNetworkReachabilityRef networkReachability;
+@property (readwrite, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus;
+@property (readwrite, nonatomic, copy) AFNetworkReachabilityStatusBlock networkReachabilityStatusBlock;
+@end
+
+@implementation AFNetworkReachabilityManager
+
++ (instancetype)sharedManager {
+    static AFNetworkReachabilityManager *_sharedManager = nil;
+    static dispatch_once_t onceToken;
+    dispatch_once(&onceToken, ^{
+        _sharedManager = [self manager];
+    });
+
+    return _sharedManager;
+}
+
++ (instancetype)managerForDomain:(NSString *)domain {
+    SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, [domain UTF8String]);
+
+    AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability];
+    
+    CFRelease(reachability);
+
+    return manager;
+}
+
++ (instancetype)managerForAddress:(const void *)address {
+    SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr *)address);
+    AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability];
+
+    CFRelease(reachability);
+    
+    return manager;
+}
+
++ (instancetype)manager
+{
+#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)
+    struct sockaddr_in6 address;
+    bzero(&address, sizeof(address));
+    address.sin6_len = sizeof(address);
+    address.sin6_family = AF_INET6;
+#else
+    struct sockaddr_in address;
+    bzero(&address, sizeof(address));
+    address.sin_len = sizeof(address);
+    address.sin_family = AF_INET;
+#endif
+    return [self managerForAddress:&address];
+}
+
+- (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability {
+    self = [super init];
+    if (!self) {
+        return nil;
+    }
+
+    _networkReachability = CFRetain(reachability);
+    self.networkReachabilityStatus = AFNetworkReachabilityStatusUnknown;
+
+    return self;
+}
+
+- (instancetype)init NS_UNAVAILABLE
+{
+    return nil;
+}
+
+- (void)dealloc {
+    [self stopMonitoring];
+    
+    if (_networkReachability != NULL) {
+        CFRelease(_networkReachability);
+    }
+}
+
+#pragma mark -
+
+- (BOOL)isReachable {
+    return [self isReachableViaWWAN] || [self isReachableViaWiFi];
+}
+
+- (BOOL)isReachableViaWWAN {
+    return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWWAN;
+}
+
+- (BOOL)isReachableViaWiFi {
+    return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWiFi;
+}
+
+#pragma mark -
+
+- (void)startMonitoring {
+    [self stopMonitoring];
+
+    if (!self.networkReachability) {
+        return;
+    }
+
+    __weak __typeof(self)weakSelf = self;
+    AFNetworkReachabilityStatusBlock callback = ^(AFNetworkReachabilityStatus status) {
+        __strong __typeof(weakSelf)strongSelf = weakSelf;
+
+        strongSelf.networkReachabilityStatus = status;
+        if (strongSelf.networkReachabilityStatusBlock) {
+            strongSelf.networkReachabilityStatusBlock(status);
+        }
+
+    };
+
+    SCNetworkReachabilityContext context = {0, (__bridge void *)callback, AFNetworkReachabilityRetainCallback, AFNetworkReachabilityReleaseCallback, NULL};
+    SCNetworkReachabilitySetCallback(self.networkReachability, AFNetworkReachabilityCallback, &context);
+    SCNetworkReachabilityScheduleWithRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes);
+
+    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0),^{
+        SCNetworkReachabilityFlags flags;
+        if (SCNetworkReachabilityGetFlags(self.networkReachability, &flags)) {
+            AFPostReachabilityStatusChange(flags, callback);
+        }
+    });
+}
+
+- (void)stopMonitoring {
+    if (!self.networkReachability) {
+        return;
+    }
+
+    SCNetworkReachabilityUnscheduleFromRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes);
+}
+
+#pragma mark -
+
+- (NSString *)localizedNetworkReachabilityStatusString {
+    return AFStringFromNetworkReachabilityStatus(self.networkReachabilityStatus);
+}
+
+#pragma mark -
+
+- (void)setReachabilityStatusChangeBlock:(void (^)(AFNetworkReachabilityStatus status))block {
+    self.networkReachabilityStatusBlock = block;
+}
+
+#pragma mark - NSKeyValueObserving
+
++ (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key {
+    if ([key isEqualToString:@"reachable"] || [key isEqualToString:@"reachableViaWWAN"] || [key isEqualToString:@"reachableViaWiFi"]) {
+        return [NSSet setWithObject:@"networkReachabilityStatus"];
+    }
+
+    return [super keyPathsForValuesAffectingValueForKey:key];
+}
+
+@end
+#endif

+ 41 - 0
Pods/AFNetworking/AFNetworking/AFNetworking.h

@@ -0,0 +1,41 @@
+// AFNetworking.h
+//
+// Copyright (c) 2013 AFNetworking (http://afnetworking.com/)
+// 
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+// 
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import <Foundation/Foundation.h>
+#import <Availability.h>
+#import <TargetConditionals.h>
+
+#ifndef _AFNETWORKING_
+    #define _AFNETWORKING_
+
+    #import "AFURLRequestSerialization.h"
+    #import "AFURLResponseSerialization.h"
+    #import "AFSecurityPolicy.h"
+
+#if !TARGET_OS_WATCH
+    #import "AFNetworkReachabilityManager.h"
+#endif
+
+    #import "AFURLSessionManager.h"
+    #import "AFHTTPSessionManager.h"
+
+#endif /* _AFNETWORKING_ */

+ 154 - 0
Pods/AFNetworking/AFNetworking/AFSecurityPolicy.h

@@ -0,0 +1,154 @@
+// AFSecurityPolicy.h
+// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import <Foundation/Foundation.h>
+#import <Security/Security.h>
+
+typedef NS_ENUM(NSUInteger, AFSSLPinningMode) {
+    AFSSLPinningModeNone,
+    AFSSLPinningModePublicKey,
+    AFSSLPinningModeCertificate,
+};
+
+/**
+ `AFSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections.
+
+ 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.
+ */
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface AFSecurityPolicy : NSObject <NSSecureCoding, NSCopying>
+
+/**
+ The criteria by which server trust should be evaluated against the pinned SSL certificates. Defaults to `AFSSLPinningModeNone`.
+ */
+@property (readonly, nonatomic, assign) AFSSLPinningMode SSLPinningMode;
+
+/**
+ The certificates used to evaluate server trust according to the SSL pinning mode. 
+
+  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`.
+ 
+ Note that if pinning is enabled, `evaluateServerTrust:forDomain:` will return true if any pinned certificate matches.
+ */
+@property (nonatomic, strong, nullable) NSSet <NSData *> *pinnedCertificates;
+
+/**
+ Whether or not to trust servers with an invalid or expired SSL certificates. Defaults to `NO`.
+ */
+@property (nonatomic, assign) BOOL allowInvalidCertificates;
+
+/**
+ Whether or not to validate the domain name in the certificate's CN field. Defaults to `YES`.
+ */
+@property (nonatomic, assign) BOOL validatesDomainName;
+
+///-----------------------------------------
+/// @name Getting Certificates from the Bundle
+///-----------------------------------------
+
+/**
+ 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`.
+
+ @return The certificates included in the given bundle.
+ */
++ (NSSet <NSData *> *)certificatesInBundle:(NSBundle *)bundle;
+
+///-----------------------------------------
+/// @name Getting Specific Security Policies
+///-----------------------------------------
+
+/**
+ 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.
+
+ @return The default security policy.
+ */
++ (instancetype)defaultPolicy;
+
+///---------------------
+/// @name Initialization
+///---------------------
+
+/**
+ Creates and returns a security policy with the specified pinning mode.
+
+ @param pinningMode The SSL pinning mode.
+
+ @return A new security policy.
+ */
++ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode;
+
+/**
+ Creates and returns a security policy with the specified pinning mode.
+
+ @param pinningMode The SSL pinning mode.
+ @param pinnedCertificates The certificates to pin against.
+
+ @return A new security policy.
+ */
++ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode withPinnedCertificates:(NSSet <NSData *> *)pinnedCertificates;
+
+///------------------------------
+/// @name Evaluating Server Trust
+///------------------------------
+
+/**
+ Whether or not the specified server trust should be accepted, based on the security policy.
+
+ This method should be used when responding to an authentication challenge from a server.
+
+ @param serverTrust The X.509 certificate trust of the server.
+ @param domain The domain of serverTrust. If `nil`, the domain will not be validated.
+
+ @return Whether or not to trust the server.
+ */
+- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust
+                  forDomain:(nullable NSString *)domain;
+
+@end
+
+NS_ASSUME_NONNULL_END
+
+///----------------
+/// @name Constants
+///----------------
+
+/**
+ ## SSL Pinning Modes
+
+ The following constants are provided by `AFSSLPinningMode` as possible SSL pinning modes.
+
+ enum {
+ AFSSLPinningModeNone,
+ AFSSLPinningModePublicKey,
+ AFSSLPinningModeCertificate,
+ }
+
+ `AFSSLPinningModeNone`
+ Do not used pinned certificates to validate servers.
+
+ `AFSSLPinningModePublicKey`
+ Validate host certificates against public keys of pinned certificates.
+
+ `AFSSLPinningModeCertificate`
+ Validate host certificates against pinned certificates.
+*/

+ 353 - 0
Pods/AFNetworking/AFNetworking/AFSecurityPolicy.m

@@ -0,0 +1,353 @@
+// AFSecurityPolicy.m
+// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import "AFSecurityPolicy.h"
+
+#import <AssertMacros.h>
+
+#if !TARGET_OS_IOS && !TARGET_OS_WATCH && !TARGET_OS_TV
+static NSData * AFSecKeyGetData(SecKeyRef key) {
+    CFDataRef data = NULL;
+
+    __Require_noErr_Quiet(SecItemExport(key, kSecFormatUnknown, kSecItemPemArmour, NULL, &data), _out);
+
+    return (__bridge_transfer NSData *)data;
+
+_out:
+    if (data) {
+        CFRelease(data);
+    }
+
+    return nil;
+}
+#endif
+
+static BOOL AFSecKeyIsEqualToKey(SecKeyRef key1, SecKeyRef key2) {
+#if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV
+    return [(__bridge id)key1 isEqual:(__bridge id)key2];
+#else
+    return [AFSecKeyGetData(key1) isEqual:AFSecKeyGetData(key2)];
+#endif
+}
+
+static id AFPublicKeyForCertificate(NSData *certificate) {
+    id allowedPublicKey = nil;
+    SecCertificateRef allowedCertificate;
+    SecCertificateRef allowedCertificates[1];
+    CFArrayRef tempCertificates = nil;
+    SecPolicyRef policy = nil;
+    SecTrustRef allowedTrust = nil;
+    SecTrustResultType result;
+
+    allowedCertificate = SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificate);
+    __Require_Quiet(allowedCertificate != NULL, _out);
+
+    allowedCertificates[0] = allowedCertificate;
+    tempCertificates = CFArrayCreate(NULL, (const void **)allowedCertificates, 1, NULL);
+
+    policy = SecPolicyCreateBasicX509();
+    __Require_noErr_Quiet(SecTrustCreateWithCertificates(tempCertificates, policy, &allowedTrust), _out);
+    __Require_noErr_Quiet(SecTrustEvaluate(allowedTrust, &result), _out);
+
+    allowedPublicKey = (__bridge_transfer id)SecTrustCopyPublicKey(allowedTrust);
+
+_out:
+    if (allowedTrust) {
+        CFRelease(allowedTrust);
+    }
+
+    if (policy) {
+        CFRelease(policy);
+    }
+
+    if (tempCertificates) {
+        CFRelease(tempCertificates);
+    }
+
+    if (allowedCertificate) {
+        CFRelease(allowedCertificate);
+    }
+
+    return allowedPublicKey;
+}
+
+static BOOL AFServerTrustIsValid(SecTrustRef serverTrust) {
+    BOOL isValid = NO;
+    SecTrustResultType result;
+    __Require_noErr_Quiet(SecTrustEvaluate(serverTrust, &result), _out);
+
+    isValid = (result == kSecTrustResultUnspecified || result == kSecTrustResultProceed);
+
+_out:
+    return isValid;
+}
+
+static NSArray * AFCertificateTrustChainForServerTrust(SecTrustRef serverTrust) {
+    CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust);
+    NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount];
+
+    for (CFIndex i = 0; i < certificateCount; i++) {
+        SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i);
+        [trustChain addObject:(__bridge_transfer NSData *)SecCertificateCopyData(certificate)];
+    }
+
+    return [NSArray arrayWithArray:trustChain];
+}
+
+static NSArray * AFPublicKeyTrustChainForServerTrust(SecTrustRef serverTrust) {
+    SecPolicyRef policy = SecPolicyCreateBasicX509();
+    CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust);
+    NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount];
+    for (CFIndex i = 0; i < certificateCount; i++) {
+        SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i);
+
+        SecCertificateRef someCertificates[] = {certificate};
+        CFArrayRef certificates = CFArrayCreate(NULL, (const void **)someCertificates, 1, NULL);
+
+        SecTrustRef trust;
+        __Require_noErr_Quiet(SecTrustCreateWithCertificates(certificates, policy, &trust), _out);
+
+        SecTrustResultType result;
+        __Require_noErr_Quiet(SecTrustEvaluate(trust, &result), _out);
+
+        [trustChain addObject:(__bridge_transfer id)SecTrustCopyPublicKey(trust)];
+
+    _out:
+        if (trust) {
+            CFRelease(trust);
+        }
+
+        if (certificates) {
+            CFRelease(certificates);
+        }
+
+        continue;
+    }
+    CFRelease(policy);
+
+    return [NSArray arrayWithArray:trustChain];
+}
+
+#pragma mark -
+
+@interface AFSecurityPolicy()
+@property (readwrite, nonatomic, assign) AFSSLPinningMode SSLPinningMode;
+@property (readwrite, nonatomic, strong) NSSet *pinnedPublicKeys;
+@end
+
+@implementation AFSecurityPolicy
+
++ (NSSet *)certificatesInBundle:(NSBundle *)bundle {
+    NSArray *paths = [bundle pathsForResourcesOfType:@"cer" inDirectory:@"."];
+
+    NSMutableSet *certificates = [NSMutableSet setWithCapacity:[paths count]];
+    for (NSString *path in paths) {
+        NSData *certificateData = [NSData dataWithContentsOfFile:path];
+        [certificates addObject:certificateData];
+    }
+
+    return [NSSet setWithSet:certificates];
+}
+
++ (NSSet *)defaultPinnedCertificates {
+    static NSSet *_defaultPinnedCertificates = nil;
+    static dispatch_once_t onceToken;
+    dispatch_once(&onceToken, ^{
+        NSBundle *bundle = [NSBundle bundleForClass:[self class]];
+        _defaultPinnedCertificates = [self certificatesInBundle:bundle];
+    });
+
+    return _defaultPinnedCertificates;
+}
+
++ (instancetype)defaultPolicy {
+    AFSecurityPolicy *securityPolicy = [[self alloc] init];
+    securityPolicy.SSLPinningMode = AFSSLPinningModeNone;
+
+    return securityPolicy;
+}
+
++ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode {
+    return [self policyWithPinningMode:pinningMode withPinnedCertificates:[self defaultPinnedCertificates]];
+}
+
++ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode withPinnedCertificates:(NSSet *)pinnedCertificates {
+    AFSecurityPolicy *securityPolicy = [[self alloc] init];
+    securityPolicy.SSLPinningMode = pinningMode;
+
+    [securityPolicy setPinnedCertificates:pinnedCertificates];
+
+    return securityPolicy;
+}
+
+- (instancetype)init {
+    self = [super init];
+    if (!self) {
+        return nil;
+    }
+
+    self.validatesDomainName = YES;
+
+    return self;
+}
+
+- (void)setPinnedCertificates:(NSSet *)pinnedCertificates {
+    _pinnedCertificates = pinnedCertificates;
+
+    if (self.pinnedCertificates) {
+        NSMutableSet *mutablePinnedPublicKeys = [NSMutableSet setWithCapacity:[self.pinnedCertificates count]];
+        for (NSData *certificate in self.pinnedCertificates) {
+            id publicKey = AFPublicKeyForCertificate(certificate);
+            if (!publicKey) {
+                continue;
+            }
+            [mutablePinnedPublicKeys addObject:publicKey];
+        }
+        self.pinnedPublicKeys = [NSSet setWithSet:mutablePinnedPublicKeys];
+    } else {
+        self.pinnedPublicKeys = nil;
+    }
+}
+
+#pragma mark -
+
+- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust
+                  forDomain:(NSString *)domain
+{
+    if (domain && self.allowInvalidCertificates && self.validatesDomainName && (self.SSLPinningMode == AFSSLPinningModeNone || [self.pinnedCertificates count] == 0)) {
+        // https://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/NetworkingTopics/Articles/OverridingSSLChainValidationCorrectly.html
+        //  According to the docs, you should only trust your provided certs for evaluation.
+        //  Pinned certificates are added to the trust. Without pinned certificates,
+        //  there is nothing to evaluate against.
+        //
+        //  From Apple Docs:
+        //          "Do not implicitly trust self-signed certificates as anchors (kSecTrustOptionImplicitAnchors).
+        //           Instead, add your own (self-signed) CA certificate to the list of trusted anchors."
+        NSLog(@"In order to validate a domain name for self signed certificates, you MUST use pinning.");
+        return NO;
+    }
+
+    NSMutableArray *policies = [NSMutableArray array];
+    if (self.validatesDomainName) {
+        [policies addObject:(__bridge_transfer id)SecPolicyCreateSSL(true, (__bridge CFStringRef)domain)];
+    } else {
+        [policies addObject:(__bridge_transfer id)SecPolicyCreateBasicX509()];
+    }
+
+    SecTrustSetPolicies(serverTrust, (__bridge CFArrayRef)policies);
+
+    if (self.SSLPinningMode == AFSSLPinningModeNone) {
+        return self.allowInvalidCertificates || AFServerTrustIsValid(serverTrust);
+    } else if (!AFServerTrustIsValid(serverTrust) && !self.allowInvalidCertificates) {
+        return NO;
+    }
+
+    switch (self.SSLPinningMode) {
+        case AFSSLPinningModeNone:
+        default:
+            return NO;
+        case AFSSLPinningModeCertificate: {
+            NSMutableArray *pinnedCertificates = [NSMutableArray array];
+            for (NSData *certificateData in self.pinnedCertificates) {
+                [pinnedCertificates addObject:(__bridge_transfer id)SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificateData)];
+            }
+            SecTrustSetAnchorCertificates(serverTrust, (__bridge CFArrayRef)pinnedCertificates);
+
+            if (!AFServerTrustIsValid(serverTrust)) {
+                return NO;
+            }
+
+            // obtain the chain after being validated, which *should* contain the pinned certificate in the last position (if it's the Root CA)
+            NSArray *serverCertificates = AFCertificateTrustChainForServerTrust(serverTrust);
+            
+            for (NSData *trustChainCertificate in [serverCertificates reverseObjectEnumerator]) {
+                if ([self.pinnedCertificates containsObject:trustChainCertificate]) {
+                    return YES;
+                }
+            }
+            
+            return NO;
+        }
+        case AFSSLPinningModePublicKey: {
+            NSUInteger trustedPublicKeyCount = 0;
+            NSArray *publicKeys = AFPublicKeyTrustChainForServerTrust(serverTrust);
+
+            for (id trustChainPublicKey in publicKeys) {
+                for (id pinnedPublicKey in self.pinnedPublicKeys) {
+                    if (AFSecKeyIsEqualToKey((__bridge SecKeyRef)trustChainPublicKey, (__bridge SecKeyRef)pinnedPublicKey)) {
+                        trustedPublicKeyCount += 1;
+                    }
+                }
+            }
+            return trustedPublicKeyCount > 0;
+        }
+    }
+    
+    return NO;
+}
+
+#pragma mark - NSKeyValueObserving
+
++ (NSSet *)keyPathsForValuesAffectingPinnedPublicKeys {
+    return [NSSet setWithObject:@"pinnedCertificates"];
+}
+
+#pragma mark - NSSecureCoding
+
++ (BOOL)supportsSecureCoding {
+    return YES;
+}
+
+- (instancetype)initWithCoder:(NSCoder *)decoder {
+
+    self = [self init];
+    if (!self) {
+        return nil;
+    }
+
+    self.SSLPinningMode = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(SSLPinningMode))] unsignedIntegerValue];
+    self.allowInvalidCertificates = [decoder decodeBoolForKey:NSStringFromSelector(@selector(allowInvalidCertificates))];
+    self.validatesDomainName = [decoder decodeBoolForKey:NSStringFromSelector(@selector(validatesDomainName))];
+    self.pinnedCertificates = [decoder decodeObjectOfClass:[NSArray class] forKey:NSStringFromSelector(@selector(pinnedCertificates))];
+
+    return self;
+}
+
+- (void)encodeWithCoder:(NSCoder *)coder {
+    [coder encodeObject:[NSNumber numberWithUnsignedInteger:self.SSLPinningMode] forKey:NSStringFromSelector(@selector(SSLPinningMode))];
+    [coder encodeBool:self.allowInvalidCertificates forKey:NSStringFromSelector(@selector(allowInvalidCertificates))];
+    [coder encodeBool:self.validatesDomainName forKey:NSStringFromSelector(@selector(validatesDomainName))];
+    [coder encodeObject:self.pinnedCertificates forKey:NSStringFromSelector(@selector(pinnedCertificates))];
+}
+
+#pragma mark - NSCopying
+
+- (instancetype)copyWithZone:(NSZone *)zone {
+    AFSecurityPolicy *securityPolicy = [[[self class] allocWithZone:zone] init];
+    securityPolicy.SSLPinningMode = self.SSLPinningMode;
+    securityPolicy.allowInvalidCertificates = self.allowInvalidCertificates;
+    securityPolicy.validatesDomainName = self.validatesDomainName;
+    securityPolicy.pinnedCertificates = [self.pinnedCertificates copyWithZone:zone];
+
+    return securityPolicy;
+}
+
+@end

文件差异内容过多而无法显示
+ 479 - 0
Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.h


文件差异内容过多而无法显示
+ 1376 - 0
Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.m


+ 311 - 0
Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.h

@@ -0,0 +1,311 @@
+// AFURLResponseSerialization.h
+// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import <Foundation/Foundation.h>
+#import <CoreGraphics/CoreGraphics.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+/**
+ 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.
+
+ 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.
+ */
+@protocol AFURLResponseSerialization <NSObject, NSSecureCoding, NSCopying>
+
+/**
+ The response object decoded from the data associated with a specified response.
+
+ @param response The response to be processed.
+ @param data The response data to be decoded.
+ @param error The error that occurred while attempting to decode the response data.
+
+ @return The object decoded from the specified response data.
+ */
+- (nullable id)responseObjectForResponse:(nullable NSURLResponse *)response
+                           data:(nullable NSData *)data
+                          error:(NSError * _Nullable __autoreleasing *)error NS_SWIFT_NOTHROW;
+
+@end
+
+#pragma mark -
+
+/**
+ `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.
+
+ Any request or response serializer dealing with HTTP is encouraged to subclass `AFHTTPResponseSerializer` in order to ensure consistent default behavior.
+ */
+@interface AFHTTPResponseSerializer : NSObject <AFURLResponseSerialization>
+
+- (instancetype)init;
+
+/**
+ The string encoding used to serialize data received from the server, when no string encoding is specified by the response. `NSUTF8StringEncoding` by default.
+ */
+@property (nonatomic, assign) NSStringEncoding stringEncoding;
+
+/**
+ Creates and returns a serializer with default configuration.
+ */
++ (instancetype)serializer;
+
+///-----------------------------------------
+/// @name Configuring Response Serialization
+///-----------------------------------------
+
+/**
+ 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.
+
+ See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
+ */
+@property (nonatomic, copy, nullable) NSIndexSet *acceptableStatusCodes;
+
+/**
+ 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.
+ */
+@property (nonatomic, copy, nullable) NSSet <NSString *> *acceptableContentTypes;
+
+/**
+ Validates the specified response and data.
+
+ In its base implementation, this method checks for an acceptable status code and content type. Subclasses may wish to add other domain-specific checks.
+
+ @param response The response to be validated.
+ @param data The data associated with the response.
+ @param error The error that occurred while attempting to validate the response.
+
+ @return `YES` if the response is valid, otherwise `NO`.
+ */
+- (BOOL)validateResponse:(nullable NSHTTPURLResponse *)response
+                    data:(nullable NSData *)data
+                   error:(NSError * _Nullable __autoreleasing *)error;
+
+@end
+
+#pragma mark -
+
+
+/**
+ `AFJSONResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes JSON responses.
+
+ By default, `AFJSONResponseSerializer` accepts the following MIME types, which includes the official standard, `application/json`, as well as other commonly-used types:
+
+ - `application/json`
+ - `text/json`
+ - `text/javascript`
+ */
+@interface AFJSONResponseSerializer : AFHTTPResponseSerializer
+
+- (instancetype)init;
+
+/**
+ Options for reading the response JSON data and creating the Foundation objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONReadingOptions". `0` by default.
+ */
+@property (nonatomic, assign) NSJSONReadingOptions readingOptions;
+
+/**
+ Whether to remove keys with `NSNull` values from response JSON. Defaults to `NO`.
+ */
+@property (nonatomic, assign) BOOL removesKeysWithNullValues;
+
+/**
+ Creates and returns a JSON serializer with specified reading and writing options.
+
+ @param readingOptions The specified JSON reading options.
+ */
++ (instancetype)serializerWithReadingOptions:(NSJSONReadingOptions)readingOptions;
+
+@end
+
+#pragma mark -
+
+/**
+ `AFXMLParserResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLParser` objects.
+
+ By default, `AFXMLParserResponseSerializer` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types:
+
+ - `application/xml`
+ - `text/xml`
+ */
+@interface AFXMLParserResponseSerializer : AFHTTPResponseSerializer
+
+@end
+
+#pragma mark -
+
+#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
+
+/**
+ `AFXMLDocumentResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLDocument` objects.
+
+ By default, `AFXMLDocumentResponseSerializer` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types:
+
+ - `application/xml`
+ - `text/xml`
+ */
+@interface AFXMLDocumentResponseSerializer : AFHTTPResponseSerializer
+
+- (instancetype)init;
+
+/**
+ Input and output options specifically intended for `NSXMLDocument` objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONReadingOptions". `0` by default.
+ */
+@property (nonatomic, assign) NSUInteger options;
+
+/**
+ Creates and returns an XML document serializer with the specified options.
+
+ @param mask The XML document options.
+ */
++ (instancetype)serializerWithXMLDocumentOptions:(NSUInteger)mask;
+
+@end
+
+#endif
+
+#pragma mark -
+
+/**
+ `AFPropertyListResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLDocument` objects.
+
+ By default, `AFPropertyListResponseSerializer` accepts the following MIME types:
+
+ - `application/x-plist`
+ */
+@interface AFPropertyListResponseSerializer : AFHTTPResponseSerializer
+
+- (instancetype)init;
+
+/**
+ The property list format. Possible values are described in "NSPropertyListFormat".
+ */
+@property (nonatomic, assign) NSPropertyListFormat format;
+
+/**
+ The property list reading options. Possible values are described in "NSPropertyListMutabilityOptions."
+ */
+@property (nonatomic, assign) NSPropertyListReadOptions readOptions;
+
+/**
+ Creates and returns a property list serializer with a specified format, read options, and write options.
+
+ @param format The property list format.
+ @param readOptions The property list reading options.
+ */
++ (instancetype)serializerWithFormat:(NSPropertyListFormat)format
+                         readOptions:(NSPropertyListReadOptions)readOptions;
+
+@end
+
+#pragma mark -
+
+/**
+ `AFImageResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes image responses.
+
+ By default, `AFImageResponseSerializer` accepts the following MIME types, which correspond to the image formats supported by UIImage or NSImage:
+
+ - `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`
+ */
+@interface AFImageResponseSerializer : AFHTTPResponseSerializer
+
+#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH
+/**
+ 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.
+ */
+@property (nonatomic, assign) CGFloat imageScale;
+
+/**
+ 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.
+ */
+@property (nonatomic, assign) BOOL automaticallyInflatesResponseImage;
+#endif
+
+@end
+
+#pragma mark -
+
+/**
+ `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.
+ */
+@interface AFCompoundResponseSerializer : AFHTTPResponseSerializer
+
+/**
+ The component response serializers.
+ */
+@property (readonly, nonatomic, copy) NSArray <id<AFURLResponseSerialization>> *responseSerializers;
+
+/**
+ Creates and returns a compound serializer comprised of the specified response serializers.
+
+ @warning Each response serializer specified must be a subclass of `AFHTTPResponseSerializer`, and response to `-validateResponse:data:error:`.
+ */
++ (instancetype)compoundSerializerWithResponseSerializers:(NSArray <id<AFURLResponseSerialization>> *)responseSerializers;
+
+@end
+
+///----------------
+/// @name Constants
+///----------------
+
+/**
+ ## Error Domains
+
+ The following error domain is predefined.
+
+ - `NSString * const AFURLResponseSerializationErrorDomain`
+
+ ### Constants
+
+ `AFURLResponseSerializationErrorDomain`
+ AFURLResponseSerializer errors. Error codes for `AFURLResponseSerializationErrorDomain` correspond to codes in `NSURLErrorDomain`.
+ */
+FOUNDATION_EXPORT NSString * const AFURLResponseSerializationErrorDomain;
+
+/**
+ ## User info dictionary keys
+
+ These keys may exist in the user info dictionary, in addition to those defined for NSError.
+
+ - `NSString * const AFNetworkingOperationFailingURLResponseErrorKey`
+ - `NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey`
+
+ ### Constants
+
+ `AFNetworkingOperationFailingURLResponseErrorKey`
+ The corresponding value is an `NSURLResponse` containing the response of the operation associated with an error. This key is only present in the `AFURLResponseSerializationErrorDomain`.
+
+ `AFNetworkingOperationFailingURLResponseDataErrorKey`
+ 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`.
+ */
+FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLResponseErrorKey;
+
+FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey;
+
+NS_ASSUME_NONNULL_END

+ 805 - 0
Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.m

@@ -0,0 +1,805 @@
+// AFURLResponseSerialization.m
+// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import "AFURLResponseSerialization.h"
+
+#import <TargetConditionals.h>
+
+#if TARGET_OS_IOS
+#import <UIKit/UIKit.h>
+#elif TARGET_OS_WATCH
+#import <WatchKit/WatchKit.h>
+#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
+#import <Cocoa/Cocoa.h>
+#endif
+
+NSString * const AFURLResponseSerializationErrorDomain = @"com.alamofire.error.serialization.response";
+NSString * const AFNetworkingOperationFailingURLResponseErrorKey = @"com.alamofire.serialization.response.error.response";
+NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey = @"com.alamofire.serialization.response.error.data";
+
+static NSError * AFErrorWithUnderlyingError(NSError *error, NSError *underlyingError) {
+    if (!error) {
+        return underlyingError;
+    }
+
+    if (!underlyingError || error.userInfo[NSUnderlyingErrorKey]) {
+        return error;
+    }
+
+    NSMutableDictionary *mutableUserInfo = [error.userInfo mutableCopy];
+    mutableUserInfo[NSUnderlyingErrorKey] = underlyingError;
+
+    return [[NSError alloc] initWithDomain:error.domain code:error.code userInfo:mutableUserInfo];
+}
+
+static BOOL AFErrorOrUnderlyingErrorHasCodeInDomain(NSError *error, NSInteger code, NSString *domain) {
+    if ([error.domain isEqualToString:domain] && error.code == code) {
+        return YES;
+    } else if (error.userInfo[NSUnderlyingErrorKey]) {
+        return AFErrorOrUnderlyingErrorHasCodeInDomain(error.userInfo[NSUnderlyingErrorKey], code, domain);
+    }
+
+    return NO;
+}
+
+static id AFJSONObjectByRemovingKeysWithNullValues(id JSONObject, NSJSONReadingOptions readingOptions) {
+    if ([JSONObject isKindOfClass:[NSArray class]]) {
+        NSMutableArray *mutableArray = [NSMutableArray arrayWithCapacity:[(NSArray *)JSONObject count]];
+        for (id value in (NSArray *)JSONObject) {
+            [mutableArray addObject:AFJSONObjectByRemovingKeysWithNullValues(value, readingOptions)];
+        }
+
+        return (readingOptions & NSJSONReadingMutableContainers) ? mutableArray : [NSArray arrayWithArray:mutableArray];
+    } else if ([JSONObject isKindOfClass:[NSDictionary class]]) {
+        NSMutableDictionary *mutableDictionary = [NSMutableDictionary dictionaryWithDictionary:JSONObject];
+        for (id <NSCopying> key in [(NSDictionary *)JSONObject allKeys]) {
+            id value = (NSDictionary *)JSONObject[key];
+            if (!value || [value isEqual:[NSNull null]]) {
+                [mutableDictionary removeObjectForKey:key];
+            } else if ([value isKindOfClass:[NSArray class]] || [value isKindOfClass:[NSDictionary class]]) {
+                mutableDictionary[key] = AFJSONObjectByRemovingKeysWithNullValues(value, readingOptions);
+            }
+        }
+
+        return (readingOptions & NSJSONReadingMutableContainers) ? mutableDictionary : [NSDictionary dictionaryWithDictionary:mutableDictionary];
+    }
+
+    return JSONObject;
+}
+
+@implementation AFHTTPResponseSerializer
+
++ (instancetype)serializer {
+    return [[self alloc] init];
+}
+
+- (instancetype)init {
+    self = [super init];
+    if (!self) {
+        return nil;
+    }
+
+    self.stringEncoding = NSUTF8StringEncoding;
+
+    self.acceptableStatusCodes = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(200, 100)];
+    self.acceptableContentTypes = nil;
+
+    return self;
+}
+
+#pragma mark -
+
+- (BOOL)validateResponse:(NSHTTPURLResponse *)response
+                    data:(NSData *)data
+                   error:(NSError * __autoreleasing *)error
+{
+    BOOL responseIsValid = YES;
+    NSError *validationError = nil;
+
+    if (response && [response isKindOfClass:[NSHTTPURLResponse class]]) {
+        if (self.acceptableContentTypes && ![self.acceptableContentTypes containsObject:[response MIMEType]] &&
+            !([response MIMEType] == nil && [data length] == 0)) {
+
+            if ([data length] > 0 && [response URL]) {
+                NSMutableDictionary *mutableUserInfo = [@{
+                                                          NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: unacceptable content-type: %@", @"AFNetworking", nil), [response MIMEType]],
+                                                          NSURLErrorFailingURLErrorKey:[response URL],
+                                                          AFNetworkingOperationFailingURLResponseErrorKey: response,
+                                                        } mutableCopy];
+                if (data) {
+                    mutableUserInfo[AFNetworkingOperationFailingURLResponseDataErrorKey] = data;
+                }
+
+                validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:mutableUserInfo], validationError);
+            }
+
+            responseIsValid = NO;
+        }
+
+        if (self.acceptableStatusCodes && ![self.acceptableStatusCodes containsIndex:(NSUInteger)response.statusCode] && [response URL]) {
+            NSMutableDictionary *mutableUserInfo = [@{
+                                               NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: %@ (%ld)", @"AFNetworking", nil), [NSHTTPURLResponse localizedStringForStatusCode:response.statusCode], (long)response.statusCode],
+                                               NSURLErrorFailingURLErrorKey:[response URL],
+                                               AFNetworkingOperationFailingURLResponseErrorKey: response,
+                                       } mutableCopy];
+
+            if (data) {
+                mutableUserInfo[AFNetworkingOperationFailingURLResponseDataErrorKey] = data;
+            }
+
+            validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorBadServerResponse userInfo:mutableUserInfo], validationError);
+
+            responseIsValid = NO;
+        }
+    }
+
+    if (error && !responseIsValid) {
+        *error = validationError;
+    }
+
+    return responseIsValid;
+}
+
+#pragma mark - AFURLResponseSerialization
+
+- (id)responseObjectForResponse:(NSURLResponse *)response
+                           data:(NSData *)data
+                          error:(NSError *__autoreleasing *)error
+{
+    [self validateResponse:(NSHTTPURLResponse *)response data:data error:error];
+
+    return data;
+}
+
+#pragma mark - NSSecureCoding
+
++ (BOOL)supportsSecureCoding {
+    return YES;
+}
+
+- (instancetype)initWithCoder:(NSCoder *)decoder {
+    self = [self init];
+    if (!self) {
+        return nil;
+    }
+
+    self.acceptableStatusCodes = [decoder decodeObjectOfClass:[NSIndexSet class] forKey:NSStringFromSelector(@selector(acceptableStatusCodes))];
+    self.acceptableContentTypes = [decoder decodeObjectOfClass:[NSIndexSet class] forKey:NSStringFromSelector(@selector(acceptableContentTypes))];
+
+    return self;
+}
+
+- (void)encodeWithCoder:(NSCoder *)coder {
+    [coder encodeObject:self.acceptableStatusCodes forKey:NSStringFromSelector(@selector(acceptableStatusCodes))];
+    [coder encodeObject:self.acceptableContentTypes forKey:NSStringFromSelector(@selector(acceptableContentTypes))];
+}
+
+#pragma mark - NSCopying
+
+- (instancetype)copyWithZone:(NSZone *)zone {
+    AFHTTPResponseSerializer *serializer = [[[self class] allocWithZone:zone] init];
+    serializer.acceptableStatusCodes = [self.acceptableStatusCodes copyWithZone:zone];
+    serializer.acceptableContentTypes = [self.acceptableContentTypes copyWithZone:zone];
+
+    return serializer;
+}
+
+@end
+
+#pragma mark -
+
+@implementation AFJSONResponseSerializer
+
++ (instancetype)serializer {
+    return [self serializerWithReadingOptions:(NSJSONReadingOptions)0];
+}
+
++ (instancetype)serializerWithReadingOptions:(NSJSONReadingOptions)readingOptions {
+    AFJSONResponseSerializer *serializer = [[self alloc] init];
+    serializer.readingOptions = readingOptions;
+
+    return serializer;
+}
+
+- (instancetype)init {
+    self = [super init];
+    if (!self) {
+        return nil;
+    }
+
+    self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
+
+    return self;
+}
+
+#pragma mark - AFURLResponseSerialization
+
+- (id)responseObjectForResponse:(NSURLResponse *)response
+                           data:(NSData *)data
+                          error:(NSError *__autoreleasing *)error
+{
+    if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
+        if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) {
+            return nil;
+        }
+    }
+
+    id responseObject = nil;
+    NSError *serializationError = nil;
+    // 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.
+    // See https://github.com/rails/rails/issues/1742
+    BOOL isSpace = [data isEqualToData:[NSData dataWithBytes:" " length:1]];
+    if (data.length > 0 && !isSpace) {
+        responseObject = [NSJSONSerialization JSONObjectWithData:data options:self.readingOptions error:&serializationError];
+    } else {
+        return nil;
+    }
+
+    if (self.removesKeysWithNullValues && responseObject) {
+        responseObject = AFJSONObjectByRemovingKeysWithNullValues(responseObject, self.readingOptions);
+    }
+
+    if (error) {
+        *error = AFErrorWithUnderlyingError(serializationError, *error);
+    }
+
+    return responseObject;
+}
+
+#pragma mark - NSSecureCoding
+
+- (instancetype)initWithCoder:(NSCoder *)decoder {
+    self = [super initWithCoder:decoder];
+    if (!self) {
+        return nil;
+    }
+
+    self.readingOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(readingOptions))] unsignedIntegerValue];
+    self.removesKeysWithNullValues = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(removesKeysWithNullValues))] boolValue];
+
+    return self;
+}
+
+- (void)encodeWithCoder:(NSCoder *)coder {
+    [super encodeWithCoder:coder];
+
+    [coder encodeObject:@(self.readingOptions) forKey:NSStringFromSelector(@selector(readingOptions))];
+    [coder encodeObject:@(self.removesKeysWithNullValues) forKey:NSStringFromSelector(@selector(removesKeysWithNullValues))];
+}
+
+#pragma mark - NSCopying
+
+- (instancetype)copyWithZone:(NSZone *)zone {
+    AFJSONResponseSerializer *serializer = [[[self class] allocWithZone:zone] init];
+    serializer.readingOptions = self.readingOptions;
+    serializer.removesKeysWithNullValues = self.removesKeysWithNullValues;
+
+    return serializer;
+}
+
+@end
+
+#pragma mark -
+
+@implementation AFXMLParserResponseSerializer
+
++ (instancetype)serializer {
+    AFXMLParserResponseSerializer *serializer = [[self alloc] init];
+
+    return serializer;
+}
+
+- (instancetype)init {
+    self = [super init];
+    if (!self) {
+        return nil;
+    }
+
+    self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/xml", @"text/xml", nil];
+
+    return self;
+}
+
+#pragma mark - AFURLResponseSerialization
+
+- (id)responseObjectForResponse:(NSHTTPURLResponse *)response
+                           data:(NSData *)data
+                          error:(NSError *__autoreleasing *)error
+{
+    if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
+        if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) {
+            return nil;
+        }
+    }
+
+    return [[NSXMLParser alloc] initWithData:data];
+}
+
+@end
+
+#pragma mark -
+
+#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
+
+@implementation AFXMLDocumentResponseSerializer
+
++ (instancetype)serializer {
+    return [self serializerWithXMLDocumentOptions:0];
+}
+
++ (instancetype)serializerWithXMLDocumentOptions:(NSUInteger)mask {
+    AFXMLDocumentResponseSerializer *serializer = [[self alloc] init];
+    serializer.options = mask;
+
+    return serializer;
+}
+
+- (instancetype)init {
+    self = [super init];
+    if (!self) {
+        return nil;
+    }
+
+    self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/xml", @"text/xml", nil];
+
+    return self;
+}
+
+#pragma mark - AFURLResponseSerialization
+
+- (id)responseObjectForResponse:(NSURLResponse *)response
+                           data:(NSData *)data
+                          error:(NSError *__autoreleasing *)error
+{
+    if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
+        if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) {
+            return nil;
+        }
+    }
+
+    NSError *serializationError = nil;
+    NSXMLDocument *document = [[NSXMLDocument alloc] initWithData:data options:self.options error:&serializationError];
+
+    if (error) {
+        *error = AFErrorWithUnderlyingError(serializationError, *error);
+    }
+
+    return document;
+}
+
+#pragma mark - NSSecureCoding
+
+- (instancetype)initWithCoder:(NSCoder *)decoder {
+    self = [super initWithCoder:decoder];
+    if (!self) {
+        return nil;
+    }
+
+    self.options = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(options))] unsignedIntegerValue];
+
+    return self;
+}
+
+- (void)encodeWithCoder:(NSCoder *)coder {
+    [super encodeWithCoder:coder];
+
+    [coder encodeObject:@(self.options) forKey:NSStringFromSelector(@selector(options))];
+}
+
+#pragma mark - NSCopying
+
+- (instancetype)copyWithZone:(NSZone *)zone {
+    AFXMLDocumentResponseSerializer *serializer = [[[self class] allocWithZone:zone] init];
+    serializer.options = self.options;
+
+    return serializer;
+}
+
+@end
+
+#endif
+
+#pragma mark -
+
+@implementation AFPropertyListResponseSerializer
+
++ (instancetype)serializer {
+    return [self serializerWithFormat:NSPropertyListXMLFormat_v1_0 readOptions:0];
+}
+
++ (instancetype)serializerWithFormat:(NSPropertyListFormat)format
+                         readOptions:(NSPropertyListReadOptions)readOptions
+{
+    AFPropertyListResponseSerializer *serializer = [[self alloc] init];
+    serializer.format = format;
+    serializer.readOptions = readOptions;
+
+    return serializer;
+}
+
+- (instancetype)init {
+    self = [super init];
+    if (!self) {
+        return nil;
+    }
+
+    self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/x-plist", nil];
+
+    return self;
+}
+
+#pragma mark - AFURLResponseSerialization
+
+- (id)responseObjectForResponse:(NSURLResponse *)response
+                           data:(NSData *)data
+                          error:(NSError *__autoreleasing *)error
+{
+    if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
+        if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) {
+            return nil;
+        }
+    }
+
+    id responseObject;
+    NSError *serializationError = nil;
+
+    if (data) {
+        responseObject = [NSPropertyListSerialization propertyListWithData:data options:self.readOptions format:NULL error:&serializationError];
+    }
+
+    if (error) {
+        *error = AFErrorWithUnderlyingError(serializationError, *error);
+    }
+
+    return responseObject;
+}
+
+#pragma mark - NSSecureCoding
+
+- (instancetype)initWithCoder:(NSCoder *)decoder {
+    self = [super initWithCoder:decoder];
+    if (!self) {
+        return nil;
+    }
+
+    self.format = (NSPropertyListFormat)[[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(format))] unsignedIntegerValue];
+    self.readOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(readOptions))] unsignedIntegerValue];
+
+    return self;
+}
+
+- (void)encodeWithCoder:(NSCoder *)coder {
+    [super encodeWithCoder:coder];
+
+    [coder encodeObject:@(self.format) forKey:NSStringFromSelector(@selector(format))];
+    [coder encodeObject:@(self.readOptions) forKey:NSStringFromSelector(@selector(readOptions))];
+}
+
+#pragma mark - NSCopying
+
+- (instancetype)copyWithZone:(NSZone *)zone {
+    AFPropertyListResponseSerializer *serializer = [[[self class] allocWithZone:zone] init];
+    serializer.format = self.format;
+    serializer.readOptions = self.readOptions;
+
+    return serializer;
+}
+
+@end
+
+#pragma mark -
+
+#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH
+#import <CoreGraphics/CoreGraphics.h>
+#import <UIKit/UIKit.h>
+
+@interface UIImage (AFNetworkingSafeImageLoading)
++ (UIImage *)af_safeImageWithData:(NSData *)data;
+@end
+
+static NSLock* imageLock = nil;
+
+@implementation UIImage (AFNetworkingSafeImageLoading)
+
++ (UIImage *)af_safeImageWithData:(NSData *)data {
+    UIImage* image = nil;
+    static dispatch_once_t onceToken;
+    dispatch_once(&onceToken, ^{
+        imageLock = [[NSLock alloc] init];
+    });
+    
+    [imageLock lock];
+    image = [UIImage imageWithData:data];
+    [imageLock unlock];
+    return image;
+}
+
+@end
+
+static UIImage * AFImageWithDataAtScale(NSData *data, CGFloat scale) {
+    UIImage *image = [UIImage af_safeImageWithData:data];
+    if (image.images) {
+        return image;
+    }
+    
+    return [[UIImage alloc] initWithCGImage:[image CGImage] scale:scale orientation:image.imageOrientation];
+}
+
+static UIImage * AFInflatedImageFromResponseWithDataAtScale(NSHTTPURLResponse *response, NSData *data, CGFloat scale) {
+    if (!data || [data length] == 0) {
+        return nil;
+    }
+
+    CGImageRef imageRef = NULL;
+    CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData((__bridge CFDataRef)data);
+
+    if ([response.MIMEType isEqualToString:@"image/png"]) {
+        imageRef = CGImageCreateWithPNGDataProvider(dataProvider,  NULL, true, kCGRenderingIntentDefault);
+    } else if ([response.MIMEType isEqualToString:@"image/jpeg"]) {
+        imageRef = CGImageCreateWithJPEGDataProvider(dataProvider, NULL, true, kCGRenderingIntentDefault);
+
+        if (imageRef) {
+            CGColorSpaceRef imageColorSpace = CGImageGetColorSpace(imageRef);
+            CGColorSpaceModel imageColorSpaceModel = CGColorSpaceGetModel(imageColorSpace);
+
+            // CGImageCreateWithJPEGDataProvider does not properly handle CMKY, so fall back to AFImageWithDataAtScale
+            if (imageColorSpaceModel == kCGColorSpaceModelCMYK) {
+                CGImageRelease(imageRef);
+                imageRef = NULL;
+            }
+        }
+    }
+
+    CGDataProviderRelease(dataProvider);
+
+    UIImage *image = AFImageWithDataAtScale(data, scale);
+    if (!imageRef) {
+        if (image.images || !image) {
+            return image;
+        }
+
+        imageRef = CGImageCreateCopy([image CGImage]);
+        if (!imageRef) {
+            return nil;
+        }
+    }
+
+    size_t width = CGImageGetWidth(imageRef);
+    size_t height = CGImageGetHeight(imageRef);
+    size_t bitsPerComponent = CGImageGetBitsPerComponent(imageRef);
+
+    if (width * height > 1024 * 1024 || bitsPerComponent > 8) {
+        CGImageRelease(imageRef);
+
+        return image;
+    }
+
+    // CGImageGetBytesPerRow() calculates incorrectly in iOS 5.0, so defer to CGBitmapContextCreate
+    size_t bytesPerRow = 0;
+    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
+    CGColorSpaceModel colorSpaceModel = CGColorSpaceGetModel(colorSpace);
+    CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef);
+
+    if (colorSpaceModel == kCGColorSpaceModelRGB) {
+        uint32_t alpha = (bitmapInfo & kCGBitmapAlphaInfoMask);
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wassign-enum"
+        if (alpha == kCGImageAlphaNone) {
+            bitmapInfo &= ~kCGBitmapAlphaInfoMask;
+            bitmapInfo |= kCGImageAlphaNoneSkipFirst;
+        } else if (!(alpha == kCGImageAlphaNoneSkipFirst || alpha == kCGImageAlphaNoneSkipLast)) {
+            bitmapInfo &= ~kCGBitmapAlphaInfoMask;
+            bitmapInfo |= kCGImageAlphaPremultipliedFirst;
+        }
+#pragma clang diagnostic pop
+    }
+
+    CGContextRef context = CGBitmapContextCreate(NULL, width, height, bitsPerComponent, bytesPerRow, colorSpace, bitmapInfo);
+
+    CGColorSpaceRelease(colorSpace);
+
+    if (!context) {
+        CGImageRelease(imageRef);
+
+        return image;
+    }
+
+    CGContextDrawImage(context, CGRectMake(0.0f, 0.0f, width, height), imageRef);
+    CGImageRef inflatedImageRef = CGBitmapContextCreateImage(context);
+
+    CGContextRelease(context);
+
+    UIImage *inflatedImage = [[UIImage alloc] initWithCGImage:inflatedImageRef scale:scale orientation:image.imageOrientation];
+
+    CGImageRelease(inflatedImageRef);
+    CGImageRelease(imageRef);
+
+    return inflatedImage;
+}
+#endif
+
+
+@implementation AFImageResponseSerializer
+
+- (instancetype)init {
+    self = [super init];
+    if (!self) {
+        return nil;
+    }
+
+    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];
+
+#if TARGET_OS_IOS || TARGET_OS_TV
+    self.imageScale = [[UIScreen mainScreen] scale];
+    self.automaticallyInflatesResponseImage = YES;
+#elif TARGET_OS_WATCH
+    self.imageScale = [[WKInterfaceDevice currentDevice] screenScale];
+    self.automaticallyInflatesResponseImage = YES;
+#endif
+
+    return self;
+}
+
+#pragma mark - AFURLResponseSerializer
+
+- (id)responseObjectForResponse:(NSURLResponse *)response
+                           data:(NSData *)data
+                          error:(NSError *__autoreleasing *)error
+{
+    if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
+        if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) {
+            return nil;
+        }
+    }
+
+#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH
+    if (self.automaticallyInflatesResponseImage) {
+        return AFInflatedImageFromResponseWithDataAtScale((NSHTTPURLResponse *)response, data, self.imageScale);
+    } else {
+        return AFImageWithDataAtScale(data, self.imageScale);
+    }
+#else
+    // Ensure that the image is set to it's correct pixel width and height
+    NSBitmapImageRep *bitimage = [[NSBitmapImageRep alloc] initWithData:data];
+    NSImage *image = [[NSImage alloc] initWithSize:NSMakeSize([bitimage pixelsWide], [bitimage pixelsHigh])];
+    [image addRepresentation:bitimage];
+
+    return image;
+#endif
+
+    return nil;
+}
+
+#pragma mark - NSSecureCoding
+
+- (instancetype)initWithCoder:(NSCoder *)decoder {
+    self = [super initWithCoder:decoder];
+    if (!self) {
+        return nil;
+    }
+
+#if TARGET_OS_IOS  || TARGET_OS_TV || TARGET_OS_WATCH
+    NSNumber *imageScale = [decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(imageScale))];
+#if CGFLOAT_IS_DOUBLE
+    self.imageScale = [imageScale doubleValue];
+#else
+    self.imageScale = [imageScale floatValue];
+#endif
+
+    self.automaticallyInflatesResponseImage = [decoder decodeBoolForKey:NSStringFromSelector(@selector(automaticallyInflatesResponseImage))];
+#endif
+
+    return self;
+}
+
+- (void)encodeWithCoder:(NSCoder *)coder {
+    [super encodeWithCoder:coder];
+
+#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH
+    [coder encodeObject:@(self.imageScale) forKey:NSStringFromSelector(@selector(imageScale))];
+    [coder encodeBool:self.automaticallyInflatesResponseImage forKey:NSStringFromSelector(@selector(automaticallyInflatesResponseImage))];
+#endif
+}
+
+#pragma mark - NSCopying
+
+- (instancetype)copyWithZone:(NSZone *)zone {
+    AFImageResponseSerializer *serializer = [[[self class] allocWithZone:zone] init];
+
+#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH
+    serializer.imageScale = self.imageScale;
+    serializer.automaticallyInflatesResponseImage = self.automaticallyInflatesResponseImage;
+#endif
+
+    return serializer;
+}
+
+@end
+
+#pragma mark -
+
+@interface AFCompoundResponseSerializer ()
+@property (readwrite, nonatomic, copy) NSArray *responseSerializers;
+@end
+
+@implementation AFCompoundResponseSerializer
+
++ (instancetype)compoundSerializerWithResponseSerializers:(NSArray *)responseSerializers {
+    AFCompoundResponseSerializer *serializer = [[self alloc] init];
+    serializer.responseSerializers = responseSerializers;
+
+    return serializer;
+}
+
+#pragma mark - AFURLResponseSerialization
+
+- (id)responseObjectForResponse:(NSURLResponse *)response
+                           data:(NSData *)data
+                          error:(NSError *__autoreleasing *)error
+{
+    for (id <AFURLResponseSerialization> serializer in self.responseSerializers) {
+        if (![serializer isKindOfClass:[AFHTTPResponseSerializer class]]) {
+            continue;
+        }
+
+        NSError *serializerError = nil;
+        id responseObject = [serializer responseObjectForResponse:response data:data error:&serializerError];
+        if (responseObject) {
+            if (error) {
+                *error = AFErrorWithUnderlyingError(serializerError, *error);
+            }
+
+            return responseObject;
+        }
+    }
+
+    return [super responseObjectForResponse:response data:data error:error];
+}
+
+#pragma mark - NSSecureCoding
+
+- (instancetype)initWithCoder:(NSCoder *)decoder {
+    self = [super initWithCoder:decoder];
+    if (!self) {
+        return nil;
+    }
+
+    self.responseSerializers = [decoder decodeObjectOfClass:[NSArray class] forKey:NSStringFromSelector(@selector(responseSerializers))];
+
+    return self;
+}
+
+- (void)encodeWithCoder:(NSCoder *)coder {
+    [super encodeWithCoder:coder];
+
+    [coder encodeObject:self.responseSerializers forKey:NSStringFromSelector(@selector(responseSerializers))];
+}
+
+#pragma mark - NSCopying
+
+- (instancetype)copyWithZone:(NSZone *)zone {
+    AFCompoundResponseSerializer *serializer = [[[self class] allocWithZone:zone] init];
+    serializer.responseSerializers = self.responseSerializers;
+
+    return serializer;
+}
+
+@end

文件差异内容过多而无法显示
+ 500 - 0
Pods/AFNetworking/AFNetworking/AFURLSessionManager.h


文件差异内容过多而无法显示
+ 1244 - 0
Pods/AFNetworking/AFNetworking/AFURLSessionManager.m


+ 19 - 0
Pods/AFNetworking/LICENSE

@@ -0,0 +1,19 @@
+Copyright (c) 2011–2016 Alamofire Software Foundation (http://alamofire.org/)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.

+ 320 - 0
Pods/AFNetworking/README.md

@@ -0,0 +1,320 @@
+<p align="center" >
+  <img src="https://raw.github.com/AFNetworking/AFNetworking/assets/afnetworking-logo.png" alt="AFNetworking" title="AFNetworking">
+</p>
+
+[![Build Status](https://travis-ci.org/AFNetworking/AFNetworking.svg)](https://travis-ci.org/AFNetworking/AFNetworking)
+[![codecov.io](https://codecov.io/github/AFNetworking/AFNetworking/coverage.svg?branch=master)](https://codecov.io/github/AFNetworking/AFNetworking?branch=master)
+[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/AFNetworking.svg)](https://img.shields.io/cocoapods/v/AFNetworking.svg)
+[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
+[![Platform](https://img.shields.io/cocoapods/p/AFNetworking.svg?style=flat)](http://cocoadocs.org/docsets/AFNetworking)
+[![Twitter](https://img.shields.io/badge/twitter-@AFNetworking-blue.svg?style=flat)](http://twitter.com/AFNetworking)
+
+AFNetworking is a delightful networking library for iOS and Mac OS X. 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.
+
+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.
+
+Choose AFNetworking for your next project, or migrate over your existing projects—you'll be happy you did!
+
+## How To Get Started
+
+- [Download AFNetworking](https://github.com/AFNetworking/AFNetworking/archive/master.zip) and try out the included Mac and iPhone example apps
+- 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)
+- Check out the [documentation](http://cocoadocs.org/docsets/AFNetworking/) for a comprehensive look at all of the APIs available in AFNetworking
+- 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.
+
+## Communication
+
+- If you **need help**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/afnetworking). (Tag 'afnetworking')
+- If you'd like to **ask a general question**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/afnetworking).
+- If you **found a bug**, _and can provide steps to reliably reproduce it_, open an issue.
+- If you **have a feature request**, open an issue.
+- If you **want to contribute**, submit a pull request.
+
+## Installation
+AFNetworking supports multiple methods for installing the library in a project.
+
+## Installation with CocoaPods
+
+[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:
+
+```bash
+$ gem install cocoapods
+```
+
+> CocoaPods 0.39.0+ is required to build AFNetworking 3.0.0+.
+
+#### Podfile
+
+To integrate AFNetworking into your Xcode project using CocoaPods, specify it in your `Podfile`:
+
+```ruby
+source 'https://github.com/CocoaPods/Specs.git'
+platform :ios, '8.0'
+
+pod 'AFNetworking', '~> 3.0'
+```
+
+Then, run the following command:
+
+```bash
+$ pod install
+```
+
+### Installation with Carthage
+
+[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
+
+You can install Carthage with [Homebrew](http://brew.sh/) using the following command:
+
+```bash
+$ brew update
+$ brew install carthage
+```
+
+To integrate AFNetworking into your Xcode project using Carthage, specify it in your `Cartfile`:
+
+```ogdl
+github "AFNetworking/AFNetworking" ~> 3.0
+```
+
+Run `carthage` to build the framework and drag the built `AFNetworking.framework` into your Xcode project.
+
+## Requirements
+
+| AFNetworking Version | Minimum iOS Target  | Minimum OS X Target  | Minimum watchOS Target  | Minimum tvOS Target  |                                   Notes                                   |
+|:--------------------:|:---------------------------:|:----------------------------:|:----------------------------:|:----------------------------:|:-------------------------------------------------------------------------:|
+| 3.x | iOS 7 | OS X 10.9 | watchOS 2.0 | tvOS 9.0 | Xcode 7+ is required. `NSURLConnectionOperation` support has been removed. |
+| 2.6 -> 2.6.3 | iOS 7 | OS X 10.9 | watchOS 2.0 | n/a | Xcode 7+ is required. |
+| 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. |
+| 1.x | iOS 5 | Mac OS X 10.7 | n/a | n/a |
+| 0.10.x | iOS 4 | Mac OS X 10.6 | n/a | n/a |
+
+(OS X projects must support [64-bit with modern Cocoa runtime](https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtVersionsPlatforms.html)).
+
+> Programming in Swift? Try [Alamofire](https://github.com/Alamofire/Alamofire) for a more conventional set of APIs.
+
+## Architecture
+
+### NSURLSession
+
+- `AFURLSessionManager`
+- `AFHTTPSessionManager`
+
+### Serialization
+
+* `<AFURLRequestSerialization>`
+  - `AFHTTPRequestSerializer`
+  - `AFJSONRequestSerializer`
+  - `AFPropertyListRequestSerializer`
+* `<AFURLResponseSerialization>`
+  - `AFHTTPResponseSerializer`
+  - `AFJSONResponseSerializer`
+  - `AFXMLParserResponseSerializer`
+  - `AFXMLDocumentResponseSerializer` _(Mac OS X)_
+  - `AFPropertyListResponseSerializer`
+  - `AFImageResponseSerializer`
+  - `AFCompoundResponseSerializer`
+
+### Additional Functionality
+
+- `AFSecurityPolicy`
+- `AFNetworkReachabilityManager`
+
+## Usage
+
+### AFURLSessionManager
+
+`AFURLSessionManager` creates and manages an `NSURLSession` object based on a specified `NSURLSessionConfiguration` object, which conforms to `<NSURLSessionTaskDelegate>`, `<NSURLSessionDataDelegate>`, `<NSURLSessionDownloadDelegate>`, and `<NSURLSessionDelegate>`.
+
+#### Creating a Download Task
+
+```objective-c
+NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
+AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];
+
+NSURL *URL = [NSURL URLWithString:@"http://example.com/download.zip"];
+NSURLRequest *request = [NSURLRequest requestWithURL:URL];
+
+NSURLSessionDownloadTask *downloadTask = [manager downloadTaskWithRequest:request progress:nil destination:^NSURL *(NSURL *targetPath, NSURLResponse *response) {
+    NSURL *documentsDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil];
+    return [documentsDirectoryURL URLByAppendingPathComponent:[response suggestedFilename]];
+} completionHandler:^(NSURLResponse *response, NSURL *filePath, NSError *error) {
+    NSLog(@"File downloaded to: %@", filePath);
+}];
+[downloadTask resume];
+```
+
+#### Creating an Upload Task
+
+```objective-c
+NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
+AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];
+
+NSURL *URL = [NSURL URLWithString:@"http://example.com/upload"];
+NSURLRequest *request = [NSURLRequest requestWithURL:URL];
+
+NSURL *filePath = [NSURL fileURLWithPath:@"file://path/to/image.png"];
+NSURLSessionUploadTask *uploadTask = [manager uploadTaskWithRequest:request fromFile:filePath progress:nil completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
+    if (error) {
+        NSLog(@"Error: %@", error);
+    } else {
+        NSLog(@"Success: %@ %@", response, responseObject);
+    }
+}];
+[uploadTask resume];
+```
+
+#### Creating an Upload Task for a Multi-Part Request, with Progress
+
+```objective-c
+NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:@"http://example.com/upload" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
+        [formData appendPartWithFileURL:[NSURL fileURLWithPath:@"file://path/to/image.jpg"] name:@"file" fileName:@"filename.jpg" mimeType:@"image/jpeg" error:nil];
+    } error:nil];
+
+AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
+
+NSURLSessionUploadTask *uploadTask;
+uploadTask = [manager
+              uploadTaskWithStreamedRequest:request
+              progress:^(NSProgress * _Nonnull uploadProgress) {
+                  // This is not called back on the main queue.
+                  // You are responsible for dispatching to the main queue for UI updates
+                  dispatch_async(dispatch_get_main_queue(), ^{
+                      //Update the progress view
+                      [progressView setProgress:uploadProgress.fractionCompleted];
+                  });
+              }
+              completionHandler:^(NSURLResponse * _Nonnull response, id  _Nullable responseObject, NSError * _Nullable error) {
+                  if (error) {
+                      NSLog(@"Error: %@", error);
+                  } else {
+                      NSLog(@"%@ %@", response, responseObject);
+                  }
+              }];
+
+[uploadTask resume];
+```
+
+#### Creating a Data Task
+
+```objective-c
+NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
+AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];
+
+NSURL *URL = [NSURL URLWithString:@"http://httpbin.org/get"];
+NSURLRequest *request = [NSURLRequest requestWithURL:URL];
+
+NSURLSessionDataTask *dataTask = [manager dataTaskWithRequest:request completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
+    if (error) {
+        NSLog(@"Error: %@", error);
+    } else {
+        NSLog(@"%@ %@", response, responseObject);
+    }
+}];
+[dataTask resume];
+```
+
+---
+
+### Request Serialization
+
+Request serializers create requests from URL strings, encoding parameters as either a query string or HTTP body.
+
+```objective-c
+NSString *URLString = @"http://example.com";
+NSDictionary *parameters = @{@"foo": @"bar", @"baz": @[@1, @2, @3]};
+```
+
+#### Query String Parameter Encoding
+
+```objective-c
+[[AFHTTPRequestSerializer serializer] requestWithMethod:@"GET" URLString:URLString parameters:parameters error:nil];
+```
+
+    GET http://example.com?foo=bar&baz[]=1&baz[]=2&baz[]=3
+
+#### URL Form Parameter Encoding
+
+```objective-c
+[[AFHTTPRequestSerializer serializer] requestWithMethod:@"POST" URLString:URLString parameters:parameters error:nil];
+```
+
+    POST http://example.com/
+    Content-Type: application/x-www-form-urlencoded
+
+    foo=bar&baz[]=1&baz[]=2&baz[]=3
+
+#### JSON Parameter Encoding
+
+```objective-c
+[[AFJSONRequestSerializer serializer] requestWithMethod:@"POST" URLString:URLString parameters:parameters error:nil];
+```
+
+    POST http://example.com/
+    Content-Type: application/json
+
+    {"foo": "bar", "baz": [1,2,3]}
+
+---
+
+### Network Reachability Manager
+
+`AFNetworkReachabilityManager` monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces.
+
+* Do not use Reachability to determine if the original request should be sent.
+	* You should try to send it.
+* You can use Reachability to determine when a request should be automatically retried.
+	* Although it may still fail, a Reachability notification that the connectivity is available is a good time to retry something.
+* Network reachability is a useful tool for determining why a request might have failed.
+	* 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."
+
+See also [WWDC 2012 session 706, "Networking Best Practices."](https://developer.apple.com/videos/play/wwdc2012-706/).
+
+#### Shared Network Reachability
+
+```objective-c
+[[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
+    NSLog(@"Reachability: %@", AFStringFromNetworkReachabilityStatus(status));
+}];
+
+[[AFNetworkReachabilityManager sharedManager] startMonitoring];
+```
+
+---
+
+### Security Policy
+
+`AFSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections.
+
+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.
+
+#### Allowing Invalid SSL Certificates
+
+```objective-c
+AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
+manager.securityPolicy.allowInvalidCertificates = YES; // not recommended for production
+```
+
+---
+
+## Unit Tests
+
+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.
+
+## Credits
+
+AFNetworking is owned and maintained by the [Alamofire Software Foundation](http://alamofire.org).
+
+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).
+
+AFNetworking's logo was designed by [Alan Defibaugh](http://www.alandefibaugh.com/).
+
+And most of all, thanks to AFNetworking's [growing list of contributors](https://github.com/AFNetworking/AFNetworking/contributors).
+
+### Security Disclosure
+
+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.
+
+## License
+
+AFNetworking is released under the MIT license. See LICENSE for details.

+ 149 - 0
Pods/AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.h

@@ -0,0 +1,149 @@
+// AFAutoPurgingImageCache.h
+// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import <TargetConditionals.h>
+#import <Foundation/Foundation.h>
+
+#if TARGET_OS_IOS || TARGET_OS_TV
+#import <UIKit/UIKit.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+/**
+ The `AFImageCache` protocol defines a set of APIs for adding, removing and fetching images from a cache synchronously.
+ */
+@protocol AFImageCache <NSObject>
+
+/**
+ Adds the image to the cache with the given identifier.
+
+ @param image The image to cache.
+ @param identifier The unique identifier for the image in the cache.
+ */
+- (void)addImage:(UIImage *)image withIdentifier:(NSString *)identifier;
+
+/**
+ Removes the image from the cache matching the given identifier.
+
+ @param identifier The unique identifier for the image in the cache.
+
+ @return A BOOL indicating whether or not the image was removed from the cache.
+ */
+- (BOOL)removeImageWithIdentifier:(NSString *)identifier;
+
+/**
+ Removes all images from the cache.
+
+ @return A BOOL indicating whether or not all images were removed from the cache.
+ */
+- (BOOL)removeAllImages;
+
+/**
+ Returns the image in the cache associated with the given identifier.
+
+ @param identifier The unique identifier for the image in the cache.
+
+ @return An image for the matching identifier, or nil.
+ */
+- (nullable UIImage *)imageWithIdentifier:(NSString *)identifier;
+@end
+
+
+/**
+ 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.
+ */
+@protocol AFImageRequestCache <AFImageCache>
+
+/**
+ Adds the image to the cache using an identifier created from the request and additional identifier.
+
+ @param image The image to cache.
+ @param request The unique URL request identifing the image asset.
+ @param identifier The additional identifier to apply to the URL request to identify the image.
+ */
+- (void)addImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier;
+
+/**
+ Removes the image from the cache using an identifier created from the request and additional identifier.
+
+ @param request The unique URL request identifing the image asset.
+ @param identifier The additional identifier to apply to the URL request to identify the image.
+ 
+ @return A BOOL indicating whether or not all images were removed from the cache.
+ */
+- (BOOL)removeImageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier;
+
+/**
+ Returns the image from the cache associated with an identifier created from the request and additional identifier.
+
+ @param request The unique URL request identifing the image asset.
+ @param identifier The additional identifier to apply to the URL request to identify the image.
+
+ @return An image for the matching request and identifier, or nil.
+ */
+- (nullable UIImage *)imageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier;
+
+@end
+
+/**
+ 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.
+ */
+@interface AFAutoPurgingImageCache : NSObject <AFImageRequestCache>
+
+/**
+ The total memory capacity of the cache in bytes.
+ */
+@property (nonatomic, assign) UInt64 memoryCapacity;
+
+/**
+ The preferred memory usage after purge in bytes. During a purge, images will be purged until the memory capacity drops below this limit.
+ */
+@property (nonatomic, assign) UInt64 preferredMemoryUsageAfterPurge;
+
+/**
+ The current total memory usage in bytes of all images stored within the cache.
+ */
+@property (nonatomic, assign, readonly) UInt64 memoryUsage;
+
+/**
+ 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`.
+
+ @return The new `AutoPurgingImageCache` instance.
+ */
+- (instancetype)init;
+
+/**
+ Initialies the `AutoPurgingImageCache` instance with the given memory capacity and preferred memory usage
+ after purge limit.
+
+ @param memoryCapacity The total memory capacity of the cache in bytes.
+ @param preferredMemoryCapacity The preferred memory usage after purge in bytes.
+
+ @return The new `AutoPurgingImageCache` instance.
+ */
+- (instancetype)initWithMemoryCapacity:(UInt64)memoryCapacity preferredMemoryCapacity:(UInt64)preferredMemoryCapacity;
+
+@end
+
+NS_ASSUME_NONNULL_END
+
+#endif
+

+ 201 - 0
Pods/AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.m

@@ -0,0 +1,201 @@
+// AFAutoPurgingImageCache.m
+// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import <TargetConditionals.h>
+
+#if TARGET_OS_IOS || TARGET_OS_TV 
+
+#import "AFAutoPurgingImageCache.h"
+
+@interface AFCachedImage : NSObject
+
+@property (nonatomic, strong) UIImage *image;
+@property (nonatomic, strong) NSString *identifier;
+@property (nonatomic, assign) UInt64 totalBytes;
+@property (nonatomic, strong) NSDate *lastAccessDate;
+@property (nonatomic, assign) UInt64 currentMemoryUsage;
+
+@end
+
+@implementation AFCachedImage
+
+-(instancetype)initWithImage:(UIImage *)image identifier:(NSString *)identifier {
+    if (self = [self init]) {
+        self.image = image;
+        self.identifier = identifier;
+
+        CGSize imageSize = CGSizeMake(image.size.width * image.scale, image.size.height * image.scale);
+        CGFloat bytesPerPixel = 4.0;
+        CGFloat bytesPerSize = imageSize.width * imageSize.height;
+        self.totalBytes = (UInt64)bytesPerPixel * (UInt64)bytesPerSize;
+        self.lastAccessDate = [NSDate date];
+    }
+    return self;
+}
+
+- (UIImage*)accessImage {
+    self.lastAccessDate = [NSDate date];
+    return self.image;
+}
+
+- (NSString *)description {
+    NSString *descriptionString = [NSString stringWithFormat:@"Idenfitier: %@  lastAccessDate: %@ ", self.identifier, self.lastAccessDate];
+    return descriptionString;
+
+}
+
+@end
+
+@interface AFAutoPurgingImageCache ()
+@property (nonatomic, strong) NSMutableDictionary <NSString* , AFCachedImage*> *cachedImages;
+@property (nonatomic, assign) UInt64 currentMemoryUsage;
+@property (nonatomic, strong) dispatch_queue_t synchronizationQueue;
+@end
+
+@implementation AFAutoPurgingImageCache
+
+- (instancetype)init {
+    return [self initWithMemoryCapacity:100 * 1024 * 1024 preferredMemoryCapacity:60 * 1024 * 1024];
+}
+
+- (instancetype)initWithMemoryCapacity:(UInt64)memoryCapacity preferredMemoryCapacity:(UInt64)preferredMemoryCapacity {
+    if (self = [super init]) {
+        self.memoryCapacity = memoryCapacity;
+        self.preferredMemoryUsageAfterPurge = preferredMemoryCapacity;
+        self.cachedImages = [[NSMutableDictionary alloc] init];
+
+        NSString *queueName = [NSString stringWithFormat:@"com.alamofire.autopurgingimagecache-%@", [[NSUUID UUID] UUIDString]];
+        self.synchronizationQueue = dispatch_queue_create([queueName cStringUsingEncoding:NSASCIIStringEncoding], DISPATCH_QUEUE_CONCURRENT);
+
+        [[NSNotificationCenter defaultCenter]
+         addObserver:self
+         selector:@selector(removeAllImages)
+         name:UIApplicationDidReceiveMemoryWarningNotification
+         object:nil];
+
+    }
+    return self;
+}
+
+- (void)dealloc {
+    [[NSNotificationCenter defaultCenter] removeObserver:self];
+}
+
+- (UInt64)memoryUsage {
+    __block UInt64 result = 0;
+    dispatch_sync(self.synchronizationQueue, ^{
+        result = self.currentMemoryUsage;
+    });
+    return result;
+}
+
+- (void)addImage:(UIImage *)image withIdentifier:(NSString *)identifier {
+    dispatch_barrier_async(self.synchronizationQueue, ^{
+        AFCachedImage *cacheImage = [[AFCachedImage alloc] initWithImage:image identifier:identifier];
+
+        AFCachedImage *previousCachedImage = self.cachedImages[identifier];
+        if (previousCachedImage != nil) {
+            self.currentMemoryUsage -= previousCachedImage.totalBytes;
+        }
+
+        self.cachedImages[identifier] = cacheImage;
+        self.currentMemoryUsage += cacheImage.totalBytes;
+    });
+
+    dispatch_barrier_async(self.synchronizationQueue, ^{
+        if (self.currentMemoryUsage > self.memoryCapacity) {
+            UInt64 bytesToPurge = self.currentMemoryUsage - self.preferredMemoryUsageAfterPurge;
+            NSMutableArray <AFCachedImage*> *sortedImages = [NSMutableArray arrayWithArray:self.cachedImages.allValues];
+            NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"lastAccessDate"
+                                                                           ascending:YES];
+            [sortedImages sortUsingDescriptors:@[sortDescriptor]];
+
+            UInt64 bytesPurged = 0;
+
+            for (AFCachedImage *cachedImage in sortedImages) {
+                [self.cachedImages removeObjectForKey:cachedImage.identifier];
+                bytesPurged += cachedImage.totalBytes;
+                if (bytesPurged >= bytesToPurge) {
+                    break ;
+                }
+            }
+            self.currentMemoryUsage -= bytesPurged;
+        }
+    });
+}
+
+- (BOOL)removeImageWithIdentifier:(NSString *)identifier {
+    __block BOOL removed = NO;
+    dispatch_barrier_sync(self.synchronizationQueue, ^{
+        AFCachedImage *cachedImage = self.cachedImages[identifier];
+        if (cachedImage != nil) {
+            [self.cachedImages removeObjectForKey:identifier];
+            self.currentMemoryUsage -= cachedImage.totalBytes;
+            removed = YES;
+        }
+    });
+    return removed;
+}
+
+- (BOOL)removeAllImages {
+    __block BOOL removed = NO;
+    dispatch_barrier_sync(self.synchronizationQueue, ^{
+        if (self.cachedImages.count > 0) {
+            [self.cachedImages removeAllObjects];
+            self.currentMemoryUsage = 0;
+            removed = YES;
+        }
+    });
+    return removed;
+}
+
+- (nullable UIImage *)imageWithIdentifier:(NSString *)identifier {
+    __block UIImage *image = nil;
+    dispatch_sync(self.synchronizationQueue, ^{
+        AFCachedImage *cachedImage = self.cachedImages[identifier];
+        image = [cachedImage accessImage];
+    });
+    return image;
+}
+
+- (void)addImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)identifier {
+    [self addImage:image withIdentifier:[self imageCacheKeyFromURLRequest:request withAdditionalIdentifier:identifier]];
+}
+
+- (BOOL)removeImageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)identifier {
+    return [self removeImageWithIdentifier:[self imageCacheKeyFromURLRequest:request withAdditionalIdentifier:identifier]];
+}
+
+- (nullable UIImage *)imageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)identifier {
+    return [self imageWithIdentifier:[self imageCacheKeyFromURLRequest:request withAdditionalIdentifier:identifier]];
+}
+
+- (NSString *)imageCacheKeyFromURLRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)additionalIdentifier {
+    NSString *key = request.URL.absoluteString;
+    if (additionalIdentifier != nil) {
+        key = [key stringByAppendingString:additionalIdentifier];
+    }
+    return key;
+}
+
+@end
+
+#endif

+ 157 - 0
Pods/AFNetworking/UIKit+AFNetworking/AFImageDownloader.h

@@ -0,0 +1,157 @@
+// AFImageDownloader.h
+// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import <TargetConditionals.h>
+
+#if TARGET_OS_IOS || TARGET_OS_TV 
+
+#import <Foundation/Foundation.h>
+#import "AFAutoPurgingImageCache.h"
+#import "AFHTTPSessionManager.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+typedef NS_ENUM(NSInteger, AFImageDownloadPrioritization) {
+    AFImageDownloadPrioritizationFIFO,
+    AFImageDownloadPrioritizationLIFO
+};
+
+/**
+ 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.
+ */
+@interface AFImageDownloadReceipt : NSObject
+
+/**
+ The data task created by the `AFImageDownloader`.
+*/
+@property (nonatomic, strong) NSURLSessionDataTask *task;
+
+/**
+ The unique identifier for the success and failure blocks when duplicate requests are made.
+ */
+@property (nonatomic, strong) NSUUID *receiptID;
+@end
+
+/** 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.
+ */
+@interface AFImageDownloader : NSObject
+
+/**
+ The image cache used to store all downloaded images in. `AFAutoPurgingImageCache` by default.
+ */
+@property (nonatomic, strong, nullable) id <AFImageRequestCache> imageCache;
+
+/**
+ The `AFHTTPSessionManager` used to download images. By default, this is configured with an `AFImageResponseSerializer`, and a shared `NSURLCache` for all image downloads.
+ */
+@property (nonatomic, strong) AFHTTPSessionManager *sessionManager;
+
+/**
+ Defines the order prioritization of incoming download requests being inserted into the queue. `AFImageDownloadPrioritizationFIFO` by default.
+ */
+@property (nonatomic, assign) AFImageDownloadPrioritization downloadPrioritizaton;
+
+/**
+ The shared default instance of `AFImageDownloader` initialized with default values.
+ */
++ (instancetype)defaultInstance;
+
+/**
+ Creates a default `NSURLCache` with common usage parameter values.
+
+ @returns The default `NSURLCache` instance.
+ */
++ (NSURLCache *)defaultURLCache;
+
+/**
+ Default initializer
+
+ @return An instance of `AFImageDownloader` initialized with default values.
+ */
+- (instancetype)init;
+
+/**
+ Initializes the `AFImageDownloader` instance with the given session manager, download prioritization, maximum active download count and image cache.
+
+ @param sessionManager The session manager to use to download images.
+ @param downloadPrioritization The download prioritization of the download queue.
+ @param maximumActiveDownloads  The maximum number of active downloads allowed at any given time. Recommend `4`.
+ @param imageCache The image cache used to store all downloaded images in.
+
+ @return The new `AFImageDownloader` instance.
+ */
+- (instancetype)initWithSessionManager:(AFHTTPSessionManager *)sessionManager
+                downloadPrioritization:(AFImageDownloadPrioritization)downloadPrioritization
+                maximumActiveDownloads:(NSInteger)maximumActiveDownloads
+                            imageCache:(nullable id <AFImageRequestCache>)imageCache;
+
+/**
+ Creates a data task using the `sessionManager` instance for the specified URL request.
+
+ If the same data task is already in the queue or currently being downloaded, the success and failure blocks are
+ appended to the already existing task. Once the task completes, all success or failure blocks attached to the
+ task are executed in the order they were added.
+
+ @param request The URL request.
+ @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`.
+ @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.
+
+ @return The image download receipt for the data task if available. `nil` if the image is stored in the cache.
+ cache and the URL request cache policy allows the cache to be used.
+ */
+- (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *)request
+                                                        success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse  * _Nullable response, UIImage *responseObject))success
+                                                        failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure;
+
+/**
+ Creates a data task using the `sessionManager` instance for the specified URL request.
+
+ If the same data task is already in the queue or currently being downloaded, the success and failure blocks are
+ appended to the already existing task. Once the task completes, all success or failure blocks attached to the
+ task are executed in the order they were added.
+
+ @param request The URL request.
+ @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.
+ @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`.
+ @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.
+
+ @return The image download receipt for the data task if available. `nil` if the image is stored in the cache.
+ cache and the URL request cache policy allows the cache to be used.
+ */
+- (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *)request
+                                                 withReceiptID:(NSUUID *)receiptID
+                                                        success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse  * _Nullable response, UIImage *responseObject))success
+                                                        failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure;
+
+/**
+ Cancels the data task in the receipt by removing the corresponding success and failure blocks and cancelling the data task if necessary.
+
+ 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.
+
+ @param imageDownloadReceipt The image download receipt to cancel.
+ */
+- (void)cancelTaskForImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt;
+
+@end
+
+#endif
+
+NS_ASSUME_NONNULL_END

+ 391 - 0
Pods/AFNetworking/UIKit+AFNetworking/AFImageDownloader.m

@@ -0,0 +1,391 @@
+// AFImageDownloader.m
+// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import <TargetConditionals.h>
+
+#if TARGET_OS_IOS || TARGET_OS_TV
+
+#import "AFImageDownloader.h"
+#import "AFHTTPSessionManager.h"
+
+@interface AFImageDownloaderResponseHandler : NSObject
+@property (nonatomic, strong) NSUUID *uuid;
+@property (nonatomic, copy) void (^successBlock)(NSURLRequest*, NSHTTPURLResponse*, UIImage*);
+@property (nonatomic, copy) void (^failureBlock)(NSURLRequest*, NSHTTPURLResponse*, NSError*);
+@end
+
+@implementation AFImageDownloaderResponseHandler
+
+- (instancetype)initWithUUID:(NSUUID *)uuid
+                     success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *responseObject))success
+                     failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure {
+    if (self = [self init]) {
+        self.uuid = uuid;
+        self.successBlock = success;
+        self.failureBlock = failure;
+    }
+    return self;
+}
+
+- (NSString *)description {
+    return [NSString stringWithFormat: @"<AFImageDownloaderResponseHandler>UUID: %@", [self.uuid UUIDString]];
+}
+
+@end
+
+@interface AFImageDownloaderMergedTask : NSObject
+@property (nonatomic, strong) NSString *URLIdentifier;
+@property (nonatomic, strong) NSUUID *identifier;
+@property (nonatomic, strong) NSURLSessionDataTask *task;
+@property (nonatomic, strong) NSMutableArray <AFImageDownloaderResponseHandler*> *responseHandlers;
+
+@end
+
+@implementation AFImageDownloaderMergedTask
+
+- (instancetype)initWithURLIdentifier:(NSString *)URLIdentifier identifier:(NSUUID *)identifier task:(NSURLSessionDataTask *)task {
+    if (self = [self init]) {
+        self.URLIdentifier = URLIdentifier;
+        self.task = task;
+        self.identifier = identifier;
+        self.responseHandlers = [[NSMutableArray alloc] init];
+    }
+    return self;
+}
+
+- (void)addResponseHandler:(AFImageDownloaderResponseHandler*)handler {
+    [self.responseHandlers addObject:handler];
+}
+
+- (void)removeResponseHandler:(AFImageDownloaderResponseHandler*)handler {
+    [self.responseHandlers removeObject:handler];
+}
+
+@end
+
+@implementation AFImageDownloadReceipt
+
+- (instancetype)initWithReceiptID:(NSUUID *)receiptID task:(NSURLSessionDataTask *)task {
+    if (self = [self init]) {
+        self.receiptID = receiptID;
+        self.task = task;
+    }
+    return self;
+}
+
+@end
+
+@interface AFImageDownloader ()
+
+@property (nonatomic, strong) dispatch_queue_t synchronizationQueue;
+@property (nonatomic, strong) dispatch_queue_t responseQueue;
+
+@property (nonatomic, assign) NSInteger maximumActiveDownloads;
+@property (nonatomic, assign) NSInteger activeRequestCount;
+
+@property (nonatomic, strong) NSMutableArray *queuedMergedTasks;
+@property (nonatomic, strong) NSMutableDictionary *mergedTasks;
+
+@end
+
+
+@implementation AFImageDownloader
+
++ (NSURLCache *)defaultURLCache {
+    return [[NSURLCache alloc] initWithMemoryCapacity:20 * 1024 * 1024
+                                         diskCapacity:150 * 1024 * 1024
+                                             diskPath:@"com.alamofire.imagedownloader"];
+}
+
++ (NSURLSessionConfiguration *)defaultURLSessionConfiguration {
+    NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
+
+    //TODO set the default HTTP headers
+
+    configuration.HTTPShouldSetCookies = YES;
+    configuration.HTTPShouldUsePipelining = NO;
+
+    configuration.requestCachePolicy = NSURLRequestUseProtocolCachePolicy;
+    configuration.allowsCellularAccess = YES;
+    configuration.timeoutIntervalForRequest = 60.0;
+    configuration.URLCache = [AFImageDownloader defaultURLCache];
+
+    return configuration;
+}
+
+- (instancetype)init {
+    NSURLSessionConfiguration *defaultConfiguration = [self.class defaultURLSessionConfiguration];
+    AFHTTPSessionManager *sessionManager = [[AFHTTPSessionManager alloc] initWithSessionConfiguration:defaultConfiguration];
+    sessionManager.responseSerializer = [AFImageResponseSerializer serializer];
+
+    return [self initWithSessionManager:sessionManager
+                 downloadPrioritization:AFImageDownloadPrioritizationFIFO
+                 maximumActiveDownloads:4
+                             imageCache:[[AFAutoPurgingImageCache alloc] init]];
+}
+
+- (instancetype)initWithSessionManager:(AFHTTPSessionManager *)sessionManager
+                downloadPrioritization:(AFImageDownloadPrioritization)downloadPrioritization
+                maximumActiveDownloads:(NSInteger)maximumActiveDownloads
+                            imageCache:(id <AFImageRequestCache>)imageCache {
+    if (self = [super init]) {
+        self.sessionManager = sessionManager;
+
+        self.downloadPrioritizaton = downloadPrioritization;
+        self.maximumActiveDownloads = maximumActiveDownloads;
+        self.imageCache = imageCache;
+
+        self.queuedMergedTasks = [[NSMutableArray alloc] init];
+        self.mergedTasks = [[NSMutableDictionary alloc] init];
+        self.activeRequestCount = 0;
+
+        NSString *name = [NSString stringWithFormat:@"com.alamofire.imagedownloader.synchronizationqueue-%@", [[NSUUID UUID] UUIDString]];
+        self.synchronizationQueue = dispatch_queue_create([name cStringUsingEncoding:NSASCIIStringEncoding], DISPATCH_QUEUE_SERIAL);
+
+        name = [NSString stringWithFormat:@"com.alamofire.imagedownloader.responsequeue-%@", [[NSUUID UUID] UUIDString]];
+        self.responseQueue = dispatch_queue_create([name cStringUsingEncoding:NSASCIIStringEncoding], DISPATCH_QUEUE_CONCURRENT);
+    }
+
+    return self;
+}
+
++ (instancetype)defaultInstance {
+    static AFImageDownloader *sharedInstance = nil;
+    static dispatch_once_t onceToken;
+    dispatch_once(&onceToken, ^{
+        sharedInstance = [[self alloc] init];
+    });
+    return sharedInstance;
+}
+
+- (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *)request
+                                                        success:(void (^)(NSURLRequest * _Nonnull, NSHTTPURLResponse * _Nullable, UIImage * _Nonnull))success
+                                                        failure:(void (^)(NSURLRequest * _Nonnull, NSHTTPURLResponse * _Nullable, NSError * _Nonnull))failure {
+    return [self downloadImageForURLRequest:request withReceiptID:[NSUUID UUID] success:success failure:failure];
+}
+
+- (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *)request
+                                                  withReceiptID:(nonnull NSUUID *)receiptID
+                                                        success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse  * _Nullable response, UIImage *responseObject))success
+                                                        failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure {
+    __block NSURLSessionDataTask *task = nil;
+    dispatch_sync(self.synchronizationQueue, ^{
+        NSString *URLIdentifier = request.URL.absoluteString;
+        if (URLIdentifier == nil) {
+            if (failure) {
+                NSError *error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorBadURL userInfo:nil];
+                dispatch_async(dispatch_get_main_queue(), ^{
+                    failure(request, nil, error);
+                });
+            }
+            return;
+        }
+
+        // 1) Append the success and failure blocks to a pre-existing request if it already exists
+        AFImageDownloaderMergedTask *existingMergedTask = self.mergedTasks[URLIdentifier];
+        if (existingMergedTask != nil) {
+            AFImageDownloaderResponseHandler *handler = [[AFImageDownloaderResponseHandler alloc] initWithUUID:receiptID success:success failure:failure];
+            [existingMergedTask addResponseHandler:handler];
+            task = existingMergedTask.task;
+            return;
+        }
+
+        // 2) Attempt to load the image from the image cache if the cache policy allows it
+        switch (request.cachePolicy) {
+            case NSURLRequestUseProtocolCachePolicy:
+            case NSURLRequestReturnCacheDataElseLoad:
+            case NSURLRequestReturnCacheDataDontLoad: {
+                UIImage *cachedImage = [self.imageCache imageforRequest:request withAdditionalIdentifier:nil];
+                if (cachedImage != nil) {
+                    if (success) {
+                        dispatch_async(dispatch_get_main_queue(), ^{
+                            success(request, nil, cachedImage);
+                        });
+                    }
+                    return;
+                }
+                break;
+            }
+            default:
+                break;
+        }
+
+        // 3) Create the request and set up authentication, validation and response serialization
+        NSUUID *mergedTaskIdentifier = [NSUUID UUID];
+        NSURLSessionDataTask *createdTask;
+        __weak __typeof__(self) weakSelf = self;
+
+        createdTask = [self.sessionManager
+                       dataTaskWithRequest:request
+                       completionHandler:^(NSURLResponse * _Nonnull response, id  _Nullable responseObject, NSError * _Nullable error) {
+                           dispatch_async(self.responseQueue, ^{
+                               __strong __typeof__(weakSelf) strongSelf = weakSelf;
+                               AFImageDownloaderMergedTask *mergedTask = self.mergedTasks[URLIdentifier];
+                               if ([mergedTask.identifier isEqual:mergedTaskIdentifier]) {
+                                   mergedTask = [strongSelf safelyRemoveMergedTaskWithURLIdentifier:URLIdentifier];
+                                   if (error) {
+                                       for (AFImageDownloaderResponseHandler *handler in mergedTask.responseHandlers) {
+                                           if (handler.failureBlock) {
+                                               dispatch_async(dispatch_get_main_queue(), ^{
+                                                   handler.failureBlock(request, (NSHTTPURLResponse*)response, error);
+                                               });
+                                           }
+                                       }
+                                   } else {
+                                       [strongSelf.imageCache addImage:responseObject forRequest:request withAdditionalIdentifier:nil];
+
+                                       for (AFImageDownloaderResponseHandler *handler in mergedTask.responseHandlers) {
+                                           if (handler.successBlock) {
+                                               dispatch_async(dispatch_get_main_queue(), ^{
+                                                   handler.successBlock(request, (NSHTTPURLResponse*)response, responseObject);
+                                               });
+                                           }
+                                       }
+                                       
+                                   }
+                               }
+                               [strongSelf safelyDecrementActiveTaskCount];
+                               [strongSelf safelyStartNextTaskIfNecessary];
+                           });
+                       }];
+
+        // 4) Store the response handler for use when the request completes
+        AFImageDownloaderResponseHandler *handler = [[AFImageDownloaderResponseHandler alloc] initWithUUID:receiptID
+                                                                                                   success:success
+                                                                                                   failure:failure];
+        AFImageDownloaderMergedTask *mergedTask = [[AFImageDownloaderMergedTask alloc]
+                                                   initWithURLIdentifier:URLIdentifier
+                                                   identifier:mergedTaskIdentifier
+                                                   task:createdTask];
+        [mergedTask addResponseHandler:handler];
+        self.mergedTasks[URLIdentifier] = mergedTask;
+
+        // 5) Either start the request or enqueue it depending on the current active request count
+        if ([self isActiveRequestCountBelowMaximumLimit]) {
+            [self startMergedTask:mergedTask];
+        } else {
+            [self enqueueMergedTask:mergedTask];
+        }
+
+        task = mergedTask.task;
+    });
+    if (task) {
+        return [[AFImageDownloadReceipt alloc] initWithReceiptID:receiptID task:task];
+    } else {
+        return nil;
+    }
+}
+
+- (void)cancelTaskForImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt {
+    dispatch_sync(self.synchronizationQueue, ^{
+        NSString *URLIdentifier = imageDownloadReceipt.task.originalRequest.URL.absoluteString;
+        AFImageDownloaderMergedTask *mergedTask = self.mergedTasks[URLIdentifier];
+        NSUInteger index = [mergedTask.responseHandlers indexOfObjectPassingTest:^BOOL(AFImageDownloaderResponseHandler * _Nonnull handler, __unused NSUInteger idx, __unused BOOL * _Nonnull stop) {
+            return handler.uuid == imageDownloadReceipt.receiptID;
+        }];
+
+        if (index != NSNotFound) {
+            AFImageDownloaderResponseHandler *handler = mergedTask.responseHandlers[index];
+            [mergedTask removeResponseHandler:handler];
+            NSString *failureReason = [NSString stringWithFormat:@"ImageDownloader cancelled URL request: %@",imageDownloadReceipt.task.originalRequest.URL.absoluteString];
+            NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey:failureReason};
+            NSError *error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled userInfo:userInfo];
+            if (handler.failureBlock) {
+                dispatch_async(dispatch_get_main_queue(), ^{
+                    handler.failureBlock(imageDownloadReceipt.task.originalRequest, nil, error);
+                });
+            }
+        }
+
+        if (mergedTask.responseHandlers.count == 0 && mergedTask.task.state == NSURLSessionTaskStateSuspended) {
+            [mergedTask.task cancel];
+            [self removeMergedTaskWithURLIdentifier:URLIdentifier];
+        }
+    });
+}
+
+- (AFImageDownloaderMergedTask*)safelyRemoveMergedTaskWithURLIdentifier:(NSString *)URLIdentifier {
+    __block AFImageDownloaderMergedTask *mergedTask = nil;
+    dispatch_sync(self.synchronizationQueue, ^{
+        mergedTask = [self removeMergedTaskWithURLIdentifier:URLIdentifier];
+    });
+    return mergedTask;
+}
+
+//This method should only be called from safely within the synchronizationQueue
+- (AFImageDownloaderMergedTask *)removeMergedTaskWithURLIdentifier:(NSString *)URLIdentifier {
+    AFImageDownloaderMergedTask *mergedTask = self.mergedTasks[URLIdentifier];
+    [self.mergedTasks removeObjectForKey:URLIdentifier];
+    return mergedTask;
+}
+
+- (void)safelyDecrementActiveTaskCount {
+    dispatch_sync(self.synchronizationQueue, ^{
+        if (self.activeRequestCount > 0) {
+            self.activeRequestCount -= 1;
+        }
+    });
+}
+
+- (void)safelyStartNextTaskIfNecessary {
+    dispatch_sync(self.synchronizationQueue, ^{
+        if ([self isActiveRequestCountBelowMaximumLimit]) {
+            while (self.queuedMergedTasks.count > 0) {
+                AFImageDownloaderMergedTask *mergedTask = [self dequeueMergedTask];
+                if (mergedTask.task.state == NSURLSessionTaskStateSuspended) {
+                    [self startMergedTask:mergedTask];
+                    break;
+                }
+            }
+        }
+    });
+}
+
+- (void)startMergedTask:(AFImageDownloaderMergedTask *)mergedTask {
+    [mergedTask.task resume];
+    ++self.activeRequestCount;
+}
+
+- (void)enqueueMergedTask:(AFImageDownloaderMergedTask *)mergedTask {
+    switch (self.downloadPrioritizaton) {
+        case AFImageDownloadPrioritizationFIFO:
+            [self.queuedMergedTasks addObject:mergedTask];
+            break;
+        case AFImageDownloadPrioritizationLIFO:
+            [self.queuedMergedTasks insertObject:mergedTask atIndex:0];
+            break;
+    }
+}
+
+- (AFImageDownloaderMergedTask *)dequeueMergedTask {
+    AFImageDownloaderMergedTask *mergedTask = nil;
+    mergedTask = [self.queuedMergedTasks firstObject];
+    [self.queuedMergedTasks removeObject:mergedTask];
+    return mergedTask;
+}
+
+- (BOOL)isActiveRequestCountBelowMaximumLimit {
+    return self.activeRequestCount < self.maximumActiveDownloads;
+}
+
+@end
+
+#endif

+ 103 - 0
Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h

@@ -0,0 +1,103 @@
+// AFNetworkActivityIndicatorManager.h
+// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import <Foundation/Foundation.h>
+
+#import <TargetConditionals.h>
+
+#if TARGET_OS_IOS
+
+#import <UIKit/UIKit.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+/**
+ `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.
+
+ 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:
+
+    [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES];
+
+ 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.
+
+ See the Apple Human Interface Guidelines section about the Network Activity Indicator for more information:
+ http://developer.apple.com/library/iOS/#documentation/UserExperience/Conceptual/MobileHIG/UIElementGuidelines/UIElementGuidelines.html#//apple_ref/doc/uid/TP40006556-CH13-SW44
+ */
+NS_EXTENSION_UNAVAILABLE_IOS("Use view controller based solutions where appropriate instead.")
+@interface AFNetworkActivityIndicatorManager : NSObject
+
+/**
+ A Boolean value indicating whether the manager is enabled.
+
+ If YES, the manager will change status bar network activity indicator according to network operation notifications it receives. The default value is NO.
+ */
+@property (nonatomic, assign, getter = isEnabled) BOOL enabled;
+
+/**
+ A Boolean value indicating whether the network activity indicator manager is currently active.
+*/
+@property (readonly, nonatomic, assign, getter=isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible;
+
+/**
+ 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.
+ 
+ Apple's HIG describes the following:
+
+ > 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.
+
+ */
+@property (nonatomic, assign) NSTimeInterval activationDelay;
+
+/**
+ 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.
+ */
+
+@property (nonatomic, assign) NSTimeInterval completionDelay;
+
+/**
+ Returns the shared network activity indicator manager object for the system.
+
+ @return The systemwide network activity indicator manager.
+ */
++ (instancetype)sharedManager;
+
+/**
+ Increments the number of active network requests. If this number was zero before incrementing, this will start animating the status bar network activity indicator.
+ */
+- (void)incrementActivityCount;
+
+/**
+ Decrements the number of active network requests. If this number becomes zero after decrementing, this will stop animating the status bar network activity indicator.
+ */
+- (void)decrementActivityCount;
+
+/**
+ 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.
+
+ @param block A block to be executed when the network activity indicator status changes.
+ */
+- (void)setNetworkingActivityActionWithBlock:(nullable void (^)(BOOL networkActivityIndicatorVisible))block;
+
+@end
+
+NS_ASSUME_NONNULL_END
+
+#endif

+ 261 - 0
Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m

@@ -0,0 +1,261 @@
+// AFNetworkActivityIndicatorManager.m
+// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import "AFNetworkActivityIndicatorManager.h"
+
+#if TARGET_OS_IOS
+#import "AFURLSessionManager.h"
+
+typedef NS_ENUM(NSInteger, AFNetworkActivityManagerState) {
+    AFNetworkActivityManagerStateNotActive,
+    AFNetworkActivityManagerStateDelayingStart,
+    AFNetworkActivityManagerStateActive,
+    AFNetworkActivityManagerStateDelayingEnd
+};
+
+static NSTimeInterval const kDefaultAFNetworkActivityManagerActivationDelay = 1.0;
+static NSTimeInterval const kDefaultAFNetworkActivityManagerCompletionDelay = 0.17;
+
+static NSURLRequest * AFNetworkRequestFromNotification(NSNotification *notification) {
+    if ([[notification object] respondsToSelector:@selector(originalRequest)]) {
+        return [(NSURLSessionTask *)[notification object] originalRequest];
+    } else {
+        return nil;
+    }
+}
+
+typedef void (^AFNetworkActivityActionBlock)(BOOL networkActivityIndicatorVisible);
+
+@interface AFNetworkActivityIndicatorManager ()
+@property (readwrite, nonatomic, assign) NSInteger activityCount;
+@property (readwrite, nonatomic, strong) NSTimer *activationDelayTimer;
+@property (readwrite, nonatomic, strong) NSTimer *completionDelayTimer;
+@property (readonly, nonatomic, getter = isNetworkActivityOccurring) BOOL networkActivityOccurring;
+@property (nonatomic, copy) AFNetworkActivityActionBlock networkActivityActionBlock;
+@property (nonatomic, assign) AFNetworkActivityManagerState currentState;
+@property (nonatomic, assign, getter=isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible;
+
+- (void)updateCurrentStateForNetworkActivityChange;
+@end
+
+@implementation AFNetworkActivityIndicatorManager
+
++ (instancetype)sharedManager {
+    static AFNetworkActivityIndicatorManager *_sharedManager = nil;
+    static dispatch_once_t oncePredicate;
+    dispatch_once(&oncePredicate, ^{
+        _sharedManager = [[self alloc] init];
+    });
+
+    return _sharedManager;
+}
+
+- (instancetype)init {
+    self = [super init];
+    if (!self) {
+        return nil;
+    }
+    self.currentState = AFNetworkActivityManagerStateNotActive;
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidStart:) name:AFNetworkingTaskDidResumeNotification object:nil];
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingTaskDidSuspendNotification object:nil];
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingTaskDidCompleteNotification object:nil];
+    self.activationDelay = kDefaultAFNetworkActivityManagerActivationDelay;
+    self.completionDelay = kDefaultAFNetworkActivityManagerCompletionDelay;
+
+    return self;
+}
+
+- (void)dealloc {
+    [[NSNotificationCenter defaultCenter] removeObserver:self];
+
+    [_activationDelayTimer invalidate];
+    [_completionDelayTimer invalidate];
+}
+
+- (void)setEnabled:(BOOL)enabled {
+    _enabled = enabled;
+    if (enabled == NO) {
+        [self setCurrentState:AFNetworkActivityManagerStateNotActive];
+    }
+}
+
+- (void)setNetworkingActivityActionWithBlock:(void (^)(BOOL networkActivityIndicatorVisible))block {
+    self.networkActivityActionBlock = block;
+}
+
+- (BOOL)isNetworkActivityOccurring {
+    @synchronized(self) {
+        return self.activityCount > 0;
+    }
+}
+
+- (void)setNetworkActivityIndicatorVisible:(BOOL)networkActivityIndicatorVisible {
+    if (_networkActivityIndicatorVisible != networkActivityIndicatorVisible) {
+        [self willChangeValueForKey:@"networkActivityIndicatorVisible"];
+        @synchronized(self) {
+             _networkActivityIndicatorVisible = networkActivityIndicatorVisible;
+        }
+        [self didChangeValueForKey:@"networkActivityIndicatorVisible"];
+        if (self.networkActivityActionBlock) {
+            self.networkActivityActionBlock(networkActivityIndicatorVisible);
+        } else {
+            [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:networkActivityIndicatorVisible];
+        }
+    }
+}
+
+- (void)setActivityCount:(NSInteger)activityCount {
+	@synchronized(self) {
+		_activityCount = activityCount;
+	}
+
+    dispatch_async(dispatch_get_main_queue(), ^{
+        [self updateCurrentStateForNetworkActivityChange];
+    });
+}
+
+- (void)incrementActivityCount {
+    [self willChangeValueForKey:@"activityCount"];
+	@synchronized(self) {
+		_activityCount++;
+	}
+    [self didChangeValueForKey:@"activityCount"];
+
+    dispatch_async(dispatch_get_main_queue(), ^{
+        [self updateCurrentStateForNetworkActivityChange];
+    });
+}
+
+- (void)decrementActivityCount {
+    [self willChangeValueForKey:@"activityCount"];
+	@synchronized(self) {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wgnu"
+		_activityCount = MAX(_activityCount - 1, 0);
+#pragma clang diagnostic pop
+	}
+    [self didChangeValueForKey:@"activityCount"];
+
+    dispatch_async(dispatch_get_main_queue(), ^{
+        [self updateCurrentStateForNetworkActivityChange];
+    });
+}
+
+- (void)networkRequestDidStart:(NSNotification *)notification {
+    if ([AFNetworkRequestFromNotification(notification) URL]) {
+        [self incrementActivityCount];
+    }
+}
+
+- (void)networkRequestDidFinish:(NSNotification *)notification {
+    if ([AFNetworkRequestFromNotification(notification) URL]) {
+        [self decrementActivityCount];
+    }
+}
+
+#pragma mark - Internal State Management
+- (void)setCurrentState:(AFNetworkActivityManagerState)currentState {
+    @synchronized(self) {
+        if (_currentState != currentState) {
+            [self willChangeValueForKey:@"currentState"];
+            _currentState = currentState;
+            switch (currentState) {
+                case AFNetworkActivityManagerStateNotActive:
+                    [self cancelActivationDelayTimer];
+                    [self cancelCompletionDelayTimer];
+                    [self setNetworkActivityIndicatorVisible:NO];
+                    break;
+                case AFNetworkActivityManagerStateDelayingStart:
+                    [self startActivationDelayTimer];
+                    break;
+                case AFNetworkActivityManagerStateActive:
+                    [self cancelCompletionDelayTimer];
+                    [self setNetworkActivityIndicatorVisible:YES];
+                    break;
+                case AFNetworkActivityManagerStateDelayingEnd:
+                    [self startCompletionDelayTimer];
+                    break;
+            }
+        }
+        [self didChangeValueForKey:@"currentState"];
+    }
+}
+
+- (void)updateCurrentStateForNetworkActivityChange {
+    if (self.enabled) {
+        switch (self.currentState) {
+            case AFNetworkActivityManagerStateNotActive:
+                if (self.isNetworkActivityOccurring) {
+                    [self setCurrentState:AFNetworkActivityManagerStateDelayingStart];
+                }
+                break;
+            case AFNetworkActivityManagerStateDelayingStart:
+                //No op. Let the delay timer finish out.
+                break;
+            case AFNetworkActivityManagerStateActive:
+                if (!self.isNetworkActivityOccurring) {
+                    [self setCurrentState:AFNetworkActivityManagerStateDelayingEnd];
+                }
+                break;
+            case AFNetworkActivityManagerStateDelayingEnd:
+                if (self.isNetworkActivityOccurring) {
+                    [self setCurrentState:AFNetworkActivityManagerStateActive];
+                }
+                break;
+        }
+    }
+}
+
+- (void)startActivationDelayTimer {
+    self.activationDelayTimer = [NSTimer
+                                 timerWithTimeInterval:self.activationDelay target:self selector:@selector(activationDelayTimerFired) userInfo:nil repeats:NO];
+    [[NSRunLoop mainRunLoop] addTimer:self.activationDelayTimer forMode:NSRunLoopCommonModes];
+}
+
+- (void)activationDelayTimerFired {
+    if (self.networkActivityOccurring) {
+        [self setCurrentState:AFNetworkActivityManagerStateActive];
+    } else {
+        [self setCurrentState:AFNetworkActivityManagerStateNotActive];
+    }
+}
+
+- (void)startCompletionDelayTimer {
+    [self.completionDelayTimer invalidate];
+    self.completionDelayTimer = [NSTimer timerWithTimeInterval:self.completionDelay target:self selector:@selector(completionDelayTimerFired) userInfo:nil repeats:NO];
+    [[NSRunLoop mainRunLoop] addTimer:self.completionDelayTimer forMode:NSRunLoopCommonModes];
+}
+
+- (void)completionDelayTimerFired {
+    [self setCurrentState:AFNetworkActivityManagerStateNotActive];
+}
+
+- (void)cancelActivationDelayTimer {
+    [self.activationDelayTimer invalidate];
+}
+
+- (void)cancelCompletionDelayTimer {
+    [self.completionDelayTimer invalidate];
+}
+
+@end
+
+#endif

+ 48 - 0
Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h

@@ -0,0 +1,48 @@
+// UIActivityIndicatorView+AFNetworking.h
+// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import <Foundation/Foundation.h>
+
+#import <TargetConditionals.h>
+
+#if TARGET_OS_IOS || TARGET_OS_TV
+
+#import <UIKit/UIKit.h>
+
+/**
+ 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.
+ */
+@interface UIActivityIndicatorView (AFNetworking)
+
+///----------------------------------
+/// @name Animating for Session Tasks
+///----------------------------------
+
+/**
+ Binds the animating state to the state of the specified task.
+
+ @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled.
+ */
+- (void)setAnimatingWithStateOfTask:(nullable NSURLSessionTask *)task;
+
+@end
+
+#endif

+ 124 - 0
Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m

@@ -0,0 +1,124 @@
+// UIActivityIndicatorView+AFNetworking.m
+// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import "UIActivityIndicatorView+AFNetworking.h"
+#import <objc/runtime.h>
+
+#if TARGET_OS_IOS || TARGET_OS_TV
+
+#import "AFURLSessionManager.h"
+
+@interface AFActivityIndicatorViewNotificationObserver : NSObject
+@property (readonly, nonatomic, weak) UIActivityIndicatorView *activityIndicatorView;
+- (instancetype)initWithActivityIndicatorView:(UIActivityIndicatorView *)activityIndicatorView;
+
+- (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task;
+
+@end
+
+@implementation UIActivityIndicatorView (AFNetworking)
+
+- (AFActivityIndicatorViewNotificationObserver *)af_notificationObserver {
+    AFActivityIndicatorViewNotificationObserver *notificationObserver = objc_getAssociatedObject(self, @selector(af_notificationObserver));
+    if (notificationObserver == nil) {
+        notificationObserver = [[AFActivityIndicatorViewNotificationObserver alloc] initWithActivityIndicatorView:self];
+        objc_setAssociatedObject(self, @selector(af_notificationObserver), notificationObserver, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+    }
+    return notificationObserver;
+}
+
+- (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task {
+    [[self af_notificationObserver] setAnimatingWithStateOfTask:task];
+}
+
+@end
+
+@implementation AFActivityIndicatorViewNotificationObserver
+
+- (instancetype)initWithActivityIndicatorView:(UIActivityIndicatorView *)activityIndicatorView
+{
+    self = [super init];
+    if (self) {
+        _activityIndicatorView = activityIndicatorView;
+    }
+    return self;
+}
+
+- (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task {
+    NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
+
+    [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil];
+    [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil];
+    [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil];
+    
+    if (task) {
+        if (task.state != NSURLSessionTaskStateCompleted) {
+            
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wreceiver-is-weak"
+#pragma clang diagnostic ignored "-Warc-repeated-use-of-weak"
+            if (task.state == NSURLSessionTaskStateRunning) {
+                [self.activityIndicatorView startAnimating];
+            } else {
+                [self.activityIndicatorView stopAnimating];
+            }
+#pragma clang diagnostic pop
+
+            [notificationCenter addObserver:self selector:@selector(af_startAnimating) name:AFNetworkingTaskDidResumeNotification object:task];
+            [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidCompleteNotification object:task];
+            [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidSuspendNotification object:task];
+        }
+    }
+}
+
+#pragma mark -
+
+- (void)af_startAnimating {
+    dispatch_async(dispatch_get_main_queue(), ^{
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wreceiver-is-weak"
+        [self.activityIndicatorView startAnimating];
+#pragma clang diagnostic pop
+    });
+}
+
+- (void)af_stopAnimating {
+    dispatch_async(dispatch_get_main_queue(), ^{
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wreceiver-is-weak"
+        [self.activityIndicatorView stopAnimating];
+#pragma clang diagnostic pop
+    });
+}
+
+#pragma mark -
+
+- (void)dealloc {
+    NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
+    
+    [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil];
+    [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil];
+    [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil];
+}
+
+@end
+
+#endif

+ 175 - 0
Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h

@@ -0,0 +1,175 @@
+// UIButton+AFNetworking.h
+// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import <Foundation/Foundation.h>
+
+#import <TargetConditionals.h>
+
+#if TARGET_OS_IOS || TARGET_OS_TV
+
+#import <UIKit/UIKit.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@class AFImageDownloader;
+
+/**
+ 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.
+
+ @warning Compound values for control `state` (such as `UIControlStateHighlighted | UIControlStateDisabled`) are unsupported.
+ */
+@interface UIButton (AFNetworking)
+
+///------------------------------------
+/// @name Accessing the Image Downloader
+///------------------------------------
+
+/**
+ Set the shared image downloader used to download images.
+
+ @param imageDownloader The shared image downloader used to download images.
+*/
++ (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader;
+
+/**
+ The shared image downloader used to download images.
+ */
++ (AFImageDownloader *)sharedImageDownloader;
+
+///--------------------
+/// @name Setting Image
+///--------------------
+
+/**
+ 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.
+
+  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.
+
+ @param state The control state.
+ @param url The URL used for the image request.
+ */
+- (void)setImageForState:(UIControlState)state
+                 withURL:(NSURL *)url;
+
+/**
+ 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.
+
+ 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.
+
+ @param state The control state.
+ @param url The URL used for the image request.
+ @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.
+ */
+- (void)setImageForState:(UIControlState)state
+                 withURL:(NSURL *)url
+        placeholderImage:(nullable UIImage *)placeholderImage;
+
+/**
+ 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.
+
+ 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.
+
+ 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.
+
+ @param state The control state.
+ @param urlRequest The URL request used for the image request.
+ @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.
+ @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`.
+ @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.
+ */
+- (void)setImageForState:(UIControlState)state
+          withURLRequest:(NSURLRequest *)urlRequest
+        placeholderImage:(nullable UIImage *)placeholderImage
+                 success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success
+                 failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure;
+
+
+///-------------------------------
+/// @name Setting Background Image
+///-------------------------------
+
+/**
+ 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.
+
+ 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.
+
+ @param state The control state.
+ @param url The URL used for the background image request.
+ */
+- (void)setBackgroundImageForState:(UIControlState)state
+                           withURL:(NSURL *)url;
+
+/**
+ 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.
+
+ 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.
+
+ @param state The control state.
+ @param url The URL used for the background image request.
+ @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.
+ */
+- (void)setBackgroundImageForState:(UIControlState)state
+                           withURL:(NSURL *)url
+                  placeholderImage:(nullable UIImage *)placeholderImage;
+
+/**
+ 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.
+
+ 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.
+
+ 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.
+
+ @param state The control state.
+ @param urlRequest The URL request used for the image request.
+ @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.
+ @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`.
+ @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.
+ */
+- (void)setBackgroundImageForState:(UIControlState)state
+                    withURLRequest:(NSURLRequest *)urlRequest
+                  placeholderImage:(nullable UIImage *)placeholderImage
+                           success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success
+                           failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure;
+
+
+///------------------------------
+/// @name Canceling Image Loading
+///------------------------------
+
+/**
+ Cancels any executing image task for the specified control state of the receiver, if one exists.
+
+ @param state The control state.
+ */
+- (void)cancelImageDownloadTaskForState:(UIControlState)state;
+
+/**
+ Cancels any executing background image task for the specified control state of the receiver, if one exists.
+
+ @param state The control state.
+ */
+- (void)cancelBackgroundImageDownloadTaskForState:(UIControlState)state;
+
+@end
+
+NS_ASSUME_NONNULL_END
+
+#endif

+ 305 - 0
Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.m

@@ -0,0 +1,305 @@
+// UIButton+AFNetworking.m
+// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import "UIButton+AFNetworking.h"
+
+#import <objc/runtime.h>
+
+#if TARGET_OS_IOS || TARGET_OS_TV
+
+#import "UIImageView+AFNetworking.h"
+#import "AFImageDownloader.h"
+
+@interface UIButton (_AFNetworking)
+@end
+
+@implementation UIButton (_AFNetworking)
+
+#pragma mark -
+
+static char AFImageDownloadReceiptNormal;
+static char AFImageDownloadReceiptHighlighted;
+static char AFImageDownloadReceiptSelected;
+static char AFImageDownloadReceiptDisabled;
+
+static const char * af_imageDownloadReceiptKeyForState(UIControlState state) {
+    switch (state) {
+        case UIControlStateHighlighted:
+            return &AFImageDownloadReceiptHighlighted;
+        case UIControlStateSelected:
+            return &AFImageDownloadReceiptSelected;
+        case UIControlStateDisabled:
+            return &AFImageDownloadReceiptDisabled;
+        case UIControlStateNormal:
+        default:
+            return &AFImageDownloadReceiptNormal;
+    }
+}
+
+- (AFImageDownloadReceipt *)af_imageDownloadReceiptForState:(UIControlState)state {
+    return (AFImageDownloadReceipt *)objc_getAssociatedObject(self, af_imageDownloadReceiptKeyForState(state));
+}
+
+- (void)af_setImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt
+                           forState:(UIControlState)state
+{
+    objc_setAssociatedObject(self, af_imageDownloadReceiptKeyForState(state), imageDownloadReceipt, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+}
+
+#pragma mark -
+
+static char AFBackgroundImageDownloadReceiptNormal;
+static char AFBackgroundImageDownloadReceiptHighlighted;
+static char AFBackgroundImageDownloadReceiptSelected;
+static char AFBackgroundImageDownloadReceiptDisabled;
+
+static const char * af_backgroundImageDownloadReceiptKeyForState(UIControlState state) {
+    switch (state) {
+        case UIControlStateHighlighted:
+            return &AFBackgroundImageDownloadReceiptHighlighted;
+        case UIControlStateSelected:
+            return &AFBackgroundImageDownloadReceiptSelected;
+        case UIControlStateDisabled:
+            return &AFBackgroundImageDownloadReceiptDisabled;
+        case UIControlStateNormal:
+        default:
+            return &AFBackgroundImageDownloadReceiptNormal;
+    }
+}
+
+- (AFImageDownloadReceipt *)af_backgroundImageDownloadReceiptForState:(UIControlState)state {
+    return (AFImageDownloadReceipt *)objc_getAssociatedObject(self, af_backgroundImageDownloadReceiptKeyForState(state));
+}
+
+- (void)af_setBackgroundImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt
+                                     forState:(UIControlState)state
+{
+    objc_setAssociatedObject(self, af_backgroundImageDownloadReceiptKeyForState(state), imageDownloadReceipt, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+}
+
+@end
+
+#pragma mark -
+
+@implementation UIButton (AFNetworking)
+
++ (AFImageDownloader *)sharedImageDownloader {
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wgnu"
+    return objc_getAssociatedObject(self, @selector(sharedImageDownloader)) ?: [AFImageDownloader defaultInstance];
+#pragma clang diagnostic pop
+}
+
++ (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader {
+    objc_setAssociatedObject(self, @selector(sharedImageDownloader), imageDownloader, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+}
+
+#pragma mark -
+
+- (void)setImageForState:(UIControlState)state
+                 withURL:(NSURL *)url
+{
+    [self setImageForState:state withURL:url placeholderImage:nil];
+}
+
+- (void)setImageForState:(UIControlState)state
+                 withURL:(NSURL *)url
+        placeholderImage:(UIImage *)placeholderImage
+{
+    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
+    [request addValue:@"image/*" forHTTPHeaderField:@"Accept"];
+
+    [self setImageForState:state withURLRequest:request placeholderImage:placeholderImage success:nil failure:nil];
+}
+
+- (void)setImageForState:(UIControlState)state
+          withURLRequest:(NSURLRequest *)urlRequest
+        placeholderImage:(nullable UIImage *)placeholderImage
+                 success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success
+                 failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure
+{
+    if ([self isActiveTaskURLEqualToURLRequest:urlRequest forState:state]) {
+        return;
+    }
+
+    [self cancelImageDownloadTaskForState:state];
+
+    AFImageDownloader *downloader = [[self class] sharedImageDownloader];
+    id <AFImageRequestCache> imageCache = downloader.imageCache;
+
+    //Use the image from the image cache if it exists
+    UIImage *cachedImage = [imageCache imageforRequest:urlRequest withAdditionalIdentifier:nil];
+    if (cachedImage) {
+        if (success) {
+            success(urlRequest, nil, cachedImage);
+        } else {
+            [self setImage:cachedImage forState:state];
+        }
+        [self af_setImageDownloadReceipt:nil forState:state];
+    } else {
+        if (placeholderImage) {
+            [self setImage:placeholderImage forState:state];
+        }
+
+        __weak __typeof(self)weakSelf = self;
+        NSUUID *downloadID = [NSUUID UUID];
+        AFImageDownloadReceipt *receipt;
+        receipt = [downloader
+                   downloadImageForURLRequest:urlRequest
+                   withReceiptID:downloadID
+                   success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull responseObject) {
+                       __strong __typeof(weakSelf)strongSelf = weakSelf;
+                       if ([[strongSelf af_imageDownloadReceiptForState:state].receiptID isEqual:downloadID]) {
+                           if (success) {
+                               success(request, response, responseObject);
+                           } else if(responseObject) {
+                               [strongSelf setImage:responseObject forState:state];
+                           }
+                           [strongSelf af_setImageDownloadReceipt:nil forState:state];
+                       }
+
+                   }
+                   failure:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, NSError * _Nonnull error) {
+                       __strong __typeof(weakSelf)strongSelf = weakSelf;
+                       if ([[strongSelf af_imageDownloadReceiptForState:state].receiptID isEqual:downloadID]) {
+                           if (failure) {
+                               failure(request, response, error);
+                           }
+                           [strongSelf  af_setImageDownloadReceipt:nil forState:state];
+                       }
+                   }];
+
+        [self af_setImageDownloadReceipt:receipt forState:state];
+    }
+}
+
+#pragma mark -
+
+- (void)setBackgroundImageForState:(UIControlState)state
+                           withURL:(NSURL *)url
+{
+    [self setBackgroundImageForState:state withURL:url placeholderImage:nil];
+}
+
+- (void)setBackgroundImageForState:(UIControlState)state
+                           withURL:(NSURL *)url
+                  placeholderImage:(nullable UIImage *)placeholderImage
+{
+    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
+    [request addValue:@"image/*" forHTTPHeaderField:@"Accept"];
+
+    [self setBackgroundImageForState:state withURLRequest:request placeholderImage:placeholderImage success:nil failure:nil];
+}
+
+- (void)setBackgroundImageForState:(UIControlState)state
+                    withURLRequest:(NSURLRequest *)urlRequest
+                  placeholderImage:(nullable UIImage *)placeholderImage
+                           success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success
+                           failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure
+{
+    if ([self isActiveBackgroundTaskURLEqualToURLRequest:urlRequest forState:state]) {
+        return;
+    }
+
+    [self cancelBackgroundImageDownloadTaskForState:state];
+
+    AFImageDownloader *downloader = [[self class] sharedImageDownloader];
+    id <AFImageRequestCache> imageCache = downloader.imageCache;
+
+    //Use the image from the image cache if it exists
+    UIImage *cachedImage = [imageCache imageforRequest:urlRequest withAdditionalIdentifier:nil];
+    if (cachedImage) {
+        if (success) {
+            success(urlRequest, nil, cachedImage);
+        } else {
+            [self setBackgroundImage:cachedImage forState:state];
+        }
+        [self af_setBackgroundImageDownloadReceipt:nil forState:state];
+    } else {
+        if (placeholderImage) {
+            [self setBackgroundImage:placeholderImage forState:state];
+        }
+
+        __weak __typeof(self)weakSelf = self;
+        NSUUID *downloadID = [NSUUID UUID];
+        AFImageDownloadReceipt *receipt;
+        receipt = [downloader
+                   downloadImageForURLRequest:urlRequest
+                   withReceiptID:downloadID
+                   success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull responseObject) {
+                       __strong __typeof(weakSelf)strongSelf = weakSelf;
+                       if ([[strongSelf af_backgroundImageDownloadReceiptForState:state].receiptID isEqual:downloadID]) {
+                           if (success) {
+                               success(request, response, responseObject);
+                           } else if(responseObject) {
+                               [strongSelf setBackgroundImage:responseObject forState:state];
+                           }
+                           [strongSelf af_setBackgroundImageDownloadReceipt:nil forState:state];
+                       }
+
+                   }
+                   failure:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, NSError * _Nonnull error) {
+                       __strong __typeof(weakSelf)strongSelf = weakSelf;
+                       if ([[strongSelf af_backgroundImageDownloadReceiptForState:state].receiptID isEqual:downloadID]) {
+                           if (failure) {
+                               failure(request, response, error);
+                           }
+                           [strongSelf  af_setBackgroundImageDownloadReceipt:nil forState:state];
+                       }
+                   }];
+
+        [self af_setBackgroundImageDownloadReceipt:receipt forState:state];
+    }
+}
+
+#pragma mark -
+
+- (void)cancelImageDownloadTaskForState:(UIControlState)state {
+    AFImageDownloadReceipt *receipt = [self af_imageDownloadReceiptForState:state];
+    if (receipt != nil) {
+        [[self.class sharedImageDownloader] cancelTaskForImageDownloadReceipt:receipt];
+        [self af_setImageDownloadReceipt:nil forState:state];
+    }
+}
+
+- (void)cancelBackgroundImageDownloadTaskForState:(UIControlState)state {
+    AFImageDownloadReceipt *receipt = [self af_backgroundImageDownloadReceiptForState:state];
+    if (receipt != nil) {
+        [[self.class sharedImageDownloader] cancelTaskForImageDownloadReceipt:receipt];
+        [self af_setBackgroundImageDownloadReceipt:nil forState:state];
+    }
+}
+
+- (BOOL)isActiveTaskURLEqualToURLRequest:(NSURLRequest *)urlRequest forState:(UIControlState)state {
+    AFImageDownloadReceipt *receipt = [self af_imageDownloadReceiptForState:state];
+    return [receipt.task.originalRequest.URL.absoluteString isEqualToString:urlRequest.URL.absoluteString];
+}
+
+- (BOOL)isActiveBackgroundTaskURLEqualToURLRequest:(NSURLRequest *)urlRequest forState:(UIControlState)state {
+    AFImageDownloadReceipt *receipt = [self af_backgroundImageDownloadReceiptForState:state];
+    return [receipt.task.originalRequest.URL.absoluteString isEqualToString:urlRequest.URL.absoluteString];
+}
+
+
+@end
+
+#endif

+ 35 - 0
Pods/AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h

@@ -0,0 +1,35 @@
+//
+//  UIImage+AFNetworking.h
+//  
+//
+//  Created by Paulo Ferreira on 08/07/15.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#if TARGET_OS_IOS || TARGET_OS_TV
+
+#import <UIKit/UIKit.h>
+
+@interface UIImage (AFNetworking)
+
++ (UIImage*) safeImageWithData:(NSData*)data;
+
+@end
+
+#endif

+ 109 - 0
Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h

@@ -0,0 +1,109 @@
+// UIImageView+AFNetworking.h
+// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import <Foundation/Foundation.h>
+
+#import <TargetConditionals.h>
+
+#if TARGET_OS_IOS || TARGET_OS_TV
+
+#import <UIKit/UIKit.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@class AFImageDownloader;
+
+/**
+ 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.
+ */
+@interface UIImageView (AFNetworking)
+
+///------------------------------------
+/// @name Accessing the Image Downloader
+///------------------------------------
+
+/**
+ Set the shared image downloader used to download images.
+
+ @param imageDownloader The shared image downloader used to download images.
+ */
++ (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader;
+
+/**
+ The shared image downloader used to download images.
+ */
++ (AFImageDownloader *)sharedImageDownloader;
+
+///--------------------
+/// @name Setting Image
+///--------------------
+
+/**
+ 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.
+
+ 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.
+
+ 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:`
+
+ @param url The URL used for the image request.
+ */
+- (void)setImageWithURL:(NSURL *)url;
+
+/**
+ 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.
+
+ 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.
+
+ 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:`
+
+ @param url The URL used for the image request.
+ @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.
+ */
+- (void)setImageWithURL:(NSURL *)url
+       placeholderImage:(nullable UIImage *)placeholderImage;
+
+/**
+ 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.
+
+ 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.
+
+ 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.
+
+ @param urlRequest The URL request used for the image request.
+ @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.
+ @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`.
+ @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.
+ */
+- (void)setImageWithURLRequest:(NSURLRequest *)urlRequest
+              placeholderImage:(nullable UIImage *)placeholderImage
+                       success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success
+                       failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure;
+
+/**
+ Cancels any executing image operation for the receiver, if one exists.
+ */
+- (void)cancelImageDownloadTask;
+
+@end
+
+NS_ASSUME_NONNULL_END
+
+#endif

+ 161 - 0
Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.m

@@ -0,0 +1,161 @@
+// UIImageView+AFNetworking.m
+// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import "UIImageView+AFNetworking.h"
+
+#import <objc/runtime.h>
+
+#if TARGET_OS_IOS || TARGET_OS_TV
+
+#import "AFImageDownloader.h"
+
+@interface UIImageView (_AFNetworking)
+@property (readwrite, nonatomic, strong, setter = af_setActiveImageDownloadReceipt:) AFImageDownloadReceipt *af_activeImageDownloadReceipt;
+@end
+
+@implementation UIImageView (_AFNetworking)
+
+- (AFImageDownloadReceipt *)af_activeImageDownloadReceipt {
+    return (AFImageDownloadReceipt *)objc_getAssociatedObject(self, @selector(af_activeImageDownloadReceipt));
+}
+
+- (void)af_setActiveImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt {
+    objc_setAssociatedObject(self, @selector(af_activeImageDownloadReceipt), imageDownloadReceipt, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+}
+
+@end
+
+#pragma mark -
+
+@implementation UIImageView (AFNetworking)
+
++ (AFImageDownloader *)sharedImageDownloader {
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wgnu"
+    return objc_getAssociatedObject(self, @selector(sharedImageDownloader)) ?: [AFImageDownloader defaultInstance];
+#pragma clang diagnostic pop
+}
+
++ (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader {
+    objc_setAssociatedObject(self, @selector(sharedImageDownloader), imageDownloader, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+}
+
+#pragma mark -
+
+- (void)setImageWithURL:(NSURL *)url {
+    [self setImageWithURL:url placeholderImage:nil];
+}
+
+- (void)setImageWithURL:(NSURL *)url
+       placeholderImage:(UIImage *)placeholderImage
+{
+    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
+    [request addValue:@"image/*" forHTTPHeaderField:@"Accept"];
+
+    [self setImageWithURLRequest:request placeholderImage:placeholderImage success:nil failure:nil];
+}
+
+- (void)setImageWithURLRequest:(NSURLRequest *)urlRequest
+              placeholderImage:(UIImage *)placeholderImage
+                       success:(void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success
+                       failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure
+{
+
+    if ([urlRequest URL] == nil) {
+        [self cancelImageDownloadTask];
+        self.image = placeholderImage;
+        return;
+    }
+
+    if ([self isActiveTaskURLEqualToURLRequest:urlRequest]){
+        return;
+    }
+
+    [self cancelImageDownloadTask];
+
+    AFImageDownloader *downloader = [[self class] sharedImageDownloader];
+    id <AFImageRequestCache> imageCache = downloader.imageCache;
+
+    //Use the image from the image cache if it exists
+    UIImage *cachedImage = [imageCache imageforRequest:urlRequest withAdditionalIdentifier:nil];
+    if (cachedImage) {
+        if (success) {
+            success(urlRequest, nil, cachedImage);
+        } else {
+            self.image = cachedImage;
+        }
+        [self clearActiveDownloadInformation];
+    } else {
+        if (placeholderImage) {
+            self.image = placeholderImage;
+        }
+
+        __weak __typeof(self)weakSelf = self;
+        NSUUID *downloadID = [NSUUID UUID];
+        AFImageDownloadReceipt *receipt;
+        receipt = [downloader
+                   downloadImageForURLRequest:urlRequest
+                   withReceiptID:downloadID
+                   success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull responseObject) {
+                       __strong __typeof(weakSelf)strongSelf = weakSelf;
+                       if ([strongSelf.af_activeImageDownloadReceipt.receiptID isEqual:downloadID]) {
+                           if (success) {
+                               success(request, response, responseObject);
+                           } else if(responseObject) {
+                               strongSelf.image = responseObject;
+                           }
+                           [strongSelf clearActiveDownloadInformation];
+                       }
+
+                   }
+                   failure:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, NSError * _Nonnull error) {
+                       __strong __typeof(weakSelf)strongSelf = weakSelf;
+                        if ([strongSelf.af_activeImageDownloadReceipt.receiptID isEqual:downloadID]) {
+                            if (failure) {
+                                failure(request, response, error);
+                            }
+                            [strongSelf clearActiveDownloadInformation];
+                        }
+                   }];
+
+        self.af_activeImageDownloadReceipt = receipt;
+    }
+}
+
+- (void)cancelImageDownloadTask {
+    if (self.af_activeImageDownloadReceipt != nil) {
+        [[self.class sharedImageDownloader] cancelTaskForImageDownloadReceipt:self.af_activeImageDownloadReceipt];
+        [self clearActiveDownloadInformation];
+     }
+}
+
+- (void)clearActiveDownloadInformation {
+    self.af_activeImageDownloadReceipt = nil;
+}
+
+- (BOOL)isActiveTaskURLEqualToURLRequest:(NSURLRequest *)urlRequest {
+    return [self.af_activeImageDownloadReceipt.task.originalRequest.URL.absoluteString isEqualToString:urlRequest.URL.absoluteString];
+}
+
+@end
+
+#endif

+ 42 - 0
Pods/AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h

@@ -0,0 +1,42 @@
+// UIKit+AFNetworking.h
+//
+// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#if TARGET_OS_IOS || TARGET_OS_TV
+#import <UIKit/UIKit.h>
+
+#ifndef _UIKIT_AFNETWORKING_
+    #define _UIKIT_AFNETWORKING_
+
+#if TARGET_OS_IOS
+    #import "AFAutoPurgingImageCache.h"
+    #import "AFImageDownloader.h"
+    #import "AFNetworkActivityIndicatorManager.h"
+    #import "UIRefreshControl+AFNetworking.h"
+    #import "UIWebView+AFNetworking.h"
+#endif
+
+    #import "UIActivityIndicatorView+AFNetworking.h"
+    #import "UIButton+AFNetworking.h"
+    #import "UIImageView+AFNetworking.h"
+    #import "UIProgressView+AFNetworking.h"
+#endif /* _UIKIT_AFNETWORKING_ */
+#endif

+ 64 - 0
Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h

@@ -0,0 +1,64 @@
+// UIProgressView+AFNetworking.h
+// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import <Foundation/Foundation.h>
+
+#import <TargetConditionals.h>
+
+#if TARGET_OS_IOS || TARGET_OS_TV
+
+#import <UIKit/UIKit.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+
+/**
+ 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.
+ */
+@interface UIProgressView (AFNetworking)
+
+///------------------------------------
+/// @name Setting Session Task Progress
+///------------------------------------
+
+/**
+ Binds the progress to the upload progress of the specified session task.
+
+ @param task The session task.
+ @param animated `YES` if the change should be animated, `NO` if the change should happen immediately.
+ */
+- (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task
+                                   animated:(BOOL)animated;
+
+/**
+ Binds the progress to the download progress of the specified session task.
+
+ @param task The session task.
+ @param animated `YES` if the change should be animated, `NO` if the change should happen immediately.
+ */
+- (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task
+                                     animated:(BOOL)animated;
+
+@end
+
+NS_ASSUME_NONNULL_END
+
+#endif

+ 118 - 0
Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.m

@@ -0,0 +1,118 @@
+// UIProgressView+AFNetworking.m
+// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import "UIProgressView+AFNetworking.h"
+
+#import <objc/runtime.h>
+
+#if TARGET_OS_IOS || TARGET_OS_TV
+
+#import "AFURLSessionManager.h"
+
+static void * AFTaskCountOfBytesSentContext = &AFTaskCountOfBytesSentContext;
+static void * AFTaskCountOfBytesReceivedContext = &AFTaskCountOfBytesReceivedContext;
+
+#pragma mark -
+
+@implementation UIProgressView (AFNetworking)
+
+- (BOOL)af_uploadProgressAnimated {
+    return [(NSNumber *)objc_getAssociatedObject(self, @selector(af_uploadProgressAnimated)) boolValue];
+}
+
+- (void)af_setUploadProgressAnimated:(BOOL)animated {
+    objc_setAssociatedObject(self, @selector(af_uploadProgressAnimated), @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+}
+
+- (BOOL)af_downloadProgressAnimated {
+    return [(NSNumber *)objc_getAssociatedObject(self, @selector(af_downloadProgressAnimated)) boolValue];
+}
+
+- (void)af_setDownloadProgressAnimated:(BOOL)animated {
+    objc_setAssociatedObject(self, @selector(af_downloadProgressAnimated), @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+}
+
+#pragma mark -
+
+- (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task
+                                   animated:(BOOL)animated
+{
+    [task addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesSentContext];
+    [task addObserver:self forKeyPath:@"countOfBytesSent" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesSentContext];
+
+    [self af_setUploadProgressAnimated:animated];
+}
+
+- (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task
+                                     animated:(BOOL)animated
+{
+    [task addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesReceivedContext];
+    [task addObserver:self forKeyPath:@"countOfBytesReceived" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesReceivedContext];
+
+    [self af_setDownloadProgressAnimated:animated];
+}
+
+#pragma mark - NSKeyValueObserving
+
+- (void)observeValueForKeyPath:(NSString *)keyPath
+                      ofObject:(id)object
+                        change:(__unused NSDictionary *)change
+                       context:(void *)context
+{
+    if (context == AFTaskCountOfBytesSentContext || context == AFTaskCountOfBytesReceivedContext) {
+        if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesSent))]) {
+            if ([object countOfBytesExpectedToSend] > 0) {
+                dispatch_async(dispatch_get_main_queue(), ^{
+                    [self setProgress:[object countOfBytesSent] / ([object countOfBytesExpectedToSend] * 1.0f) animated:self.af_uploadProgressAnimated];
+                });
+            }
+        }
+
+        if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesReceived))]) {
+            if ([object countOfBytesExpectedToReceive] > 0) {
+                dispatch_async(dispatch_get_main_queue(), ^{
+                    [self setProgress:[object countOfBytesReceived] / ([object countOfBytesExpectedToReceive] * 1.0f) animated:self.af_downloadProgressAnimated];
+                });
+            }
+        }
+
+        if ([keyPath isEqualToString:NSStringFromSelector(@selector(state))]) {
+            if ([(NSURLSessionTask *)object state] == NSURLSessionTaskStateCompleted) {
+                @try {
+                    [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(state))];
+
+                    if (context == AFTaskCountOfBytesSentContext) {
+                        [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesSent))];
+                    }
+
+                    if (context == AFTaskCountOfBytesReceivedContext) {
+                        [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesReceived))];
+                    }
+                }
+                @catch (NSException * __unused exception) {}
+            }
+        }
+    }
+}
+
+@end
+
+#endif

+ 53 - 0
Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h

@@ -0,0 +1,53 @@
+// UIRefreshControl+AFNetworking.m
+//
+// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import <Foundation/Foundation.h>
+
+#import <TargetConditionals.h>
+
+#if TARGET_OS_IOS
+
+#import <UIKit/UIKit.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+/**
+ 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.
+ */
+@interface UIRefreshControl (AFNetworking)
+
+///-----------------------------------
+/// @name Refreshing for Session Tasks
+///-----------------------------------
+
+/**
+ Binds the refreshing state to the state of the specified task.
+ 
+ @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled.
+ */
+- (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task;
+
+@end
+
+NS_ASSUME_NONNULL_END
+
+#endif

+ 122 - 0
Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m

@@ -0,0 +1,122 @@
+// UIRefreshControl+AFNetworking.m
+//
+// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import "UIRefreshControl+AFNetworking.h"
+#import <objc/runtime.h>
+
+#if TARGET_OS_IOS
+
+#import "AFURLSessionManager.h"
+
+@interface AFRefreshControlNotificationObserver : NSObject
+@property (readonly, nonatomic, weak) UIRefreshControl *refreshControl;
+- (instancetype)initWithActivityRefreshControl:(UIRefreshControl *)refreshControl;
+
+- (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task;
+
+@end
+
+@implementation UIRefreshControl (AFNetworking)
+
+- (AFRefreshControlNotificationObserver *)af_notificationObserver {
+    AFRefreshControlNotificationObserver *notificationObserver = objc_getAssociatedObject(self, @selector(af_notificationObserver));
+    if (notificationObserver == nil) {
+        notificationObserver = [[AFRefreshControlNotificationObserver alloc] initWithActivityRefreshControl:self];
+        objc_setAssociatedObject(self, @selector(af_notificationObserver), notificationObserver, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+    }
+    return notificationObserver;
+}
+
+- (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task {
+    [[self af_notificationObserver] setRefreshingWithStateOfTask:task];
+}
+
+@end
+
+@implementation AFRefreshControlNotificationObserver
+
+- (instancetype)initWithActivityRefreshControl:(UIRefreshControl *)refreshControl
+{
+    self = [super init];
+    if (self) {
+        _refreshControl = refreshControl;
+    }
+    return self;
+}
+
+- (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task {
+    NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
+
+    [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil];
+    [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil];
+    [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil];
+
+    if (task) {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wreceiver-is-weak"
+#pragma clang diagnostic ignored "-Warc-repeated-use-of-weak"
+        if (task.state == NSURLSessionTaskStateRunning) {
+            [self.refreshControl beginRefreshing];
+
+            [notificationCenter addObserver:self selector:@selector(af_beginRefreshing) name:AFNetworkingTaskDidResumeNotification object:task];
+            [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidCompleteNotification object:task];
+            [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidSuspendNotification object:task];
+        } else {
+            [self.refreshControl endRefreshing];
+        }
+#pragma clang diagnostic pop
+    }
+}
+
+#pragma mark -
+
+- (void)af_beginRefreshing {
+    dispatch_async(dispatch_get_main_queue(), ^{
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wreceiver-is-weak"
+        [self.refreshControl beginRefreshing];
+#pragma clang diagnostic pop
+    });
+}
+
+- (void)af_endRefreshing {
+    dispatch_async(dispatch_get_main_queue(), ^{
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wreceiver-is-weak"
+        [self.refreshControl endRefreshing];
+#pragma clang diagnostic pop
+    });
+}
+
+#pragma mark -
+
+- (void)dealloc {
+    NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
+    
+    [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil];
+    [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil];
+    [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil];
+}
+
+@end
+
+#endif

+ 80 - 0
Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h

@@ -0,0 +1,80 @@
+// UIWebView+AFNetworking.h
+// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import <Foundation/Foundation.h>
+
+#import <TargetConditionals.h>
+
+#if TARGET_OS_IOS
+
+#import <UIKit/UIKit.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@class AFHTTPSessionManager;
+
+/**
+ 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.
+
+ @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.
+ */
+@interface UIWebView (AFNetworking)
+
+/**
+ The session manager used to download all requests.
+ */
+@property (nonatomic, strong) AFHTTPSessionManager *sessionManager;
+
+/**
+ Asynchronously loads the specified request.
+
+ @param request A URL request identifying the location of the content to load. This must not be `nil`.
+ @param progress A progress object monitoring the current download progress.
+ @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.
+ @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.
+ */
+- (void)loadRequest:(NSURLRequest *)request
+           progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress
+            success:(nullable NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success
+            failure:(nullable void (^)(NSError *error))failure;
+
+/**
+ Asynchronously loads the data associated with a particular request with a specified MIME type and text encoding.
+
+ @param request A URL request identifying the location of the content to load. This must not be `nil`.
+ @param MIMEType The MIME type of the content. Defaults to the content type of the response if not specified.
+ @param textEncodingName The IANA encoding name, as in `utf-8` or `utf-16`. Defaults to the response text encoding if not specified.
+@param progress A progress object monitoring the current download progress.
+ @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.
+ @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.
+ */
+- (void)loadRequest:(NSURLRequest *)request
+           MIMEType:(nullable NSString *)MIMEType
+   textEncodingName:(nullable NSString *)textEncodingName
+           progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress
+            success:(nullable NSData * (^)(NSHTTPURLResponse *response, NSData *data))success
+            failure:(nullable void (^)(NSError *error))failure;
+
+@end
+
+NS_ASSUME_NONNULL_END
+
+#endif

+ 162 - 0
Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.m

@@ -0,0 +1,162 @@
+// UIWebView+AFNetworking.m
+// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#import "UIWebView+AFNetworking.h"
+
+#import <objc/runtime.h>
+
+#if TARGET_OS_IOS
+
+#import "AFHTTPSessionManager.h"
+#import "AFURLResponseSerialization.h"
+#import "AFURLRequestSerialization.h"
+
+@interface UIWebView (_AFNetworking)
+@property (readwrite, nonatomic, strong, setter = af_setURLSessionTask:) NSURLSessionDataTask *af_URLSessionTask;
+@end
+
+@implementation UIWebView (_AFNetworking)
+
+- (NSURLSessionDataTask *)af_URLSessionTask {
+    return (NSURLSessionDataTask *)objc_getAssociatedObject(self, @selector(af_URLSessionTask));
+}
+
+- (void)af_setURLSessionTask:(NSURLSessionDataTask *)af_URLSessionTask {
+    objc_setAssociatedObject(self, @selector(af_URLSessionTask), af_URLSessionTask, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+}
+
+@end
+
+#pragma mark -
+
+@implementation UIWebView (AFNetworking)
+
+- (AFHTTPSessionManager  *)sessionManager {
+    static AFHTTPSessionManager *_af_defaultHTTPSessionManager = nil;
+    static dispatch_once_t onceToken;
+    dispatch_once(&onceToken, ^{
+        _af_defaultHTTPSessionManager = [[AFHTTPSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
+        _af_defaultHTTPSessionManager.requestSerializer = [AFHTTPRequestSerializer serializer];
+        _af_defaultHTTPSessionManager.responseSerializer = [AFHTTPResponseSerializer serializer];
+    });
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wgnu"
+    return objc_getAssociatedObject(self, @selector(sessionManager)) ?: _af_defaultHTTPSessionManager;
+#pragma clang diagnostic pop
+}
+
+- (void)setSessionManager:(AFHTTPSessionManager *)sessionManager {
+    objc_setAssociatedObject(self, @selector(sessionManager), sessionManager, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+}
+
+- (AFHTTPResponseSerializer <AFURLResponseSerialization> *)responseSerializer {
+    static AFHTTPResponseSerializer <AFURLResponseSerialization> *_af_defaultResponseSerializer = nil;
+    static dispatch_once_t onceToken;
+    dispatch_once(&onceToken, ^{
+        _af_defaultResponseSerializer = [AFHTTPResponseSerializer serializer];
+    });
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wgnu"
+    return objc_getAssociatedObject(self, @selector(responseSerializer)) ?: _af_defaultResponseSerializer;
+#pragma clang diagnostic pop
+}
+
+- (void)setResponseSerializer:(AFHTTPResponseSerializer<AFURLResponseSerialization> *)responseSerializer {
+    objc_setAssociatedObject(self, @selector(responseSerializer), responseSerializer, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+}
+
+#pragma mark -
+
+- (void)loadRequest:(NSURLRequest *)request
+           progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress
+            success:(NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success
+            failure:(void (^)(NSError *error))failure
+{
+    [self loadRequest:request MIMEType:nil textEncodingName:nil progress:progress success:^NSData *(NSHTTPURLResponse *response, NSData *data) {
+        NSStringEncoding stringEncoding = NSUTF8StringEncoding;
+        if (response.textEncodingName) {
+            CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)response.textEncodingName);
+            if (encoding != kCFStringEncodingInvalidId) {
+                stringEncoding = CFStringConvertEncodingToNSStringEncoding(encoding);
+            }
+        }
+
+        NSString *string = [[NSString alloc] initWithData:data encoding:stringEncoding];
+        if (success) {
+            string = success(response, string);
+        }
+
+        return [string dataUsingEncoding:stringEncoding];
+    } failure:failure];
+}
+
+- (void)loadRequest:(NSURLRequest *)request
+           MIMEType:(NSString *)MIMEType
+   textEncodingName:(NSString *)textEncodingName
+           progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress
+            success:(NSData * (^)(NSHTTPURLResponse *response, NSData *data))success
+            failure:(void (^)(NSError *error))failure
+{
+    NSParameterAssert(request);
+
+    if (self.af_URLSessionTask.state == NSURLSessionTaskStateRunning || self.af_URLSessionTask.state == NSURLSessionTaskStateSuspended) {
+        [self.af_URLSessionTask cancel];
+    }
+    self.af_URLSessionTask = nil;
+
+    __weak __typeof(self)weakSelf = self;
+    NSURLSessionDataTask *dataTask;
+    dataTask = [self.sessionManager
+            GET:request.URL.absoluteString
+            parameters:nil
+            progress:nil
+            success:^(NSURLSessionDataTask * _Nonnull task, id  _Nonnull responseObject) {
+                __strong __typeof(weakSelf) strongSelf = weakSelf;
+                if (success) {
+                    success((NSHTTPURLResponse *)task.response, responseObject);
+                }
+                [strongSelf loadData:responseObject MIMEType:MIMEType textEncodingName:textEncodingName baseURL:[task.currentRequest URL]];
+
+                if ([strongSelf.delegate respondsToSelector:@selector(webViewDidStartLoad:)]) {
+                    [strongSelf.delegate webViewDidFinishLoad:strongSelf];
+                }
+            }
+            failure:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
+                if (failure) {
+                    failure(error);
+                }
+            }];
+    self.af_URLSessionTask = dataTask;
+    if (progress != nil) {
+        *progress = [self.sessionManager downloadProgressForTask:dataTask];
+    }
+    [self.af_URLSessionTask resume];
+
+    if ([self.delegate respondsToSelector:@selector(webViewDidStartLoad:)]) {
+        [self.delegate webViewDidStartLoad:self];
+    }
+}
+
+@end
+
+#endif

+ 551 - 0
Pods/BabyBluetooth/Classes/objc/BabyBluetooth.h

@@ -0,0 +1,551 @@
+/*
+ BabyBluetooth
+ 简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
+ https://github.com/coolnameismy/BabyBluetooth
+ 
+ version:0.7.0
+ */
+
+// Created by 刘彦玮 on 15/3/31.
+// Copyright (c) 2015年 刘彦玮. All rights reserved.
+
+
+
+#import <Foundation/Foundation.h>
+#import <CoreBluetooth/CoreBluetooth.h>
+#import "BabyCentralManager.h"
+#import "BabyPeripheralManager.h"
+#import "BabyToy.h"
+#import "BabySpeaker.h"
+#import "BabyRhythm.h"
+#import "BabyDefine.h"
+
+
+@interface BabyBluetooth : NSObject
+
+#pragma mark - babybluetooth的委托
+
+//默认频道的委托
+
+/**
+设备状态改变的block |  when CentralManager state changed
+*/
+- (void)setBlockOnCentralManagerDidUpdateState:(void (^)(CBCentralManager *central))block;
+
+/**
+ 找到Peripherals的block |  when find peripheral
+ */
+- (void)setBlockOnDiscoverToPeripherals:(void (^)(CBCentralManager *central,CBPeripheral *peripheral,NSDictionary *advertisementData, NSNumber *RSSI))block;
+
+/**
+连接Peripherals成功的block
+|  when connected peripheral 
+*/
+- (void)setBlockOnConnected:(void (^)(CBCentralManager *central,CBPeripheral *peripheral))block;
+
+/**
+连接Peripherals失败的block
+|  when fail to connect peripheral 
+*/
+- (void)setBlockOnFailToConnect:(void (^)(CBCentralManager *central,CBPeripheral *peripheral,NSError *error))block;
+
+/**
+断开Peripherals的连接的block
+|  when disconnected peripheral 
+*/
+- (void)setBlockOnDisconnect:(void (^)(CBCentralManager *central,CBPeripheral *peripheral,NSError *error))block;
+
+/**
+设置查找服务的block
+|  when discover services of peripheral 
+*/
+- (void)setBlockOnDiscoverServices:(void (^)(CBPeripheral *peripheral,NSError *error))block;
+
+/**
+设置查找到Characteristics的block
+|  when discovered Characteristics 
+*/
+- (void)setBlockOnDiscoverCharacteristics:(void (^)(CBPeripheral *peripheral,CBService *service,NSError *error))block;
+
+/**
+设置获取到最新Characteristics值的block
+|  when read new characteristics value  or notiy a characteristics value 
+*/
+- (void)setBlockOnReadValueForCharacteristic:(void (^)(CBPeripheral *peripheral,CBCharacteristic *characteristic,NSError *error))block;
+
+/**
+设置查找到Descriptors名称的block
+|  when discover descriptors for characteristic 
+*/
+- (void)setBlockOnDiscoverDescriptorsForCharacteristic:(void (^)(CBPeripheral *peripheral,CBCharacteristic *characteristic,NSError *error))block;
+
+/**
+设置读取到Descriptors值的block
+|  when read descriptors for characteristic 
+*/
+- (void)setBlockOnReadValueForDescriptors:(void (^)(CBPeripheral *peripheral,CBDescriptor *descriptor,NSError *error))block;
+
+/**
+写Characteristic成功后的block
+|  when did write value for characteristic successed 
+*/
+- (void)setBlockOnDidWriteValueForCharacteristic:(void (^)(CBCharacteristic *characteristic,NSError *error))block;
+
+/**
+写descriptor成功后的block
+|  when did write value for descriptor successed 
+*/
+- (void)setBlockOnDidWriteValueForDescriptor:(void (^)(CBDescriptor *descriptor,NSError *error))block;
+
+/**
+characteristic订阅状态改变的block
+|  when characteristic notification state changed 
+*/
+- (void)setBlockOnDidUpdateNotificationStateForCharacteristic:(void (^)(CBCharacteristic *characteristic,NSError *error))block;
+
+/**
+读取RSSI的委托
+|  when did read RSSI 
+*/
+- (void)setBlockOnDidReadRSSI:(void (^)(NSNumber *RSSI,NSError *error))block;
+
+/**
+discoverIncludedServices的回调,暂时在babybluetooth中无作用
+|  no used in babybluetooth 
+*/
+- (void)setBlockOnDidDiscoverIncludedServicesForService:(void (^)(CBService *service,NSError *error))block;
+
+/**
+外设更新名字后的block
+|  when peripheral update name 
+*/
+- (void)setBlockOnDidUpdateName:(void (^)(CBPeripheral *peripheral))block;
+
+/**
+外设更新服务后的block
+|  when peripheral update services 
+*/
+- (void)setBlockOnDidModifyServices:(void (^)(CBPeripheral *peripheral,NSArray *invalidatedServices))block;
+
+
+
+// channel的委托
+
+/**
+设备状态改变的block
+|  when CentralManager state changed 
+*/
+- (void)setBlockOnCentralManagerDidUpdateStateAtChannel:(NSString *)channel
+                                                 block:(void (^)(CBCentralManager *central))block;
+/**
+找到Peripherals的block
+|  when find peripheral 
+*/
+- (void)setBlockOnDiscoverToPeripheralsAtChannel:(NSString *)channel
+                                          block:(void (^)(CBCentralManager *central,CBPeripheral *peripheral,NSDictionary *advertisementData, NSNumber *RSSI))block;
+
+
+/**
+连接Peripherals成功的block
+|  when connected peripheral 
+*/
+- (void)setBlockOnConnectedAtChannel:(NSString *)channel
+                              block:(void (^)(CBCentralManager *central,CBPeripheral *peripheral))block;
+
+
+/**
+连接Peripherals失败的block
+|  when fail to connect peripheral 
+*/
+- (void)setBlockOnFailToConnectAtChannel:(NSString *)channel
+                                  block:(void (^)(CBCentralManager *central,CBPeripheral *peripheral,NSError *error))block;
+
+/**
+断开Peripherals的连接的block
+|  when disconnected peripheral 
+*/
+- (void)setBlockOnDisconnectAtChannel:(NSString *)channel
+                               block:(void (^)(CBCentralManager *central,CBPeripheral *peripheral,NSError *error))block;
+
+
+/**
+设置查找服务的block
+|  when discover services of peripheral 
+*/
+- (void)setBlockOnDiscoverServicesAtChannel:(NSString *)channel
+                                     block:(void (^)(CBPeripheral *peripheral,NSError *error))block;
+
+/**
+设置查找到Characteristics的block
+|  when discovered Characteristics 
+*/
+- (void)setBlockOnDiscoverCharacteristicsAtChannel:(NSString *)channel
+                                            block:(void (^)(CBPeripheral *peripheral,CBService *service,NSError *error))block;
+
+/**
+设置获取到最新Characteristics值的block
+|  when read new characteristics value  or notiy a characteristics value 
+*/
+- (void)setBlockOnReadValueForCharacteristicAtChannel:(NSString *)channel
+                                               block:(void (^)(CBPeripheral *peripheral,CBCharacteristic *characteristic,NSError *error))block;
+
+/**
+设置查找到Characteristics描述的block
+|  when discover descriptors for characteristic 
+*/
+- (void)setBlockOnDiscoverDescriptorsForCharacteristicAtChannel:(NSString *)channel
+                                                         block:(void (^)(CBPeripheral *peripheral,CBCharacteristic *service,NSError *error))block;
+
+/**
+设置读取到Characteristics描述的值的block
+|  when read descriptors for characteristic 
+*/
+- (void)setBlockOnReadValueForDescriptorsAtChannel:(NSString *)channel
+                                            block:(void (^)(CBPeripheral *peripheral,CBDescriptor *descriptor,NSError *error))block;
+
+
+/**
+写Characteristic成功后的block
+|  when did write value for characteristic successed 
+*/
+- (void)setBlockOnDidWriteValueForCharacteristicAtChannel:(NSString *)channel
+                                                   block:(void (^)(CBCharacteristic *characteristic,NSError *error))block;
+
+/**
+写descriptor成功后的block
+|  when did write value for descriptor successed 
+*/
+- (void)setBlockOnDidWriteValueForDescriptorAtChannel:(NSString *)channel
+                                               block:(void (^)(CBDescriptor *descriptor,NSError *error))block;
+
+
+/**
+characteristic订阅状态改变的block
+|  when characteristic notification state changed 
+*/
+- (void)setBlockOnDidUpdateNotificationStateForCharacteristicAtChannel:(NSString *)channel
+                                                                block:(void (^)(CBCharacteristic *characteristic,NSError *error))block;
+
+/**
+读取RSSI的委托
+|  when did read RSSI 
+*/
+- (void)setBlockOnDidReadRSSIAtChannel:(NSString *)channel
+                                block:(void (^)(NSNumber *RSSI,NSError *error))block;
+
+/**
+discoverIncludedServices的回调,暂时在babybluetooth中无作用
+|  no used in babybluetooth 
+*/
+- (void)setBlockOnDidDiscoverIncludedServicesForServiceAtChannel:(NSString *)channel
+                                                          block:(void (^)(CBService *service,NSError *error))block;
+
+/**
+外设更新名字后的block
+|  when peripheral update name 
+*/
+- (void)setBlockOnDidUpdateNameAtChannel:(NSString *)channel
+                                  block:(void (^)(CBPeripheral *peripheral))block;
+
+/**
+外设更新服务后的block
+|  when peripheral update services 
+*/
+- (void)setBlockOnDidModifyServicesAtChannel:(NSString *)channel
+                                      block:(void (^)(CBPeripheral *peripheral,NSArray *invalidatedServices))block;
+
+
+#pragma mark - babybluetooth filter
+
+/**
+设置查找Peripherals的规则
+|  filter of discover peripherals 
+*/
+- (void)setFilterOnDiscoverPeripherals:(BOOL (^)(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI))filter;
+
+/**
+设置连接Peripherals的规则
+|  setting filter of connect to peripherals  peripherals 
+*/
+- (void)setFilterOnConnectToPeripherals:(BOOL (^)(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI))filter;
+
+
+/**
+设置查找Peripherals的规则
+|  filter of discover peripherals 
+*/
+- (void)setFilterOnDiscoverPeripheralsAtChannel:(NSString *)channel
+                                      filter:(BOOL (^)(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI))filter;
+
+/**
+设置连接Peripherals的规则
+|  setting filter of connect to peripherals  peripherals 
+*/
+- (void)setFilterOnConnectToPeripheralsAtChannel:(NSString *)channel
+                                     filter:(BOOL (^)(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI))filter;
+
+
+#pragma mark - babybluetooth Special
+
+/**
+babyBluettooth cancelScan方法调用后的回调
+|  when after call cancelScan 
+*/
+- (void)setBlockOnCancelScanBlock:(void(^)(CBCentralManager *centralManager))block;
+
+/**
+babyBluettooth cancelAllPeripheralsConnectionBlock 方法执行后并且全部设备断开后的回调
+|  when did all peripheral disConnect 
+*/
+- (void)setBlockOnCancelAllPeripheralsConnectionBlock:(void(^)(CBCentralManager *centralManager))block;
+
+/**
+babyBluettooth cancelScan方法调用后的回调
+|  when after call cancelScan 
+*/
+- (void)setBlockOnCancelScanBlockAtChannel:(NSString *)channel
+                                         block:(void(^)(CBCentralManager *centralManager))block;
+
+/**
+babyBluettooth cancelAllPeripheralsConnectionBlock 方法执行后并且全部设备断开后的回调
+|  when did all peripheral disConnect 
+*/
+- (void)setBlockOnCancelAllPeripheralsConnectionBlockAtChannel:(NSString *)channel
+                                                             block:(void(^)(CBCentralManager *centralManager))block;
+
+/**
+设置蓝牙运行时的参数
+|  set ble runtime parameters 
+*/
+- (void)setBabyOptionsWithScanForPeripheralsWithOptions:(NSDictionary *) scanForPeripheralsWithOptions
+                          connectPeripheralWithOptions:(NSDictionary *) connectPeripheralWithOptions
+                        scanForPeripheralsWithServices:(NSArray *)scanForPeripheralsWithServices
+                                  discoverWithServices:(NSArray *)discoverWithServices
+                           discoverWithCharacteristics:(NSArray *)discoverWithCharacteristics;
+
+/**
+设置蓝牙运行时的参数
+|  set ble runtime parameters 
+*/
+- (void)setBabyOptionsAtChannel:(NSString *)channel
+ scanForPeripheralsWithOptions:(NSDictionary *) scanForPeripheralsWithOptions
+  connectPeripheralWithOptions:(NSDictionary *) connectPeripheralWithOptions
+scanForPeripheralsWithServices:(NSArray *)scanForPeripheralsWithServices
+          discoverWithServices:(NSArray *)discoverWithServices
+   discoverWithCharacteristics:(NSArray *)discoverWithCharacteristics;
+
+
+#pragma mark - 链式函数
+
+/**
+查找Peripherals
+ */
+- (BabyBluetooth *(^)()) scanForPeripherals;
+
+/**
+连接Peripherals
+ */
+- (BabyBluetooth *(^)()) connectToPeripherals;
+
+/**
+发现Services
+ */
+- (BabyBluetooth *(^)()) discoverServices;
+
+/**
+获取Characteristics
+ */
+- (BabyBluetooth *(^)()) discoverCharacteristics;
+
+/**
+更新Characteristics的值
+ */
+- (BabyBluetooth *(^)()) readValueForCharacteristic;
+
+/**
+获取Characteristics的名称
+ */
+- (BabyBluetooth *(^)()) discoverDescriptorsForCharacteristic;
+
+/**
+获取Descriptors的值
+ */
+- (BabyBluetooth *(^)()) readValueForDescriptors;
+
+/**
+开始执行
+ */
+- (BabyBluetooth *(^)()) begin;
+
+/**
+sec秒后停止
+ */
+- (BabyBluetooth *(^)(int sec)) stop;
+
+/**
+持有对象
+ */
+- (BabyBluetooth *(^)(id obj)) having;
+
+/**
+切换委托的频道
+ */
+- (BabyBluetooth *(^)(NSString *channel)) channel;
+
+/**
+谓词,返回self
+ */
+- (BabyBluetooth *) and;
+/**
+谓词,返回self
+ */
+- (BabyBluetooth *) then;
+/**
+谓词,返回self
+ */
+- (BabyBluetooth *) with;
+
+/**
+ * enjoy 祝你使用愉快,
+ *
+ *   说明:enjoy是蓝牙全套串行方法的简写(发现服务,发现特征,读取特征,读取特征描述),前面可以必须有scanForPeripherals或having方法,channel可以选择添加。
+     
+    enjoy() 等同于 connectToPeripherals().discoverServices().discoverCharacteristics().readValueForCharacteristic().discoverDescriptorsForCharacteristic().readValueForDescriptors().begin();
+    
+    它可以让你少敲很多代码
+ 
+     ## 例子:
+     - 扫描后来个全套(发现服务,发现特征,读取特征,读取特征描述)
+     
+     ` baby.scanForPeripherals().connectToPeripherals().discoverServices().discoverCharacteristics()
+     .readValueForCharacteristic().discoverDescriptorsForCharacteristic().readValueForDescriptors().begin();
+     `
+     
+     - 直接使用已有的外设连接后全套(发现服务,发现特征,读取特征,读取特征描述)
+
+     ` baby.having(self.peripheral).connectToPeripherals().discoverServices().discoverCharacteristics()
+     .readValueForCharacteristic().discoverDescriptorsForCharacteristic().readValueForDescriptors().begin();
+ `
+ enjoy后面也可以加stop()方法
+ 
+ */
+
+- (BabyBluetooth *(^)()) enjoy;
+
+#pragma mark - 工具方法
+
+/**
+ * 单例构造方法
+ * @return BabyBluetooth共享实例
+ */
++ (instancetype)shareBabyBluetooth;
+
+
+/**
+断开连接
+ */
+- (void)cancelPeripheralConnection:(CBPeripheral *)peripheral;
+
+/**
+断开所有连接
+ */
+- (void)cancelAllPeripheralsConnection;
+
+/**
+停止扫描
+ */
+- (void)cancelScan;
+
+/**
+更新Characteristics的值
+ */
+- (BabyBluetooth *(^)(CBPeripheral *peripheral,CBCharacteristic *characteristic)) characteristicDetails;
+
+/**
+设置characteristic的notify
+ */
+- (void)notify:(CBPeripheral *)peripheral
+characteristic:(CBCharacteristic *)characteristic
+         block:(void(^)(CBPeripheral *peripheral, CBCharacteristic *characteristics, NSError *error))block;
+
+/**
+取消characteristic的notify
+ */
+- (void)cancelNotify:(CBPeripheral *)peripheral
+     characteristic:(CBCharacteristic *)characteristic;
+
+/**
+获取当前连接的peripherals
+ */
+- (NSArray *)findConnectedPeripherals;
+
+/**
+获取当前连接的peripheral
+ */
+- (CBPeripheral *)findConnectedPeripheral:(NSString *)peripheralName;
+
+/**
+获取当前corebluetooth的centralManager对象
+ */
+- (CBCentralManager *)centralManager;
+
+/**
+ 添加断开自动重连的外设
+ */
+- (void)AutoReconnect:(CBPeripheral *)peripheral;
+
+/**
+ 删除断开自动重连的外设
+ */
+- (void)AutoReconnectCancel:(CBPeripheral *)peripheral;
+
+/**
+ 根据外设UUID对应的string获取已配对的外设
+ 
+ 通过方法获取外设后可以直接连接外设,跳过扫描过程
+ */
+- (CBPeripheral *)retrievePeripheralWithUUIDString:(NSString *)UUIDString;
+
+
+#pragma mark - peripheral model
+
+//进入外设模式
+- (BabyPeripheralManager *(^)()) bePeripheral;
+- (BabyPeripheralManager *(^)(NSString *localName)) bePeripheralWithName;
+
+@property (nonatomic, readonly) CBPeripheralManager *peripheralManager;
+
+//peripheral model block
+
+/**
+ PeripheralManager did update state block
+ */
+- (void)peripheralModelBlockOnPeripheralManagerDidUpdateState:(void(^)(CBPeripheralManager *peripheral))block;
+/**
+ PeripheralManager did add service block
+ */
+- (void)peripheralModelBlockOnDidAddService:(void(^)(CBPeripheralManager *peripheral,CBService *service,NSError *error))block;
+/**
+ PeripheralManager did start advertising block
+ */
+- (void)peripheralModelBlockOnDidStartAdvertising:(void(^)(CBPeripheralManager *peripheral,NSError *error))block;
+/**
+ peripheralManager did receive read request block
+ */
+- (void)peripheralModelBlockOnDidReceiveReadRequest:(void(^)(CBPeripheralManager *peripheral,CBATTRequest *request))block;
+/**
+ peripheralManager did receive write request block
+ */
+- (void)peripheralModelBlockOnDidReceiveWriteRequests:(void(^)(CBPeripheralManager *peripheral,NSArray *requests))block;
+/**
+ peripheralManager did subscribe to characteristic block
+ */
+- (void)peripheralModelBlockOnDidSubscribeToCharacteristic:(void(^)(CBPeripheralManager *peripheral,CBCentral *central,CBCharacteristic *characteristic))block;
+/**
+peripheralManager did subscribe to characteristic block
+*/
+- (void)peripheralModelBlockOnDidUnSubscribeToCharacteristic:(void(^)(CBPeripheralManager *peripheral,CBCentral *central,CBCharacteristic *characteristic))block;
+
+@end
+
+

+ 668 - 0
Pods/BabyBluetooth/Classes/objc/BabyBluetooth.m

@@ -0,0 +1,668 @@
+/*
+ BabyBluetooth
+ 简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
+ https://github.com/coolnameismy/BabyBluetooth
+ */
+
+//  Created by 刘彦玮 on 15/3/31.
+//  Copyright (c) 2015年 刘彦玮. All rights reserved.
+
+
+#import "BabyBluetooth.h"
+
+
+
+@implementation BabyBluetooth{
+    BabyCentralManager *babyCentralManager;
+    BabyPeripheralManager *babyPeripheralManager;
+    BabySpeaker *babySpeaker;
+    int CENTRAL_MANAGER_INIT_WAIT_TIMES;
+    NSTimer *timerForStop;
+}
+//单例模式
++ (instancetype)shareBabyBluetooth {
+    static BabyBluetooth *share = nil;
+    static dispatch_once_t oneToken;
+    dispatch_once(&oneToken, ^{
+        share = [[BabyBluetooth alloc]init];
+    });
+   return share;
+}
+
+- (instancetype)init {
+    self = [super init];
+    if (self) {
+        //初始化对象
+        babyCentralManager = [[BabyCentralManager alloc]init];
+        babySpeaker = [[BabySpeaker alloc]init];
+        babyCentralManager->babySpeaker = babySpeaker;
+        
+        babyPeripheralManager = [[BabyPeripheralManager alloc]init];
+        babyPeripheralManager->babySpeaker = babySpeaker;
+    }
+    return self;
+    
+}
+
+#pragma mark - babybluetooth的委托
+/*
+ 默认频道的委托
+ */
+//设备状态改变的委托
+- (void)setBlockOnCentralManagerDidUpdateState:(void (^)(CBCentralManager *central))block {
+    [[babySpeaker callback]setBlockOnCentralManagerDidUpdateState:block];
+}
+//找到Peripherals的委托
+- (void)setBlockOnDiscoverToPeripherals:(void (^)(CBCentralManager *central,CBPeripheral *peripheral,NSDictionary *advertisementData, NSNumber *RSSI))block{
+    [[babySpeaker callback]setBlockOnDiscoverPeripherals:block];
+}
+//连接Peripherals成功的委托
+- (void)setBlockOnConnected:(void (^)(CBCentralManager *central,CBPeripheral *peripheral))block {
+    [[babySpeaker callback]setBlockOnConnectedPeripheral:block];
+}
+//连接Peripherals失败的委托
+- (void)setBlockOnFailToConnect:(void (^)(CBCentralManager *central,CBPeripheral *peripheral,NSError *error))block {
+    [[babySpeaker callback]setBlockOnFailToConnect:block];
+}
+//断开Peripherals的连接
+- (void)setBlockOnDisconnect:(void (^)(CBCentralManager *central,CBPeripheral *peripheral,NSError *error))block {
+    [[babySpeaker callback]setBlockOnDisconnect:block];
+}
+//设置查找服务回叫
+- (void)setBlockOnDiscoverServices:(void (^)(CBPeripheral *peripheral,NSError *error))block {
+    [[babySpeaker callback]setBlockOnDiscoverServices:block];
+}
+//设置查找到Characteristics的block
+- (void)setBlockOnDiscoverCharacteristics:(void (^)(CBPeripheral *peripheral,CBService *service,NSError *error))block {
+    [[babySpeaker callback]setBlockOnDiscoverCharacteristics:block];
+}
+//设置获取到最新Characteristics值的block
+- (void)setBlockOnReadValueForCharacteristic:(void (^)(CBPeripheral *peripheral,CBCharacteristic *characteristic,NSError *error))block {
+    [[babySpeaker callback]setBlockOnReadValueForCharacteristic:block];
+}
+//设置查找到Characteristics描述的block
+- (void)setBlockOnDiscoverDescriptorsForCharacteristic:(void (^)(CBPeripheral *peripheral,CBCharacteristic *service,NSError *error))block {
+    [[babySpeaker callback]setBlockOnDiscoverDescriptorsForCharacteristic:block];
+}
+//设置读取到Characteristics描述的值的block
+- (void)setBlockOnReadValueForDescriptors:(void (^)(CBPeripheral *peripheral,CBDescriptor *descriptor,NSError *error))block {
+    [[babySpeaker callback]setBlockOnReadValueForDescriptors:block];
+}
+
+//写Characteristic成功后的block
+- (void)setBlockOnDidWriteValueForCharacteristic:(void (^)(CBCharacteristic *characteristic,NSError *error))block {
+    [[babySpeaker callback]setBlockOnDidWriteValueForCharacteristic:block];
+}
+//写descriptor成功后的block
+- (void)setBlockOnDidWriteValueForDescriptor:(void (^)(CBDescriptor *descriptor,NSError *error))block {
+    [[babySpeaker callback]setBlockOnDidWriteValueForDescriptor:block];
+}
+//characteristic订阅状态改变的block
+- (void)setBlockOnDidUpdateNotificationStateForCharacteristic:(void (^)(CBCharacteristic *characteristic,NSError *error))block {
+    [[babySpeaker callback]setBlockOnDidUpdateNotificationStateForCharacteristic:block];
+}
+//读取RSSI的委托
+- (void)setBlockOnDidReadRSSI:(void (^)(NSNumber *RSSI,NSError *error))block {
+    [[babySpeaker callback]setBlockOnDidReadRSSI:block];
+}
+//discoverIncludedServices的回调,暂时在babybluetooth中无作用
+- (void)setBlockOnDidDiscoverIncludedServicesForService:(void (^)(CBService *service,NSError *error))block {
+    [[babySpeaker callback]setBlockOnDidDiscoverIncludedServicesForService:block];
+}
+//外设更新名字后的block
+- (void)setBlockOnDidUpdateName:(void (^)(CBPeripheral *peripheral))block {
+    [[babySpeaker callback]setBlockOnDidUpdateName:block];
+}
+//外设更新服务后的block
+- (void)setBlockOnDidModifyServices:(void (^)(CBPeripheral *peripheral,NSArray *invalidatedServices))block {
+    [[babySpeaker callback]setBlockOnDidModifyServices:block];
+}
+
+//设置蓝牙使用的参数参数
+- (void)setBabyOptionsWithScanForPeripheralsWithOptions:(NSDictionary *) scanForPeripheralsWithOptions
+                          connectPeripheralWithOptions:(NSDictionary *) connectPeripheralWithOptions
+                        scanForPeripheralsWithServices:(NSArray *)scanForPeripheralsWithServices
+                                  discoverWithServices:(NSArray *)discoverWithServices
+                           discoverWithCharacteristics:(NSArray *)discoverWithCharacteristics {
+    BabyOptions *option = [[BabyOptions alloc]initWithscanForPeripheralsWithOptions:scanForPeripheralsWithOptions connectPeripheralWithOptions:connectPeripheralWithOptions scanForPeripheralsWithServices:scanForPeripheralsWithServices discoverWithServices:discoverWithServices discoverWithCharacteristics:discoverWithCharacteristics];
+    [[babySpeaker callback]setBabyOptions:option];
+}
+
+/*
+ channel的委托
+ */
+//设备状态改变的委托
+- (void)setBlockOnCentralManagerDidUpdateStateAtChannel:(NSString *)channel
+                                                 block:(void (^)(CBCentralManager *central))block {
+    [[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES] setBlockOnCentralManagerDidUpdateState:block];
+}
+//找到Peripherals的委托
+- (void)setBlockOnDiscoverToPeripheralsAtChannel:(NSString *)channel
+                                          block:(void (^)(CBCentralManager *central,CBPeripheral *peripheral,NSDictionary *advertisementData, NSNumber *RSSI))block {
+    [[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES] setBlockOnDiscoverPeripherals:block];
+}
+
+//连接Peripherals成功的委托
+- (void)setBlockOnConnectedAtChannel:(NSString *)channel
+                              block:(void (^)(CBCentralManager *central,CBPeripheral *peripheral))block {
+    [[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES] setBlockOnConnectedPeripheral:block];
+}
+
+//连接Peripherals失败的委托
+- (void)setBlockOnFailToConnectAtChannel:(NSString *)channel
+                                  block:(void (^)(CBCentralManager *central,CBPeripheral *peripheral,NSError *error))block {
+    [[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES] setBlockOnFailToConnect:block];
+}
+
+//断开Peripherals的连接
+- (void)setBlockOnDisconnectAtChannel:(NSString *)channel
+                               block:(void (^)(CBCentralManager *central,CBPeripheral *peripheral,NSError *error))block {
+    [[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES] setBlockOnDisconnect:block];
+}
+
+//设置查找服务回叫
+- (void)setBlockOnDiscoverServicesAtChannel:(NSString *)channel
+                                     block:(void (^)(CBPeripheral *peripheral,NSError *error))block {
+    [[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES] setBlockOnDiscoverServices:block];
+}
+
+//设置查找到Characteristics的block
+- (void)setBlockOnDiscoverCharacteristicsAtChannel:(NSString *)channel
+                                            block:(void (^)(CBPeripheral *peripheral,CBService *service,NSError *error))block {
+    [[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES] setBlockOnDiscoverCharacteristics:block];
+}
+//设置获取到最新Characteristics值的block
+- (void)setBlockOnReadValueForCharacteristicAtChannel:(NSString *)channel
+                                               block:(void (^)(CBPeripheral *peripheral,CBCharacteristic *characteristic,NSError *error))block {
+    [[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES] setBlockOnReadValueForCharacteristic:block];
+}
+//设置查找到Characteristics描述的block
+- (void)setBlockOnDiscoverDescriptorsForCharacteristicAtChannel:(NSString *)channel
+                                                         block:(void (^)(CBPeripheral *peripheral,CBCharacteristic *service,NSError *error))block {
+    [[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES] setBlockOnDiscoverDescriptorsForCharacteristic:block];
+}
+//设置读取到Characteristics描述的值的block
+- (void)setBlockOnReadValueForDescriptorsAtChannel:(NSString *)channel
+                                            block:(void (^)(CBPeripheral *peripheral,CBDescriptor *descriptor,NSError *error))block {
+    [[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES] setBlockOnReadValueForDescriptors:block];
+}
+
+//写Characteristic成功后的block
+- (void)setBlockOnDidWriteValueForCharacteristicAtChannel:(NSString *)channel
+                                                        block:(void (^)(CBCharacteristic *characteristic,NSError *error))block {
+    [[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES]setBlockOnDidWriteValueForCharacteristic:block];
+}
+//写descriptor成功后的block
+- (void)setBlockOnDidWriteValueForDescriptorAtChannel:(NSString *)channel
+                                      block:(void (^)(CBDescriptor *descriptor,NSError *error))block {
+    [[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES]setBlockOnDidWriteValueForDescriptor:block];
+}
+//characteristic订阅状态改变的block
+- (void)setBlockOnDidUpdateNotificationStateForCharacteristicAtChannel:(NSString *)channel
+                                                                     block:(void (^)(CBCharacteristic *characteristic,NSError *error))block {
+    [[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES]setBlockOnDidUpdateNotificationStateForCharacteristic:block];
+}
+//读取RSSI的委托
+- (void)setBlockOnDidReadRSSIAtChannel:(NSString *)channel
+                                block:(void (^)(NSNumber *RSSI,NSError *error))block {
+    [[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES]setBlockOnDidReadRSSI:block];
+}
+//discoverIncludedServices的回调,暂时在babybluetooth中无作用
+- (void)setBlockOnDidDiscoverIncludedServicesForServiceAtChannel:(NSString *)channel
+                                                          block:(void (^)(CBService *service,NSError *error))block {
+    [[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES]setBlockOnDidDiscoverIncludedServicesForService:block];
+}
+//外设更新名字后的block
+- (void)setBlockOnDidUpdateNameAtChannel:(NSString *)channel
+                                  block:(void (^)(CBPeripheral *peripheral))block {
+    [[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES]setBlockOnDidUpdateName:block];
+}
+//外设更新服务后的block
+- (void)setBlockOnDidModifyServicesAtChannel:(NSString *)channel
+                                      block:(void (^)(CBPeripheral *peripheral,NSArray *invalidatedServices))block {
+    [[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES]setBlockOnDidModifyServices:block];
+}
+
+
+//设置蓝牙运行时的参数
+- (void)setBabyOptionsAtChannel:(NSString *)channel
+ scanForPeripheralsWithOptions:(NSDictionary *) scanForPeripheralsWithOptions
+  connectPeripheralWithOptions:(NSDictionary *) connectPeripheralWithOptions
+    scanForPeripheralsWithServices:(NSArray *)scanForPeripheralsWithServices
+          discoverWithServices:(NSArray *)discoverWithServices
+   discoverWithCharacteristics:(NSArray *)discoverWithCharacteristics {
+    
+    BabyOptions *option = [[BabyOptions alloc]initWithscanForPeripheralsWithOptions:scanForPeripheralsWithOptions connectPeripheralWithOptions:connectPeripheralWithOptions scanForPeripheralsWithServices:scanForPeripheralsWithServices discoverWithServices:discoverWithServices discoverWithCharacteristics:discoverWithCharacteristics];
+     [[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES]setBabyOptions:option];
+}
+
+#pragma mark - babybluetooth filter委托
+//设置查找Peripherals的规则
+- (void)setFilterOnDiscoverPeripherals:(BOOL (^)(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI))filter {
+    [[babySpeaker callback]setFilterOnDiscoverPeripherals:filter];
+}
+//设置连接Peripherals的规则
+- (void)setFilterOnConnectToPeripherals:(BOOL (^)(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI))filter {
+    [[babySpeaker callback]setFilterOnconnectToPeripherals:filter];
+}
+//设置查找Peripherals的规则
+- (void)setFilterOnDiscoverPeripheralsAtChannel:(NSString *)channel
+                                      filter:(BOOL (^)(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI))filter {
+    [[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES] setFilterOnDiscoverPeripherals:filter];
+}
+//设置连接Peripherals的规则
+- (void)setFilterOnConnectToPeripheralsAtChannel:(NSString *)channel
+                                     filter:(BOOL (^)(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI))filter {
+    [[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES] setFilterOnconnectToPeripherals:filter];
+}
+
+#pragma mark - babybluetooth Special
+//babyBluettooth cancelScan方法调用后的回调
+- (void)setBlockOnCancelScanBlock:(void(^)(CBCentralManager *centralManager))block {
+    [[babySpeaker callback]setBlockOnCancelScan:block];
+}
+//babyBluettooth cancelAllPeripheralsConnectionBlock 方法调用后的回调
+- (void)setBlockOnCancelAllPeripheralsConnectionBlock:(void(^)(CBCentralManager *centralManager))block{
+    [[babySpeaker callback]setBlockOnCancelAllPeripheralsConnection:block];
+}
+//babyBluettooth cancelScan方法调用后的回调
+- (void)setBlockOnCancelScanBlockAtChannel:(NSString *)channel
+                                    block:(void(^)(CBCentralManager *centralManager))block {
+    [[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES] setBlockOnCancelScan:block];
+}
+//babyBluettooth cancelAllPeripheralsConnectionBlock 方法调用后的回调
+- (void)setBlockOnCancelAllPeripheralsConnectionBlockAtChannel:(NSString *)channel
+                                                        block:(void(^)(CBCentralManager *centralManager))block {
+    [[babySpeaker callbackOnChnnel:channel createWhenNotExist:YES] setBlockOnCancelAllPeripheralsConnection:block];
+}
+
+#pragma mark - 链式函数
+//查找Peripherals
+- (BabyBluetooth *(^)()) scanForPeripherals {
+    return ^BabyBluetooth *() {
+        [babyCentralManager->pocket setObject:@"YES" forKey:@"needScanForPeripherals"];
+        return self;
+    };
+}
+
+//连接Peripherals
+- (BabyBluetooth *(^)()) connectToPeripherals {
+    return ^BabyBluetooth *() {
+        [babyCentralManager->pocket setObject:@"YES" forKey:@"needConnectPeripheral"];
+        return self;
+    };
+}
+
+//发现Services
+- (BabyBluetooth *(^)()) discoverServices {
+    return ^BabyBluetooth *() {
+        [babyCentralManager->pocket setObject:@"YES" forKey:@"needDiscoverServices"];
+        return self;
+    };
+}
+
+//获取Characteristics
+- (BabyBluetooth *(^)()) discoverCharacteristics {
+    return ^BabyBluetooth *() {
+        [babyCentralManager->pocket setObject:@"YES" forKey:@"needDiscoverCharacteristics"];
+        return self;
+    };
+}
+
+//更新Characteristics的值
+- (BabyBluetooth *(^)()) readValueForCharacteristic {
+    return ^BabyBluetooth *() {
+        [babyCentralManager->pocket setObject:@"YES" forKey:@"needReadValueForCharacteristic"];
+        return self;
+    };
+}
+
+//设置查找到Descriptors名称的block
+- (BabyBluetooth *(^)()) discoverDescriptorsForCharacteristic {
+    return ^BabyBluetooth *() {
+        [babyCentralManager->pocket setObject:@"YES" forKey:@"needDiscoverDescriptorsForCharacteristic"];
+        return self;
+    };
+}
+
+//设置读取到Descriptors值的block
+- (BabyBluetooth *(^)()) readValueForDescriptors {
+    return ^BabyBluetooth *() {
+        [babyCentralManager->pocket setObject:@"YES" forKey:@"needReadValueForDescriptors"];
+        return self;
+    };
+}
+
+//开始并执行
+- (BabyBluetooth *(^)()) begin {
+    return ^BabyBluetooth *() {
+        //取消未执行的stop定时任务
+        [timerForStop invalidate];
+        dispatch_sync(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+            [self resetSeriseParmeter];
+            //处理链式函数缓存的数据
+            if ([[babyCentralManager->pocket valueForKey:@"needScanForPeripherals"] isEqualToString:@"YES"]) {
+                babyCentralManager->needScanForPeripherals = YES;
+            }
+            if ([[babyCentralManager->pocket valueForKey:@"needConnectPeripheral"] isEqualToString:@"YES"]) {
+                babyCentralManager->needConnectPeripheral = YES;
+            }
+            if ([[babyCentralManager->pocket valueForKey:@"needDiscoverServices"] isEqualToString:@"YES"]) {
+                babyCentralManager->needDiscoverServices = YES;
+            }
+            if ([[babyCentralManager->pocket valueForKey:@"needDiscoverCharacteristics"] isEqualToString:@"YES"]) {
+                babyCentralManager->needDiscoverCharacteristics = YES;
+            }
+            if ([[babyCentralManager->pocket valueForKey:@"needReadValueForCharacteristic"] isEqualToString:@"YES"]) {
+                babyCentralManager->needReadValueForCharacteristic = YES;
+            }
+            if ([[babyCentralManager->pocket valueForKey:@"needDiscoverDescriptorsForCharacteristic"] isEqualToString:@"YES"]) {
+                babyCentralManager->needDiscoverDescriptorsForCharacteristic = YES;
+            }
+            if ([[babyCentralManager->pocket valueForKey:@"needReadValueForDescriptors"] isEqualToString:@"YES"]) {
+                babyCentralManager->needReadValueForDescriptors = YES;
+            }
+            //调整委托方法的channel,如果没设置默认为缺省频道
+            NSString *channel = [babyCentralManager->pocket valueForKey:@"channel"];
+            [babySpeaker switchChannel:channel];
+            //缓存的peripheral
+            CBPeripheral *cachedPeripheral = [babyCentralManager->pocket valueForKey:NSStringFromClass([CBPeripheral class])];
+            //校验series合法性
+            [self validateProcess];
+            //清空pocjet
+            babyCentralManager->pocket = [[NSMutableDictionary alloc]init];
+            //开始扫描或连接设备
+            [self start:cachedPeripheral];
+        });
+        return self;
+    };
+}
+
+
+//私有方法,扫描或连接设备
+- (void)start:(CBPeripheral *)cachedPeripheral {
+    if (babyCentralManager->centralManager.state == CBCentralManagerStatePoweredOn) {
+        CENTRAL_MANAGER_INIT_WAIT_TIMES = 0;
+        //扫描后连接
+        if (babyCentralManager->needScanForPeripherals) {
+            //开始扫描peripherals
+            [babyCentralManager scanPeripherals];
+        }
+        //直接连接
+        else {
+            if (cachedPeripheral) {
+                [babyCentralManager connectToPeripheral:cachedPeripheral];
+            }
+        }
+        return;
+    }
+    //尝试重新等待CBCentralManager打开
+    CENTRAL_MANAGER_INIT_WAIT_TIMES ++;
+    if (CENTRAL_MANAGER_INIT_WAIT_TIMES >= KBABY_CENTRAL_MANAGER_INIT_WAIT_TIMES ) {
+        BabyLog(@">>> 第%d次等待CBCentralManager 打开任然失败,请检查你蓝牙使用权限或检查设备问题。",CENTRAL_MANAGER_INIT_WAIT_TIMES);
+        return;
+        //[NSException raise:@"CBCentralManager打开异常" format:@"尝试等待打开CBCentralManager5次,但任未能打开"];
+    }
+    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, KBABY_CENTRAL_MANAGER_INIT_WAIT_SECOND * NSEC_PER_SEC);
+    dispatch_after(popTime, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+        [self start:cachedPeripheral];
+    });
+    BabyLog(@">>> 第%d次等待CBCentralManager打开",CENTRAL_MANAGER_INIT_WAIT_TIMES);
+}
+
+//sec秒后停止
+- (BabyBluetooth *(^)(int sec)) stop {
+    
+    return ^BabyBluetooth *(int sec) {
+        BabyLog(@">>> stop in %d sec",sec);
+        
+        //听见定时器执行babyStop
+        timerForStop = [NSTimer timerWithTimeInterval:sec target:self selector:@selector(babyStop) userInfo:nil repeats:NO];
+        [timerForStop setFireDate: [[NSDate date]dateByAddingTimeInterval:sec]];
+        [[NSRunLoop currentRunLoop] addTimer:timerForStop forMode:NSRunLoopCommonModes];
+        
+        return self;
+    };
+}
+
+//私有方法,停止扫描和断开连接,清空pocket
+- (void)babyStop {
+    BabyLog(@">>>did stop");
+    [timerForStop invalidate];
+    [self resetSeriseParmeter];
+    babyCentralManager->pocket = [[NSMutableDictionary alloc]init];
+    //停止扫描,断开连接
+    [babyCentralManager cancelScan];
+    [babyCentralManager cancelAllPeripheralsConnection];
+}
+
+//重置串行方法参数
+- (void)resetSeriseParmeter {
+    babyCentralManager->needScanForPeripherals = NO;
+    babyCentralManager->needConnectPeripheral = NO;
+    babyCentralManager->needDiscoverServices = NO;
+    babyCentralManager->needDiscoverCharacteristics = NO;
+    babyCentralManager->needReadValueForCharacteristic = NO;
+    babyCentralManager->needDiscoverDescriptorsForCharacteristic = NO;
+    babyCentralManager->needReadValueForDescriptors = NO;
+}
+
+//持有对象
+- (BabyBluetooth *(^)(id obj)) having {
+    return ^(id obj) {
+        [babyCentralManager->pocket setObject:obj forKey:NSStringFromClass([obj class])];
+        return self;
+    };
+}
+
+
+//切换委托频道
+- (BabyBluetooth *(^)(NSString *channel)) channel {
+    return ^BabyBluetooth *(NSString *channel) {
+        //先缓存数据,到begin方法统一处理
+        [babyCentralManager->pocket setValue:channel forKey:@"channel"];
+        return self;
+    };
+}
+
+- (void)validateProcess {
+    
+    NSMutableArray *faildReason = [[NSMutableArray alloc]init];
+    
+    //规则:不执行discoverDescriptorsForCharacteristic()时,不能执行readValueForDescriptors()
+    if (!babyCentralManager->needDiscoverDescriptorsForCharacteristic) {
+        if (babyCentralManager->needReadValueForDescriptors) {
+            [faildReason addObject:@"未执行discoverDescriptorsForCharacteristic()不能执行readValueForDescriptors()"];
+        }
+    }
+    
+    //规则:不执行discoverCharacteristics()时,不能执行readValueForCharacteristic()或者是discoverDescriptorsForCharacteristic()
+    if (!babyCentralManager->needDiscoverCharacteristics) {
+        if (babyCentralManager->needReadValueForCharacteristic||babyCentralManager->needDiscoverDescriptorsForCharacteristic) {
+            [faildReason addObject:@"未执行discoverCharacteristics()不能执行readValueForCharacteristic()或discoverDescriptorsForCharacteristic()"];
+        }
+    }
+    
+    //规则: 不执行discoverServices()不能执行discoverCharacteristics()、readValueForCharacteristic()、discoverDescriptorsForCharacteristic()、readValueForDescriptors()
+    if (!babyCentralManager->needDiscoverServices) {
+        if (babyCentralManager->needDiscoverCharacteristics||babyCentralManager->needDiscoverDescriptorsForCharacteristic ||babyCentralManager->needReadValueForCharacteristic ||babyCentralManager->needReadValueForDescriptors) {
+             [faildReason addObject:@"未执行discoverServices()不能执行discoverCharacteristics()、readValueForCharacteristic()、discoverDescriptorsForCharacteristic()、readValueForDescriptors()"];
+        }
+        
+    }
+
+    //规则:不执行connectToPeripherals()时,不能执行discoverServices()
+    if(!babyCentralManager->needConnectPeripheral) {
+        if (babyCentralManager->needDiscoverServices) {
+             [faildReason addObject:@"未执行connectToPeripherals()不能执行discoverServices()"];
+        }
+    }
+    
+    //规则:不执行needScanForPeripherals(),那么执行connectToPeripheral()方法时必须用having(peripheral)传入peripheral实例
+    if (!babyCentralManager->needScanForPeripherals) {
+        CBPeripheral *peripheral = [babyCentralManager->pocket valueForKey:NSStringFromClass([CBPeripheral class])];
+        if (!peripheral) {
+            [faildReason addObject:@"若不执行scanForPeripherals()方法,则必须执行connectToPeripheral方法并且需要传入参数(CBPeripheral *)peripheral"];
+        }
+    }
+    
+    //抛出异常
+    if ([faildReason lastObject]) {
+        NSException *e = [NSException exceptionWithName:@"BadyBluetooth usage exception" reason:[faildReason lastObject]  userInfo:nil];
+        @throw e;
+    }
+  
+}
+
+- (BabyBluetooth *) and {
+    return self;
+}
+- (BabyBluetooth *) then {
+    return self;
+}
+- (BabyBluetooth *) with {
+    return self;
+}
+
+- (BabyBluetooth *(^)()) enjoy {
+    return ^BabyBluetooth *(int sec) {
+        self.connectToPeripherals().discoverServices().discoverCharacteristics()
+        .readValueForCharacteristic().discoverDescriptorsForCharacteristic().readValueForDescriptors().begin();
+        return self;
+    };
+}
+
+#pragma mark - 工具方法
+//断开连接
+- (void)cancelPeripheralConnection:(CBPeripheral *)peripheral {
+    [babyCentralManager cancelPeripheralConnection:peripheral];
+}
+//断开所有连接
+- (void)cancelAllPeripheralsConnection {
+    [babyCentralManager cancelAllPeripheralsConnection];
+}
+//停止扫描
+- (void)cancelScan{
+    [babyCentralManager cancelScan];
+}
+//读取Characteristic的详细信息
+- (BabyBluetooth *(^)(CBPeripheral *peripheral,CBCharacteristic *characteristic)) characteristicDetails {
+    //切换频道
+    [babySpeaker switchChannel:[babyCentralManager->pocket valueForKey:@"channel"]];
+    babyCentralManager->pocket = [[NSMutableDictionary alloc]init];
+    
+    return ^(CBPeripheral *peripheral,CBCharacteristic *characteristic) {
+        //判断连接状态
+        if (peripheral.state == CBPeripheralStateConnected) {
+            self->babyCentralManager->oneReadValueForDescriptors = YES;
+            [peripheral readValueForCharacteristic:characteristic];
+            [peripheral discoverDescriptorsForCharacteristic:characteristic];
+        }
+        else {
+            BabyLog(@"!!!设备当前处于非连接状态");
+        }
+        
+        return self;
+    };
+}
+
+- (void)notify:(CBPeripheral *)peripheral
+characteristic:(CBCharacteristic *)characteristic
+        block:(void(^)(CBPeripheral *peripheral, CBCharacteristic *characteristics, NSError *error))block {
+    //设置通知
+    [peripheral setNotifyValue:YES forCharacteristic:characteristic];
+    [babySpeaker addNotifyCallback:characteristic withBlock:block];
+}
+
+- (void)cancelNotify:(CBPeripheral *)peripheral
+     characteristic:(CBCharacteristic *)characteristic {
+    [peripheral setNotifyValue:NO forCharacteristic:characteristic];
+    [babySpeaker removeNotifyCallback:characteristic];
+}
+
+//获取当前连接的peripherals
+- (NSArray *)findConnectedPeripherals {
+     return [babyCentralManager findConnectedPeripherals];
+}
+
+//获取当前连接的peripheral
+- (CBPeripheral *)findConnectedPeripheral:(NSString *)peripheralName {
+     return [babyCentralManager findConnectedPeripheral:peripheralName];
+}
+
+//获取当前corebluetooth的centralManager对象
+- (CBCentralManager *)centralManager {
+    return babyCentralManager->centralManager;
+}
+
+/**
+ 添加断开自动重连的外设
+ */
+- (void)AutoReconnect:(CBPeripheral *)peripheral{
+    [babyCentralManager sometimes_ever:peripheral];
+}
+
+/**
+ 删除断开自动重连的外设
+ */
+- (void)AutoReconnectCancel:(CBPeripheral *)peripheral{
+    [babyCentralManager sometimes_never:peripheral];
+}
+ 
+- (CBPeripheral *)retrievePeripheralWithUUIDString:(NSString *)UUIDString {
+    CBPeripheral *p = nil;
+    @try {
+        NSUUID *uuid = [[NSUUID alloc]initWithUUIDString:UUIDString];
+        p = [self.centralManager retrievePeripheralsWithIdentifiers:@[uuid]][0];
+    } @catch (NSException *exception) {
+        BabyLog(@">>> retrievePeripheralWithUUIDString error:%@",exception)
+    } @finally {
+    }
+    return p;
+}
+
+#pragma mark - peripheral model
+
+//进入外设模式
+
+- (CBPeripheralManager *)peripheralManager {
+    return babyPeripheralManager.peripheralManager;
+}
+
+- (BabyPeripheralManager *(^)()) bePeripheral {
+    return ^BabyPeripheralManager* () {
+        return babyPeripheralManager;
+    };
+}
+- (BabyPeripheralManager *(^)(NSString *localName)) bePeripheralWithName {
+    return ^BabyPeripheralManager* (NSString *localName) {
+        babyPeripheralManager.localName = localName;
+        return babyPeripheralManager;
+    };
+}
+
+- (void)peripheralModelBlockOnPeripheralManagerDidUpdateState:(void(^)(CBPeripheralManager *peripheral))block {
+    [[babySpeaker callback]setBlockOnPeripheralModelDidUpdateState:block];
+}
+- (void)peripheralModelBlockOnDidAddService:(void(^)(CBPeripheralManager *peripheral,CBService *service,NSError *error))block {
+    [[babySpeaker callback]setBlockOnPeripheralModelDidAddService:block];
+}
+- (void)peripheralModelBlockOnDidStartAdvertising:(void(^)(CBPeripheralManager *peripheral,NSError *error))block {
+    [[babySpeaker callback]setBlockOnPeripheralModelDidStartAdvertising:block];
+}
+- (void)peripheralModelBlockOnDidReceiveReadRequest:(void(^)(CBPeripheralManager *peripheral,CBATTRequest *request))block {
+    [[babySpeaker callback]setBlockOnPeripheralModelDidReceiveReadRequest:block];
+}
+- (void)peripheralModelBlockOnDidReceiveWriteRequests:(void(^)(CBPeripheralManager *peripheral,NSArray *requests))block {
+    [[babySpeaker callback]setBlockOnPeripheralModelDidReceiveWriteRequests:block];
+}
+- (void)peripheralModelBlockOnDidSubscribeToCharacteristic:(void(^)(CBPeripheralManager *peripheral,CBCentral *central,CBCharacteristic *characteristic))block {
+    [[babySpeaker callback]setBlockOnPeripheralModelDidSubscribeToCharacteristic:block];
+}
+- (void)peripheralModelBlockOnDidUnSubscribeToCharacteristic:(void(^)(CBPeripheralManager *peripheral,CBCentral *central,CBCharacteristic *characteristic))block {
+    [[babySpeaker callback]setBlockOnPeripheralModelDidUnSubscribeToCharacteristic:block];
+}
+
+@end
+
+

+ 137 - 0
Pods/BabyBluetooth/Classes/objc/BabyCallback.h

@@ -0,0 +1,137 @@
+/*
+ BabyBluetooth
+ 简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
+ https://github.com/coolnameismy/BabyBluetooth
+ 
+ @brief  babybluetooth 的block定义和储存
+ 
+ */
+
+//  Created by 刘彦玮 on 15/9/2.
+//  Copyright (c) 2015年 刘彦玮. All rights reserved.
+//
+
+#import <CoreBluetooth/CoreBluetooth.h>
+#import "BabyOptions.h"
+
+
+//设备状态改变的委托
+typedef void (^BBCentralManagerDidUpdateStateBlock)(CBCentralManager *central);
+//找到设备的委托
+typedef void (^BBDiscoverPeripheralsBlock)(CBCentralManager *central,CBPeripheral *peripheral,NSDictionary *advertisementData, NSNumber *RSSI);
+//连接设备成功的block
+typedef void (^BBConnectedPeripheralBlock)(CBCentralManager *central,CBPeripheral *peripheral);
+//连接设备失败的block
+typedef void (^BBFailToConnectBlock)(CBCentralManager *central,CBPeripheral *peripheral,NSError *error);
+//断开设备连接的bock
+typedef void (^BBDisconnectBlock)(CBCentralManager *central,CBPeripheral *peripheral,NSError *error);
+//找到服务的block
+typedef void (^BBDiscoverServicesBlock)(CBPeripheral *peripheral,NSError *error);
+//找到Characteristics的block
+typedef void (^BBDiscoverCharacteristicsBlock)(CBPeripheral *peripheral,CBService *service,NSError *error);
+//更新(获取)Characteristics的value的block
+typedef void (^BBReadValueForCharacteristicBlock)(CBPeripheral *peripheral,CBCharacteristic *characteristic,NSError *error);
+//获取Characteristics的名称
+typedef void (^BBDiscoverDescriptorsForCharacteristicBlock)(CBPeripheral *peripheral,CBCharacteristic *service,NSError *error);
+//获取Descriptors的值
+typedef void (^BBReadValueForDescriptorsBlock)(CBPeripheral *peripheral,CBDescriptor *descriptor,NSError *error);
+
+//babyBluettooth cancelScanBlock方法调用后的回调
+typedef void (^BBCancelScanBlock)(CBCentralManager *centralManager);
+//babyBluettooth cancelAllPeripheralsConnection 方法调用后的回调
+typedef void (^BBCancelAllPeripheralsConnectionBlock)(CBCentralManager *centralManager);
+
+
+typedef void (^BBDidWriteValueForCharacteristicBlock)(CBCharacteristic *characteristic,NSError *error);
+
+typedef void (^BBDidWriteValueForDescriptorBlock)(CBDescriptor *descriptor,NSError *error);
+
+typedef void (^BBDidUpdateNotificationStateForCharacteristicBlock)(CBCharacteristic *characteristic,NSError *error);
+
+typedef void (^BBDidReadRSSIBlock)(NSNumber *RSSI,NSError *error);
+
+typedef void (^BBDidDiscoverIncludedServicesForServiceBlock)(CBService *service,NSError *error);
+
+typedef void (^BBDidUpdateNameBlock)(CBPeripheral *peripheral);
+
+typedef void (^BBDidModifyServicesBlock)(CBPeripheral *peripheral,NSArray *invalidatedServices);
+
+
+//peripheral model
+typedef void (^BBPeripheralModelDidUpdateState)(CBPeripheralManager *peripheral);
+typedef void (^BBPeripheralModelDidAddService)(CBPeripheralManager *peripheral,CBService *service,NSError *error);
+typedef void (^BBPeripheralModelDidStartAdvertising)(CBPeripheralManager *peripheral,NSError *error);
+typedef void (^BBPeripheralModelDidReceiveReadRequest)(CBPeripheralManager *peripheral,CBATTRequest *request);
+typedef void (^BBPeripheralModelDidReceiveWriteRequests)(CBPeripheralManager *peripheral,NSArray *requests);
+typedef void (^BBPeripheralModelDidSubscribeToCharacteristic)(CBPeripheralManager *peripheral,CBCentral *central,CBCharacteristic *characteristic);
+typedef void (^BBPeripheralModelDidUnSubscribeToCharacteristic)(CBPeripheralManager *peripheral,CBCentral *central,CBCharacteristic *characteristic);
+
+
+
+@interface BabyCallback : NSObject
+
+#pragma mark - callback block
+//设备状态改变的委托
+@property (nonatomic, copy) BBCentralManagerDidUpdateStateBlock blockOnCentralManagerDidUpdateState;
+//发现peripherals
+@property (nonatomic, copy) BBDiscoverPeripheralsBlock blockOnDiscoverPeripherals;
+//连接callback
+@property (nonatomic, copy) BBConnectedPeripheralBlock blockOnConnectedPeripheral;
+//连接设备失败的block
+@property (nonatomic, copy) BBFailToConnectBlock blockOnFailToConnect;
+//断开设备连接的bock
+@property (nonatomic, copy) BBDisconnectBlock blockOnDisconnect;
+ //发现services
+@property (nonatomic, copy) BBDiscoverServicesBlock blockOnDiscoverServices;
+//发现Characteristics
+@property (nonatomic, copy) BBDiscoverCharacteristicsBlock blockOnDiscoverCharacteristics;
+//发现更新Characteristics的
+@property (nonatomic, copy) BBReadValueForCharacteristicBlock blockOnReadValueForCharacteristic;
+//获取Characteristics的名称
+@property (nonatomic, copy) BBDiscoverDescriptorsForCharacteristicBlock blockOnDiscoverDescriptorsForCharacteristic;
+//获取Descriptors的值
+@property (nonatomic,copy) BBReadValueForDescriptorsBlock blockOnReadValueForDescriptors;
+
+@property (nonatomic, copy) BBDidWriteValueForCharacteristicBlock blockOnDidWriteValueForCharacteristic;
+
+@property (nonatomic, copy) BBDidWriteValueForDescriptorBlock blockOnDidWriteValueForDescriptor;
+
+@property (nonatomic, copy) BBDidUpdateNotificationStateForCharacteristicBlock blockOnDidUpdateNotificationStateForCharacteristic;
+
+@property (nonatomic, copy) BBDidReadRSSIBlock blockOnDidReadRSSI;
+
+@property (nonatomic, copy) BBDidDiscoverIncludedServicesForServiceBlock blockOnDidDiscoverIncludedServicesForService;
+
+@property (nonatomic, copy) BBDidUpdateNameBlock blockOnDidUpdateName;
+
+@property (nonatomic, copy) BBDidModifyServicesBlock blockOnDidModifyServices;
+
+
+//babyBluettooth stopScan方法调用后的回调
+@property(nonatomic,copy) BBCancelScanBlock blockOnCancelScan;
+//babyBluettooth stopConnectAllPerihperals 方法调用后的回调
+@property(nonatomic,copy) BBCancelAllPeripheralsConnectionBlock blockOnCancelAllPeripheralsConnection;
+//babyBluettooth 蓝牙使用的参数参数
+@property(nonatomic,strong) BabyOptions *babyOptions;
+
+
+#pragma mark - 过滤器Filter
+//发现peripherals规则
+@property (nonatomic, copy) BOOL (^filterOnDiscoverPeripherals)(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI);
+//连接peripherals规则
+@property (nonatomic, copy) BOOL (^filterOnconnectToPeripherals)(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI);
+
+
+#pragma mark - peripheral model
+
+//peripheral model
+
+@property (nonatomic, copy) BBPeripheralModelDidUpdateState blockOnPeripheralModelDidUpdateState;
+@property (nonatomic, copy) BBPeripheralModelDidAddService blockOnPeripheralModelDidAddService;
+@property (nonatomic, copy) BBPeripheralModelDidStartAdvertising blockOnPeripheralModelDidStartAdvertising;
+@property (nonatomic, copy) BBPeripheralModelDidReceiveReadRequest blockOnPeripheralModelDidReceiveReadRequest;
+@property (nonatomic, copy) BBPeripheralModelDidReceiveWriteRequests blockOnPeripheralModelDidReceiveWriteRequests;
+@property (nonatomic, copy) BBPeripheralModelDidSubscribeToCharacteristic blockOnPeripheralModelDidSubscribeToCharacteristic;
+@property (nonatomic, copy) BBPeripheralModelDidUnSubscribeToCharacteristic blockOnPeripheralModelDidUnSubscribeToCharacteristic;
+
+@end

+ 34 - 0
Pods/BabyBluetooth/Classes/objc/BabyCallback.m

@@ -0,0 +1,34 @@
+/*
+ BabyBluetooth
+ 简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
+ https://github.com/coolnameismy/BabyBluetooth
+ */
+
+//  Created by 刘彦玮 on 15/9/2.
+//  Copyright (c) 2015年 刘彦玮. All rights reserved.
+//
+
+#import "BabyCallback.h"
+
+@implementation BabyCallback
+
+
+- (instancetype)init {
+    self = [super init];
+    if (self) {
+        [self setFilterOnDiscoverPeripherals:^BOOL(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI) {
+            if (![peripheralName isEqualToString:@""]) {
+                return YES;
+            }
+            return NO;
+        }];
+        [self setFilterOnconnectToPeripherals:^BOOL(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI) {
+            if (![peripheralName isEqualToString:@""]) {
+                return YES;
+            }
+            return NO;
+        }];
+    }
+    return self;
+}
+@end

+ 92 - 0
Pods/BabyBluetooth/Classes/objc/BabyCentralManager.h

@@ -0,0 +1,92 @@
+/*
+ BabyBluetooth
+ 简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
+ https://github.com/coolnameismy/BabyBluetooth
+
+ @brief  蓝牙中心模式实现类 
+ 
+ */
+
+//  Created by 刘彦玮 on 15/7/30.
+//  Copyright (c) 2015年 刘彦玮. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import <CoreBluetooth/CoreBluetooth.h>
+#import "BabyToy.h"
+#import "BabySpeaker.h"
+#import "BabyDefine.h"
+
+
+
+@interface BabyCentralManager : NSObject<CBCentralManagerDelegate,CBPeripheralDelegate> {
+
+@public
+
+    //方法是否处理
+    BOOL needScanForPeripherals;//是否扫描Peripherals
+    BOOL needConnectPeripheral;//是否连接Peripherals
+    BOOL needDiscoverServices;//是否发现Services
+    BOOL needDiscoverCharacteristics;//是否获取Characteristics
+    BOOL needReadValueForCharacteristic;//是否获取(更新)Characteristics的值
+    BOOL needDiscoverDescriptorsForCharacteristic;//是否获取Characteristics的描述
+    BOOL needReadValueForDescriptors;//是否获取Descriptors的值
+    
+    //一次性处理
+    BOOL oneReadValueForDescriptors;
+    
+    //方法执行时间
+    int executeTime;
+    NSTimer *connectTimer;
+    //pocket
+    NSMutableDictionary *pocket;
+
+    //主设备
+    CBCentralManager *centralManager;
+    //回叫方法
+    BabySpeaker *babySpeaker;
+    
+@private
+    //已经连接的设备
+    NSMutableArray *connectedPeripherals;
+    //已经连接的设备
+    NSMutableArray *discoverPeripherals;
+    //需要自动重连的外设
+    NSMutableArray *reConnectPeripherals;
+}
+
+
+
+
+//扫描Peripherals
+- (void)scanPeripherals;
+//连接Peripherals
+- (void)connectToPeripheral:(CBPeripheral *)peripheral;
+//断开设备连接
+- (void)cancelPeripheralConnection:(CBPeripheral *)peripheral;
+//断开所有已连接的设备
+- (void)cancelAllPeripheralsConnection;
+//停止扫描
+- (void)cancelScan;
+
+//获取当前连接的peripherals
+- (NSArray *)findConnectedPeripherals;
+
+//获取当前连接的peripheral
+- (CBPeripheral *)findConnectedPeripheral:(NSString *)peripheralName;
+
+/**
+ sometimes ever,sometimes never.  相聚有时,后会无期
+ 
+ this is center with peripheral's story
+ **/
+
+//sometimes ever:添加断开重连接的设备
+-  (void)sometimes_ever:(CBPeripheral *)peripheral ;
+//sometimes never:删除需要重连接的设备
+-  (void)sometimes_never:(CBPeripheral *)peripheral ;
+
+@end
+
+
+

+ 483 - 0
Pods/BabyBluetooth/Classes/objc/BabyCentralManager.m

@@ -0,0 +1,483 @@
+/*
+ BabyBluetooth
+ 简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
+ https://github.com/coolnameismy/BabyBluetooth
+ */
+
+//  Created by 刘彦玮 on 15/7/30.
+//  Copyright (c) 2015年 刘彦玮. All rights reserved.
+//
+
+#import "BabyCentralManager.h"
+#import "BabyCallback.h"
+
+
+
+@implementation BabyCentralManager
+
+#define currChannel [babySpeaker callbackOnCurrChannel]
+
+- (instancetype)init {
+    self = [super init];
+    if (self) {
+        
+        
+#if  __IPHONE_OS_VERSION_MIN_REQUIRED > __IPHONE_6_0
+        NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
+                                 //蓝牙power没打开时alert提示框
+                                 [NSNumber numberWithBool:YES],CBCentralManagerOptionShowPowerAlertKey,
+                                 //重设centralManager恢复的IdentifierKey
+                                 @"babyBluetoothRestore",CBCentralManagerOptionRestoreIdentifierKey,
+                                 nil];
+        
+#else
+        NSDictionary *options = nil;
+#endif
+        
+        NSArray *backgroundModes = [[[NSBundle mainBundle] infoDictionary]objectForKey:@"UIBackgroundModes"];
+        if ([backgroundModes containsObject:@"bluetooth-central"]) {
+            //后台模式
+            centralManager = [[CBCentralManager alloc]initWithDelegate:self queue:nil options:options];
+        }
+        else {
+            //非后台模式
+            centralManager = [[CBCentralManager alloc]initWithDelegate:self queue:nil];
+        }
+        
+        //pocket
+        pocket = [[NSMutableDictionary alloc]init];
+        connectedPeripherals = [[NSMutableArray alloc]init];
+        discoverPeripherals = [[NSMutableArray alloc]init];
+        reConnectPeripherals = [[NSMutableArray alloc]init];
+    }
+    return  self;
+    
+}
+
+
+
+#pragma mark - 接收到通知
+
+//扫描Peripherals
+- (void)scanPeripherals {
+    [centralManager scanForPeripheralsWithServices:[currChannel babyOptions].scanForPeripheralsWithServices options:[currChannel babyOptions].scanForPeripheralsWithOptions];
+}
+
+//连接Peripherals
+- (void)connectToPeripheral:(CBPeripheral *)peripheral{
+    [centralManager connectPeripheral:peripheral options:[currChannel babyOptions].connectPeripheralWithOptions];
+}
+
+//断开设备连接
+- (void)cancelPeripheralConnection:(CBPeripheral *)peripheral {
+    [centralManager cancelPeripheralConnection:peripheral];
+}
+
+//断开所有已连接的设备
+- (void)cancelAllPeripheralsConnection {
+    for (int i=0;i<connectedPeripherals.count;i++) {
+        [centralManager cancelPeripheralConnection:connectedPeripherals[i]];
+    }
+}
+
+//停止扫描
+- (void)cancelScan {
+    [centralManager stopScan];
+    //停止扫描callback
+    if([currChannel blockOnCancelScan]) {
+        [currChannel blockOnCancelScan](centralManager);
+    }
+    
+}
+
+#pragma mark - CBCentralManagerDelegate委托方法
+
+- (void)centralManagerDidUpdateState:(CBCentralManager *)central {
+    
+    //发送通知
+    [[NSNotificationCenter defaultCenter]postNotificationName:BabyNotificationAtCentralManagerDidUpdateState object:@{@"central":central}];
+    
+    switch (central.state) {
+        case CBCentralManagerStateUnknown:
+            BabyLog(@">>>CBCentralManagerStateUnknown");
+            break;
+        case CBCentralManagerStateResetting:
+            BabyLog(@">>>CBCentralManagerStateResetting");
+            break;
+        case CBCentralManagerStateUnsupported:
+            BabyLog(@">>>CBCentralManagerStateUnsupported");
+            break;
+        case CBCentralManagerStateUnauthorized:
+            BabyLog(@">>>CBCentralManagerStateUnauthorized");
+            break;
+        case CBCentralManagerStatePoweredOff:
+            BabyLog(@">>>CBCentralManagerStatePoweredOff");
+            break;
+        case CBCentralManagerStatePoweredOn:
+            BabyLog(@">>>CBCentralManagerStatePoweredOn");
+            [[NSNotificationCenter defaultCenter]postNotificationName:BabyNotificationAtCentralManagerEnable object:@{@"central":central}];
+            break;
+        default:
+            break;
+    }
+    //状态改变callback
+    if ([currChannel blockOnCentralManagerDidUpdateState]) {
+        [currChannel blockOnCentralManagerDidUpdateState](central);
+    }
+}
+
+- (void)centralManager:(CBCentralManager *)central willRestoreState:(NSDictionary *)dict {
+    
+}
+
+//扫描到Peripherals
+- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI {
+    
+    //日志
+    //BabyLog(@"当扫描到设备:%@",peripheral.name);
+    [self addDiscoverPeripheral:peripheral];
+    
+    //发出通知
+    [[NSNotificationCenter defaultCenter]postNotificationName:BabyNotificationAtDidDiscoverPeripheral
+                                                       object:@{@"central":central,@"peripheral":peripheral,@"advertisementData":advertisementData,@"RSSI":RSSI}];
+    //扫描到设备callback
+    if ([currChannel filterOnDiscoverPeripherals]) {
+        if ([currChannel filterOnDiscoverPeripherals](peripheral.name,advertisementData,RSSI)) {
+            if ([currChannel blockOnDiscoverPeripherals]) {
+                [[babySpeaker callbackOnCurrChannel] blockOnDiscoverPeripherals](central,peripheral,advertisementData,RSSI);
+            }
+        }
+    }
+    
+    //处理连接设备
+    if (needConnectPeripheral) {
+        if ([currChannel filterOnconnectToPeripherals](peripheral.name,advertisementData,RSSI)) {
+            [centralManager connectPeripheral:peripheral options:[currChannel babyOptions].connectPeripheralWithOptions];
+            //开一个定时器监控连接超时的情况
+            connectTimer = [NSTimer scheduledTimerWithTimeInterval:5.0f target:self selector:@selector(disconnect:) userInfo:peripheral repeats:NO];
+        }
+    }
+}
+
+//停止扫描
+- (void)disconnect:(id)sender {
+    [centralManager stopScan];
+}
+
+//连接到Peripherals-成功
+- (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral {
+    
+    //发出通知
+    [[NSNotificationCenter defaultCenter]postNotificationName:BabyNotificationAtDidConnectPeripheral
+                                                       object:@{@"central":central,@"peripheral":peripheral}];
+    
+    //设置委托
+    [peripheral setDelegate:self];
+    
+    //BabyLog(@">>>连接到名称为(%@)的设备-成功",peripheral.name);
+    [connectTimer invalidate];//停止时钟
+    [self addPeripheral:peripheral];
+    
+    //执行回叫
+    //扫描到设备callback
+    if ([currChannel blockOnConnectedPeripheral]) {
+        [currChannel blockOnConnectedPeripheral](central,peripheral);
+    }
+    
+    //扫描外设的服务
+    if (needDiscoverServices) {
+        [peripheral discoverServices:[currChannel babyOptions].discoverWithServices];
+        //discoverIncludedServices
+    }
+    
+}
+
+//连接到Peripherals-失败
+- (void)centralManager:(CBCentralManager *)central didFailToConnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error {
+    //发出通知
+    [[NSNotificationCenter defaultCenter]postNotificationName:BabyNotificationAtDidFailToConnectPeripheral
+                                                       object:@{@"central":central,@"peripheral":peripheral,@"error":error?error:@""}];
+ 
+    //    BabyLog(@">>>连接到名称为(%@)的设备-失败,原因:%@",[peripheral name],[error localizedDescription]);
+    if ([currChannel blockOnFailToConnect]) {
+        [currChannel blockOnFailToConnect](central,peripheral,error);
+    }
+}
+
+//Peripherals断开连接
+- (void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error {
+    //发出通知
+    [[NSNotificationCenter defaultCenter]postNotificationName:BabyNotificationAtDidDisconnectPeripheral
+                                                       object:@{@"central":central,@"peripheral":peripheral,@"error":error?error:@""}];
+    
+    //    BabyLog(@">>>外设连接断开连接 %@: %@\n", [peripheral name], [error localizedDescription]);
+    if (error)
+    {
+        BabyLog(@">>> didDisconnectPeripheral for %@ with error: %@", peripheral.name, [error localizedDescription]);
+    }
+    
+    [self deletePeripheral:peripheral];
+    if ([currChannel blockOnDisconnect]) {
+        [currChannel blockOnDisconnect](central,peripheral,error);
+    }
+    
+    //判断是否全部链接都已经段开,调用blockOnCancelAllPeripheralsConnection委托
+    if ([self findConnectedPeripherals].count == 0) {
+        //停止扫描callback
+        if ([currChannel blockOnCancelAllPeripheralsConnection]) {
+            [currChannel blockOnCancelAllPeripheralsConnection](centralManager);
+        }
+        //    BabyLog(@">>> stopConnectAllPerihperals");
+    }
+    
+    //检查并重新连接需要重连的设备
+    if ([reConnectPeripherals containsObject:peripheral]) {
+        [self connectToPeripheral:peripheral];
+    }
+}
+
+//扫描到服务
+- (void)peripheral:(CBPeripheral *)peripheral didDiscoverServices:(NSError *)error {
+    
+    //发出通知
+    [[NSNotificationCenter defaultCenter]postNotificationName:BabyNotificationAtDidDiscoverServices
+                                                       object:@{@"peripheral":peripheral,@"error":error?error:@""}];
+    
+    //  BabyLog(@">>>扫描到服务:%@",peripheral.services);
+    if (error) {
+        BabyLog(@">>>didDiscoverServices for %@ with error: %@", peripheral.name, [error localizedDescription]);
+    }
+    //回叫block
+    if ([currChannel blockOnDiscoverServices]) {
+        [currChannel blockOnDiscoverServices](peripheral,error);
+    }
+    
+    //discover characteristics
+    if (needDiscoverCharacteristics) {
+        for (CBService *service in peripheral.services) {
+            [peripheral discoverCharacteristics:[currChannel babyOptions].discoverWithCharacteristics forService:service];
+        }
+    }
+}
+
+//发现服务的Characteristics
+- (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error {
+
+    //发出通知
+    [[NSNotificationCenter defaultCenter]postNotificationName:BabyNotificationAtDidDiscoverCharacteristicsForService
+                                                       object:@{@"peripheral":peripheral,@"service":service,@"error":error?error:@""}];
+    
+    
+    if (error) {
+        BabyLog(@"error didDiscoverCharacteristicsForService for %@ with error: %@", service.UUID, [error localizedDescription]);
+        //        return;
+    }
+    //回叫block
+    if ([currChannel blockOnDiscoverCharacteristics]) {
+        [currChannel blockOnDiscoverCharacteristics](peripheral,service,error);
+    }
+    
+    //如果需要更新Characteristic的值
+    if (needReadValueForCharacteristic) {
+        for (CBCharacteristic *characteristic in service.characteristics) {
+            [peripheral readValueForCharacteristic:characteristic];
+            //判断读写权限
+            //            if (characteristic.properties & CBCharacteristicPropertyRead ) {
+            //                [peripheral readValueForCharacteristic:characteristic];
+            //            }
+        }
+    }
+    
+    //如果搜索Characteristic的Descriptors
+    if (needDiscoverDescriptorsForCharacteristic) {
+        for (CBCharacteristic *characteristic in service.characteristics) {
+            [peripheral discoverDescriptorsForCharacteristic:characteristic];
+        }
+    }
+}
+
+//读取Characteristics的值
+- (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error {
+    
+    //发出通知
+    [[NSNotificationCenter defaultCenter]postNotificationName:BabyNotificationAtDidUpdateValueForCharacteristic
+                                                       object:@{@"peripheral":peripheral,@"characteristic":characteristic,@"error":error?error:@""}];
+    
+    if (error) {
+        BabyLog(@"error didUpdateValueForCharacteristic %@ with error: %@", characteristic.UUID, [error localizedDescription]);
+        //        return;
+    }
+    //查找字段订阅
+    if ([babySpeaker notifyCallback:characteristic]) {
+        [babySpeaker notifyCallback:characteristic](peripheral,characteristic,error);
+        return;
+    }
+    //回叫block
+    if ([currChannel blockOnReadValueForCharacteristic]) {
+        [currChannel blockOnReadValueForCharacteristic](peripheral,characteristic,error);
+    }
+}
+
+//发现Characteristics的Descriptors
+- (void)peripheral:(CBPeripheral *)peripheral didDiscoverDescriptorsForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error {
+    
+    if (error) {
+        BabyLog(@"error Discovered DescriptorsForCharacteristic for %@ with error: %@", characteristic.UUID, [error localizedDescription]);
+        //        return;
+    }
+    //回叫block
+    if ([currChannel blockOnDiscoverDescriptorsForCharacteristic]) {
+        [currChannel blockOnDiscoverDescriptorsForCharacteristic](peripheral,characteristic,error);
+    }
+    //如果需要更新Characteristic的Descriptors
+    if (needReadValueForDescriptors) {
+        for (CBDescriptor *d in characteristic.descriptors) {
+            [peripheral readValueForDescriptor:d];
+        }
+    }
+    
+    //执行一次的方法
+    if (oneReadValueForDescriptors) {
+        for (CBDescriptor *d in characteristic.descriptors) {
+            [peripheral readValueForDescriptor:d];
+        }
+        oneReadValueForDescriptors = NO;
+    }
+}
+
+//读取Characteristics的Descriptors的值
+- (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForDescriptor:(CBDescriptor *)descriptor error:(NSError *)error {
+    
+    
+    if (error) {
+        BabyLog(@"error didUpdateValueForDescriptor  for %@ with error: %@", descriptor.UUID, [error localizedDescription]);
+        //        return;
+    }
+    //回叫block
+    if ([currChannel blockOnReadValueForDescriptors]) {
+        [currChannel blockOnReadValueForDescriptors](peripheral,descriptor,error);
+    }
+}
+
+- (void)peripheral:(CBPeripheral *)peripheral didWriteValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error {
+    
+    [[NSNotificationCenter defaultCenter]postNotificationName:BabyNotificationAtDidWriteValueForCharacteristic object:@{@"characteristic":characteristic,@"error":error?error:@""}];
+    
+    //    BabyLog(@">>>didWriteValueForCharacteristic");
+    //    BabyLog(@">>>uuid:%@,new value:%@",characteristic.UUID,characteristic.value);
+    if ([currChannel blockOnDidWriteValueForCharacteristic]) {
+        [currChannel blockOnDidWriteValueForCharacteristic](characteristic,error);
+    }
+}
+
+- (void)peripheral:(CBPeripheral *)peripheral didWriteValueForDescriptor:(CBDescriptor *)descriptor error:(NSError *)error {
+    //    BabyLog(@">>>didWriteValueForCharacteristic");
+    //    BabyLog(@">>>uuid:%@,new value:%@",descriptor.UUID,descriptor.value);
+    if ([currChannel blockOnDidWriteValueForDescriptor]) {
+        [currChannel blockOnDidWriteValueForDescriptor](descriptor,error);
+    }
+}
+
+//characteristic.isNotifying 状态改变
+- (void)peripheral:(CBPeripheral *)peripheral didUpdateNotificationStateForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error {
+    
+    [[NSNotificationCenter defaultCenter]postNotificationName:BabyNotificationAtDidUpdateNotificationStateForCharacteristic object:@{@"characteristic":characteristic,@"error":error?error:@""}];
+    
+    BabyLog(@">>>didUpdateNotificationStateForCharacteristic");
+    BabyLog(@">>>uuid:%@,isNotifying:%@",characteristic.UUID,characteristic.isNotifying?@"isNotifying":@"Notifying");
+    if ([currChannel blockOnDidUpdateNotificationStateForCharacteristic]) {
+        [currChannel blockOnDidUpdateNotificationStateForCharacteristic](characteristic,error);
+    }
+}
+
+- (void)peripheral:(CBPeripheral *)peripheral didDiscoverIncludedServicesForService:(CBService *)service error:(NSError *)error {
+    if ([currChannel blockOnDidDiscoverIncludedServicesForService]) {
+        [currChannel blockOnDidDiscoverIncludedServicesForService](service,error);
+    }
+}
+
+# if  __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_8_0
+- (void)peripheralDidUpdateRSSI:(CBPeripheral *)peripheral error:(nullable NSError *)error {
+    [[NSNotificationCenter defaultCenter]postNotificationName:BabyNotificationAtDidReadRSSI object:@{@"peripheral":peripheral,@"RSSI":peripheral.RSSI,@"error":error?error:@""}];
+    
+    BabyLog(@">>>peripheralDidUpdateRSSI -> RSSI:%@",peripheral.RSSI);
+    if ([currChannel blockOnDidReadRSSI]) {
+        [currChannel blockOnDidReadRSSI](peripheral.RSSI,error);
+    }
+}
+#else
+- (void)peripheral:(CBPeripheral *)peripheral didReadRSSI:(NSNumber *)RSSI error:(NSError *)error {
+    [[NSNotificationCenter defaultCenter]postNotificationName:BabyNotificationAtDidReadRSSI object:@{@"peripheral":peripheral,@"RSSI":RSSI,@"error":error?error:@""}];
+    
+    BabyLog(@">>>peripheralDidUpdateRSSI -> RSSI:%@",RSSI);
+    if ([currChannel blockOnDidReadRSSI]) {
+        [currChannel blockOnDidReadRSSI](RSSI,error);
+    }
+}
+#endif
+
+- (void)peripheralDidUpdateName:(CBPeripheral *)peripheral {
+    if ([currChannel blockOnDidUpdateName]) {
+        [currChannel blockOnDidUpdateName](peripheral);
+    }
+}
+
+- (void)peripheral:(CBPeripheral *)peripheral didModifyServices:(NSArray *)invalidatedServices {
+    if ([currChannel blockOnDidModifyServices]) {
+        [currChannel blockOnDidModifyServices](peripheral,invalidatedServices);
+    }
+}
+
+/**
+ sometimes ever,sometimes never.  相聚有时,后会无期
+ 
+ this is center with peripheral's story
+ **/
+
+//sometimes ever:添加断开重连接的设备
+-  (void)sometimes_ever:(CBPeripheral *)peripheral {
+    if (![reConnectPeripherals containsObject:peripheral]) {
+        [reConnectPeripherals addObject:peripheral];
+    }
+}
+//sometimes never:删除需要重连接的设备
+-  (void)sometimes_never:(CBPeripheral *)peripheral {
+    [reConnectPeripherals removeObject:peripheral];
+}
+
+#pragma mark - 私有方法
+
+
+#pragma mark - 设备list管理
+
+- (void)addDiscoverPeripheral:(CBPeripheral *)peripheral{
+    if (![discoverPeripherals containsObject:peripheral]) {
+        [discoverPeripherals addObject:peripheral];
+    }
+}
+
+- (void)addPeripheral:(CBPeripheral *)peripheral {
+    if (![connectedPeripherals containsObject:peripheral]) {
+        [connectedPeripherals addObject:peripheral];
+    }
+}
+
+- (void)deletePeripheral:(CBPeripheral *)peripheral{
+    [connectedPeripherals removeObject:peripheral];
+}
+
+- (CBPeripheral *)findConnectedPeripheral:(NSString *)peripheralName {
+    for (CBPeripheral *p in connectedPeripherals) {
+        if ([p.name isEqualToString:peripheralName]) {
+            return p;
+        }
+    }
+    return nil;
+}
+
+- (NSArray *)findConnectedPeripherals{
+    return connectedPeripherals;
+}
+
+
+@end

+ 77 - 0
Pods/BabyBluetooth/Classes/objc/BabyDefine.h

@@ -0,0 +1,77 @@
+/*
+ BabyBluetooth
+ 简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
+ https://github.com/coolnameismy/BabyBluetooth
+ 
+@brief  预定义一些库的执行行为和配置
+ 
+ */
+
+// Created by 刘彦玮 on 6/4/19.
+//  Copyright © 2016年 liuyanwei. All rights reserved.
+//  
+
+#import <Foundation/Foundation.h>
+
+
+# pragma mark - baby 行为定义
+
+//Baby if show log 是否打印日志,默认1:打印 ,0:不打印
+#define KBABY_IS_SHOW_LOG 1
+
+//CBcentralManager等待设备打开次数
+# define KBABY_CENTRAL_MANAGER_INIT_WAIT_TIMES 5
+
+//CBcentralManager等待设备打开间隔时间
+# define KBABY_CENTRAL_MANAGER_INIT_WAIT_SECOND 2.0
+
+//BabyRhythm默认心跳时间间隔
+#define KBABYRHYTHM_BEATS_DEFAULT_INTERVAL 3;
+
+//Baby默认链式方法channel名称
+#define KBABY_DETAULT_CHANNEL @"babyDefault"
+
+# pragma mark - baby通知
+
+//蓝牙系统通知
+//centralManager status did change notification
+#define BabyNotificationAtCentralManagerDidUpdateState @"BabyNotificationAtCentralManagerDidUpdateState"
+//did discover peripheral notification
+#define BabyNotificationAtDidDiscoverPeripheral @"BabyNotificationAtDidDiscoverPeripheral"
+//did connection peripheral notification
+#define BabyNotificationAtDidConnectPeripheral @"BabyNotificationAtDidConnectPeripheral"
+//did filed connect peripheral notification
+#define BabyNotificationAtDidFailToConnectPeripheral @"BabyNotificationAtDidFailToConnectPeripheral"
+//did disconnect peripheral notification
+#define BabyNotificationAtDidDisconnectPeripheral @"BabyNotificationAtDidDisconnectPeripheral"
+//did discover service notification
+#define BabyNotificationAtDidDiscoverServices @"BabyNotificationAtDidDiscoverServices"
+//did discover characteristics notification
+#define BabyNotificationAtDidDiscoverCharacteristicsForService @"BabyNotificationAtDidDiscoverCharacteristicsForService"
+//did read or notify characteristic when received value  notification
+#define BabyNotificationAtDidUpdateValueForCharacteristic @"BabyNotificationAtDidUpdateValueForCharacteristic"
+//did write characteristic and response value notification
+#define BabyNotificationAtDidWriteValueForCharacteristic @"BabyNotificationAtDidWriteValueForCharacteristic"
+//did change characteristis notify status notification
+#define BabyNotificationAtDidUpdateNotificationStateForCharacteristic @"BabyNotificationAtDidUpdateNotificationStateForCharacteristic"
+//did read rssi and receiced value notification
+#define BabyNotificationAtDidReadRSSI @"BabyNotificationAtDidReadRSSI"
+
+//蓝牙扩展通知
+// did centralManager enable notification
+#define BabyNotificationAtCentralManagerEnable @"BabyNotificationAtCentralManagerEnable"
+
+
+
+# pragma mark - baby 定义的方法
+
+//Baby log
+#define BabyLog(fmt, ...) if(KBABY_IS_SHOW_LOG) { NSLog(fmt,##__VA_ARGS__); }
+
+
+
+
+
+@interface BabyDefine : NSObject
+
+@end

+ 16 - 0
Pods/BabyBluetooth/Classes/objc/BabyDefine.m

@@ -0,0 +1,16 @@
+//
+//  BabyBlueDefine.m
+//  BabyTestProject
+//
+//  Created by xuanyan.lyw on 16/4/19.
+//  Copyright © 2016年 liuyanwei. All rights reserved.
+//
+
+#import "BabyDefine.h"
+
+
+
+
+@implementation BabyDefine
+
+@end

+ 67 - 0
Pods/BabyBluetooth/Classes/objc/BabyOptions.h

@@ -0,0 +1,67 @@
+/*
+ BabyBluetooth
+ 简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
+ https://github.com/coolnameismy/BabyBluetooth
+ 
+ @brief  babybluetooth 封装蓝牙外设模式的运行时参数,可以实现后台模式,重复接收广播,查找service参数,查找characteristic参数
+ 
+ */
+
+//  Created by 刘彦玮 on 15/9/27.
+//  Copyright © 2015年 刘彦玮. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import <CoreBluetooth/CoreBluetooth.h>
+
+@interface BabyOptions : NSObject
+
+#pragma mark - 属性
+/*!
+ * 扫描参数,centralManager:scanForPeripheralsWithServices:self.scanForPeripheralsWithServices options:self.scanForPeripheralsWithOptions
+ * @param An optional dictionary specifying options for the scan.
+ *  @see                centralManager:scanForPeripheralsWithServices
+ *  @seealso            CBCentralManagerScanOptionAllowDuplicatesKey :忽略同一个Peripheral端的多个发现事件被聚合成一个发现事件
+ *	@seealso			CBCentralManagerScanOptionSolicitedServiceUUIDsKey
+ */
+@property (nonatomic, copy) NSDictionary *scanForPeripheralsWithOptions;
+
+/*!
+*  连接设备的参数
+*  @method connectPeripheral:options:
+*  @param              An optional dictionary specifying connection behavior options.
+*  @see                centralManager:didConnectPeripheral:
+*  @see                centralManager:didFailToConnectPeripheral:error:
+*  @seealso            CBConnectPeripheralOptionNotifyOnConnectionKey
+*  @seealso            CBConnectPeripheralOptionNotifyOnDisconnectionKey
+*  @seealso            CBConnectPeripheralOptionNotifyOnNotificationKey
+*/
+@property (nonatomic, copy) NSDictionary *connectPeripheralWithOptions;
+
+
+
+/*!
+ * 扫描参数,centralManager:scanForPeripheralsWithServices:self.scanForPeripheralsWithServices options:self.scanForPeripheralsWithOptions
+ *@param serviceUUIDs A list of <code>CBUUID</code> objects representing the service(s) to scan for.
+ *@see                centralManager:scanForPeripheralsWithServices
+ */
+@property (nonatomic, copy) NSArray *scanForPeripheralsWithServices;
+
+// [peripheral discoverServices:self.discoverWithServices];
+@property (nonatomic, copy) NSArray *discoverWithServices;
+
+// [peripheral discoverCharacteristics:self.discoverWithCharacteristics forService:service];
+@property (nonatomic, copy) NSArray *discoverWithCharacteristics;
+
+
+#pragma mark - 构造方法
+- (instancetype)initWithscanForPeripheralsWithOptions:(NSDictionary *)scanForPeripheralsWithOptions
+                        connectPeripheralWithOptions:(NSDictionary *)connectPeripheralWithOptions;
+
+- (instancetype)initWithscanForPeripheralsWithOptions:(NSDictionary *)scanForPeripheralsWithOptions
+                        connectPeripheralWithOptions:(NSDictionary *)connectPeripheralWithOptions
+                      scanForPeripheralsWithServices:(NSArray *)scanForPeripheralsWithServices
+                                discoverWithServices:(NSArray *)discoverWithServices
+                         discoverWithCharacteristics:(NSArray *)discoverWithCharacteristics;
+
+@end

+ 51 - 0
Pods/BabyBluetooth/Classes/objc/BabyOptions.m

@@ -0,0 +1,51 @@
+//
+//  BabyClothes.m
+//  BabyBluetoothAppDemo
+//
+//  Created by 刘彦玮 on 15/9/27.
+//  Copyright © 2015年 刘彦玮. All rights reserved.
+//
+
+#import "BabyOptions.h"
+
+@implementation BabyOptions
+
+- (instancetype)init {
+    self = [super init];
+    if (self) {
+      _scanForPeripheralsWithOptions = nil;
+      _connectPeripheralWithOptions = nil;
+      _scanForPeripheralsWithServices = nil;
+      _discoverWithServices = nil;
+      _discoverWithCharacteristics = nil;
+    }
+    return self;
+}
+
+- (instancetype)initWithscanForPeripheralsWithOptions:(NSDictionary *)scanForPeripheralsWithOptions
+        connectPeripheralWithOptions:(NSDictionary *)connectPeripheralWithOptions
+{
+    self = [super init];
+    if (self) {
+        [self setScanForPeripheralsWithOptions:scanForPeripheralsWithOptions];
+        [self setConnectPeripheralWithOptions:connectPeripheralWithOptions];
+    }
+    return self;
+}
+
+- (instancetype)initWithscanForPeripheralsWithOptions:(NSDictionary *)scanForPeripheralsWithOptions
+                        connectPeripheralWithOptions:(NSDictionary *)connectPeripheralWithOptions
+                      scanForPeripheralsWithServices:(NSArray *)scanForPeripheralsWithServices
+                      discoverWithServices:(NSArray *)discoverWithServices
+                      discoverWithCharacteristics:(NSArray *)discoverWithCharacteristics
+{
+    self = [self initWithscanForPeripheralsWithOptions:scanForPeripheralsWithOptions connectPeripheralWithOptions:connectPeripheralWithOptions];
+    if (self) {
+        [self setScanForPeripheralsWithServices:scanForPeripheralsWithServices];
+        [self setDiscoverWithServices:discoverWithServices];
+        [self setDiscoverWithCharacteristics:discoverWithCharacteristics];
+    }
+    return self;
+}
+
+@end

+ 74 - 0
Pods/BabyBluetooth/Classes/objc/BabyPeripheralManager.h

@@ -0,0 +1,74 @@
+/*
+ BabyBluetooth
+ 简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
+ https://github.com/coolnameismy/BabyBluetooth
+ 
+ @brief  蓝牙外设模式实现类
+ 
+ */
+
+
+//  Created by 刘彦玮 on 15/12/12.
+//  Copyright © 2015年 刘彦玮. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import <CoreBluetooth/CoreBluetooth.h>
+#import "BabyToy.h"
+#import "BabySpeaker.h"
+
+
+@interface BabyPeripheralManager : NSObject<CBPeripheralManagerDelegate> {
+
+@public
+    //回叫方法
+    BabySpeaker *babySpeaker;
+}
+
+/**
+ 添加服务
+ */
+- (BabyPeripheralManager *(^)(NSArray *array))addServices;
+
+/**
+启动广播
+ */
+- (BabyPeripheralManager *(^)())startAdvertising;
+
+//外设管理器
+@property (nonatomic, strong) CBPeripheralManager *peripheralManager;
+@property (nonatomic, copy) NSString *localName;
+@property (nonatomic, strong) NSMutableArray *services;
+
+@end
+
+
+/**
+ *  构造Characteristic,并加入service
+ *  service:CBService
+ 
+ *  param`ter for properties :option 'r' | 'w' | 'n' or combination
+ *	r                       CBCharacteristicPropertyRead
+ *	w                       CBCharacteristicPropertyWrite
+ *	n                       CBCharacteristicPropertyNotify
+ *  default value is rw     Read-Write
+
+ *  paramter for descriptor:be uesd descriptor for characteristic
+ */
+
+void makeCharacteristicToService(CBMutableService *service,NSString *UUID,NSString *properties,NSString *descriptor);
+
+/**
+ *  构造一个包含初始值的Characteristic,并加入service,包含了初值的characteristic必须设置permissions和properties都为只读
+ *  make characteristic then add to service, a static characteristic mean it has a initial value .according apple rule, it must set properties and permissions to CBCharacteristicPropertyRead and CBAttributePermissionsReadable
+*/
+void makeStaticCharacteristicToService(CBMutableService *service,NSString *UUID,NSString *descriptor,NSData *data);
+/**
+ 生成CBService
+ */
+CBMutableService* makeCBService(NSString *UUID);
+
+/**
+ 生成UUID
+ */
+NSString* genUUID();

+ 234 - 0
Pods/BabyBluetooth/Classes/objc/BabyPeripheralManager.m

@@ -0,0 +1,234 @@
+//
+//  BabyPeripheralManager.m
+//  BluetoothStubOnIOS
+//
+//  Created by 刘彦玮 on 15/12/12.
+//  Copyright © 2015年 刘彦玮. All rights reserved.
+//
+
+#import "BabyPeripheralManager.h"
+#import "BabyDefine.h"
+
+#define callbackBlock(...) if ([[babySpeaker callback] __VA_ARGS__])   [[babySpeaker callback] __VA_ARGS__ ]
+
+@implementation BabyPeripheralManager {
+    int PERIPHERAL_MANAGER_INIT_WAIT_TIMES;
+    int didAddServices;
+    NSTimer *addServiceTask;
+}
+
+- (instancetype)init {
+    self = [super init];
+    if (self) {
+        _localName = @"baby-default-name";
+        _peripheralManager = [[CBPeripheralManager alloc]initWithDelegate:self queue:nil options:nil];
+    }
+    return  self;    
+}
+
+
+- (BabyPeripheralManager *(^)())startAdvertising {
+    return ^BabyPeripheralManager *() {
+        
+        if ([self canStartAdvertising]) {
+            PERIPHERAL_MANAGER_INIT_WAIT_TIMES = 0;
+            NSMutableArray *UUIDS = [NSMutableArray array];
+            for (CBMutableService *s in _services) {
+                [UUIDS addObject:s.UUID];
+            }
+            //启动广播
+            [_peripheralManager startAdvertising:
+             @{
+               CBAdvertisementDataServiceUUIDsKey :  UUIDS
+               ,CBAdvertisementDataLocalNameKey : _localName
+             }];
+        }
+        else {
+            PERIPHERAL_MANAGER_INIT_WAIT_TIMES++;
+            if (PERIPHERAL_MANAGER_INIT_WAIT_TIMES > 5) {
+                BabyLog(@">>>error: 第%d次等待peripheralManager打开任然失败,请检查蓝牙设备是否可用",PERIPHERAL_MANAGER_INIT_WAIT_TIMES);
+            }
+            dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 3.0 * NSEC_PER_SEC);
+            dispatch_after(popTime, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+                self.startAdvertising();
+            });
+            BabyLog(@">>> 第%d次等待peripheralManager打开",PERIPHERAL_MANAGER_INIT_WAIT_TIMES);
+        }
+        
+        return self;
+    };
+}
+
+- (BOOL)canStartAdvertising {
+    if (_peripheralManager.state != CBPeripheralManagerStatePoweredOn) {
+        return NO;
+    }
+    if (didAddServices != _services.count) {
+        return NO;
+    }
+    return YES;
+}
+
+- (BOOL)isPoweredOn {
+    if (_peripheralManager.state != CBPeripheralManagerStatePoweredOn) {
+        return NO;
+    }
+    return YES;
+}
+
+- (BabyPeripheralManager *(^)(NSArray *array))addServices {
+    return ^BabyPeripheralManager*(NSArray *array) {
+        _services = [NSMutableArray arrayWithArray:array];
+        [self addServicesToPeripheral];
+        return  self;
+    };
+}
+
+- (void)addServicesToPeripheral {
+    if ([self isPoweredOn]) {
+        for (CBMutableService *s in _services) {
+            [_peripheralManager addService:s];
+        }
+    }
+    else {
+        [addServiceTask setFireDate:[NSDate distantPast]];
+        addServiceTask = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(addServicesToPeripheral) userInfo:nil repeats:NO];
+    }
+}
+
+#pragma mark - peripheralManager delegate
+
+- (void)peripheralManagerDidUpdateState:(CBPeripheralManager *)peripheral {
+    switch (peripheral.state) {
+        case CBPeripheralManagerStateUnknown:
+            BabyLog(@">>>CBPeripheralManagerStateUnknown");
+            break;
+        case CBPeripheralManagerStateResetting:
+            BabyLog(@">>>CBPeripheralManagerStateResetting");
+            break;
+        case CBPeripheralManagerStateUnsupported:
+            BabyLog(@">>>CBPeripheralManagerStateUnsupported");
+            break;
+        case CBPeripheralManagerStateUnauthorized:
+            BabyLog(@">>>CBPeripheralManagerStateUnauthorized");
+            break;
+        case CBPeripheralManagerStatePoweredOff:
+            BabyLog(@">>>CBPeripheralManagerStatePoweredOff");
+            break;
+        case CBPeripheralManagerStatePoweredOn:
+            BabyLog(@">>>CBPeripheralManagerStatePoweredOn");
+            //发送centralManagerDidUpdateState通知
+            [[NSNotificationCenter defaultCenter]postNotificationName:@"CBPeripheralManagerStatePoweredOn" object:nil];
+            break;
+        default:
+            break;
+    }
+
+//    if([babySpeaker callback] blockOnPeripheralModelDidUpdateState) {
+//        [currChannel blockOnCancelScan](centralManager);
+//    }
+    callbackBlock(blockOnPeripheralModelDidUpdateState)(peripheral);
+}
+
+
+- (void)peripheralManager:(CBPeripheralManager *)peripheral didAddService:(CBService *)service error:(NSError *)error {
+    didAddServices++;
+    callbackBlock(blockOnPeripheralModelDidAddService)(peripheral,service,error);
+}
+
+- (void)peripheralManagerDidStartAdvertising:(CBPeripheralManager *)peripheral error:(NSError *)error {
+    callbackBlock(blockOnPeripheralModelDidStartAdvertising)(peripheral,error);
+}
+
+- (void)peripheralManager:(CBPeripheralManager *)peripheral didReceiveReadRequest:(CBATTRequest *)request {
+    callbackBlock(blockOnPeripheralModelDidReceiveReadRequest)(peripheral, request);
+}
+
+- (void)peripheralManager:(CBPeripheralManager *)peripheral didReceiveWriteRequests:(NSArray *)requests {
+    callbackBlock(blockOnPeripheralModelDidReceiveWriteRequests)(peripheral,requests);
+}
+
+- (void)peripheralManager:(CBPeripheralManager *)peripheral central:(CBCentral *)central didSubscribeToCharacteristic:(CBCharacteristic *)characteristic {
+    callbackBlock(blockOnPeripheralModelDidSubscribeToCharacteristic)(peripheral,central,characteristic);
+}
+
+- (void)peripheralManager:(CBPeripheralManager *)peripheral central:(CBCentral *)central didUnsubscribeFromCharacteristic:(CBCharacteristic *)characteristic {
+    callbackBlock(blockOnPeripheralModelDidUnSubscribeToCharacteristic)(peripheral,central,characteristic);
+}
+
+
+@end
+
+void makeCharacteristicToService(CBMutableService *service,NSString *UUID,NSString *properties,NSString *descriptor) {
+
+    //paramter for properties
+    CBCharacteristicProperties prop = 0x00;
+    if ([properties containsString:@"r"]) {
+        prop =  prop | CBCharacteristicPropertyRead;
+    }
+    if ([properties containsString:@"w"]) {
+        prop =  prop | CBCharacteristicPropertyWrite;
+    }
+    if ([properties containsString:@"n"]) {
+        prop =  prop | CBCharacteristicPropertyNotify;
+    }
+    if (properties == nil || [properties isEqualToString:@""]) {
+        prop = CBCharacteristicPropertyRead | CBCharacteristicPropertyWrite;
+    }
+
+    CBMutableCharacteristic *c = [[CBMutableCharacteristic alloc]initWithType:[CBUUID UUIDWithString:UUID] properties:prop  value:nil permissions:CBAttributePermissionsReadable | CBAttributePermissionsWriteable];
+    
+    //paramter for descriptor
+    if (!(descriptor == nil || [descriptor isEqualToString:@""])) {
+        //c设置description对应的haracteristics字段描述
+        CBUUID *CBUUIDCharacteristicUserDescriptionStringUUID = [CBUUID UUIDWithString:CBUUIDCharacteristicUserDescriptionString];
+        CBMutableDescriptor *desc = [[CBMutableDescriptor alloc]initWithType: CBUUIDCharacteristicUserDescriptionStringUUID value:descriptor];
+        [c setDescriptors:@[desc]];
+    }
+    
+    if (!service.characteristics) {
+        service.characteristics = @[];
+    }
+    NSMutableArray *cs = [service.characteristics mutableCopy];
+    [cs addObject:c];
+    service.characteristics = [cs copy];
+}
+void makeStaticCharacteristicToService(CBMutableService *service,NSString *UUID,NSString *descriptor,NSData *data) {
+    
+    CBMutableCharacteristic *c = [[CBMutableCharacteristic alloc]initWithType:[CBUUID UUIDWithString:UUID] properties:CBCharacteristicPropertyRead  value:data permissions:CBAttributePermissionsReadable];
+    
+    //paramter for descriptor
+    if (!(descriptor == nil || [descriptor isEqualToString:@""])) {
+        //c设置description对应的haracteristics字段描述
+        CBUUID *CBUUIDCharacteristicUserDescriptionStringUUID = [CBUUID UUIDWithString:CBUUIDCharacteristicUserDescriptionString];
+        CBMutableDescriptor *desc = [[CBMutableDescriptor alloc]initWithType: CBUUIDCharacteristicUserDescriptionStringUUID value:descriptor];
+        [c setDescriptors:@[desc]];
+    }
+    
+    if (!service.characteristics) {
+        service.characteristics = @[];
+    }
+    NSMutableArray *cs = [service.characteristics mutableCopy];
+    [cs addObject:c];
+    service.characteristics = [cs copy];
+}
+
+
+CBMutableService* makeCBService(NSString *UUID)
+{
+    CBMutableService *s = [[CBMutableService alloc]initWithType:[CBUUID UUIDWithString:UUID] primary:YES];
+    return s;
+}
+
+NSString * genUUID()
+{
+    CFUUIDRef uuid_ref = CFUUIDCreate(NULL);
+    CFStringRef uuid_string_ref= CFUUIDCreateString(NULL, uuid_ref);
+    
+    CFRelease(uuid_ref);
+    NSString *uuid = [NSString stringWithString:(__bridge NSString*)uuid_string_ref];
+    
+    CFRelease(uuid_string_ref);
+    return uuid;
+}
+

+ 47 - 0
Pods/BabyBluetooth/Classes/objc/BabyRhythm.h

@@ -0,0 +1,47 @@
+/*
+ BabyBluetooth
+ 简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
+ https://github.com/coolnameismy/BabyBluetooth
+ 
+ @brief  babybluetooth Rhythm用于检测蓝牙的任务执行情况,处理复杂的蓝牙流程操作
+ 
+ */
+//
+//  Created by ZTELiuyw on 15/9/15.
+//  Copyright (c) 2015年 刘彦玮. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "BabyDefine.h"
+
+
+@interface BabyRhythm : NSObject
+
+
+typedef void (^BBBeatsBreakBlock)(BabyRhythm *bry);
+typedef void (^BBBeatsOverBlock)(BabyRhythm *bry);
+
+//timer for beats
+@property (nonatomic, strong) NSTimer *beatsTimer;
+
+//beat interval
+@property NSInteger beatsInterval;
+
+
+
+#pragma mark beats
+//心跳
+- (void)beats;
+//主动中断心跳
+- (void)beatsBreak;
+//结束心跳,结束后会进入BlockOnBeatOver,并且结束后再不会在触发BlockOnBeatBreak
+- (void)beatsOver;
+//恢复心跳,beatsOver操作后可以使用beatsRestart恢复心跳,恢复后又可以进入BlockOnBeatBreak方法
+- (void)beatsRestart;
+
+//心跳中断的委托
+- (void)setBlockOnBeatsBreak:(void(^)(BabyRhythm *bry))block;
+//心跳结束的委托
+- (void)setBlockOnBeatsOver:(void(^)(BabyRhythm *bry))block;
+
+@end

+ 77 - 0
Pods/BabyBluetooth/Classes/objc/BabyRhythm.m

@@ -0,0 +1,77 @@
+//
+//  BabyBeats.m
+//  BabyBluetoothAppDemo
+//
+//  Created by ZTELiuyw on 15/9/15.
+//  Copyright (c) 2015年 刘彦玮. All rights reserved.
+//
+
+#import "BabyRhythm.h"
+#import "BabyDefine.h"
+
+@implementation BabyRhythm {
+    BOOL isOver;
+    BBBeatsBreakBlock blockOnBeatBreak;
+    BBBeatsOverBlock blockOnBeatOver;
+}
+
+- (instancetype)init {
+    self = [super init];
+    if (self) {
+        //beatsInterval
+        _beatsInterval = KBABYRHYTHM_BEATS_DEFAULT_INTERVAL;
+    }
+    return  self;
+}
+
+- (void)beats {
+    
+    if (isOver) {
+        BabyLog(@">>>beats isOver");
+        return;
+    }
+    
+    BabyLog(@">>>beats at :%@",[NSDate date]);
+    if (self.beatsTimer) {
+        [self.beatsTimer setFireDate: [[NSDate date]dateByAddingTimeInterval:self.beatsInterval]];
+    }
+    else {
+       self.beatsTimer = [NSTimer timerWithTimeInterval:self.beatsInterval target:self selector:@selector(beatsBreak) userInfo:nil repeats:YES];
+        [self.beatsTimer setFireDate: [[NSDate date]dateByAddingTimeInterval:self.beatsInterval]];
+        [[NSRunLoop currentRunLoop] addTimer:self.beatsTimer forMode:NSRunLoopCommonModes];
+    }
+}
+
+- (void)beatsBreak {
+     BabyLog(@">>>beatsBreak :%@",[NSDate date]);
+    [self.beatsTimer setFireDate:[NSDate distantFuture]];
+    if (blockOnBeatBreak) {
+        blockOnBeatBreak(self);
+    }
+}
+
+- (void)beatsOver {
+    BabyLog(@">>>beatsOver :%@",[NSDate date]);
+    [self.beatsTimer setFireDate:[NSDate distantFuture]];
+    isOver = YES;
+    if (blockOnBeatOver) {
+        blockOnBeatOver(self);
+    }
+    
+}
+
+- (void)beatsRestart {
+    BabyLog(@">>>beatsRestart :%@",[NSDate date]);
+    isOver = NO;
+    [self beats];
+}
+
+- (void)setBlockOnBeatsBreak:(void(^)(BabyRhythm *bry))block {
+    blockOnBeatBreak = block;
+}
+
+- (void)setBlockOnBeatsOver:(void(^)(BabyRhythm *bry))block {
+    blockOnBeatOver = block;
+}
+
+@end

+ 42 - 0
Pods/BabyBluetooth/Classes/objc/BabySpeaker.h

@@ -0,0 +1,42 @@
+/*
+ BabyBluetooth
+ 简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
+ https://github.com/coolnameismy/BabyBluetooth
+ 
+ @brief  babybluetooth block查找和channel切换
+
+ */
+
+//  Created by 刘彦玮 on 15/9/2.
+//  Copyright (c) 2015年 刘彦玮. All rights reserved.
+//
+
+#import "BabyCallback.h"
+#import <CoreBluetooth/CoreBluetooth.h>
+
+
+@interface BabySpeaker : NSObject
+
+- (BabyCallback *)callback;
+- (BabyCallback *)callbackOnCurrChannel;
+- (BabyCallback *)callbackOnChnnel:(NSString *)channel;
+- (BabyCallback *)callbackOnChnnel:(NSString *)channel
+               createWhenNotExist:(BOOL)createWhenNotExist;
+
+//切换频道
+- (void)switchChannel:(NSString *)channel;
+
+//添加到notify list
+- (void)addNotifyCallback:(CBCharacteristic *)c
+           withBlock:(void(^)(CBPeripheral *peripheral, CBCharacteristic *characteristics, NSError *error))block;
+
+//添加到notify list
+- (void)removeNotifyCallback:(CBCharacteristic *)c;
+
+//获取notify list
+- (NSMutableDictionary *)notifyCallBackList;
+
+//获取notityBlock
+- (void(^)(CBPeripheral *peripheral, CBCharacteristic *characteristics, NSError *error))notifyCallback:(CBCharacteristic *)c;
+
+@end

+ 112 - 0
Pods/BabyBluetooth/Classes/objc/BabySpeaker.m

@@ -0,0 +1,112 @@
+/*
+ BabyBluetooth
+ 简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
+ https://github.com/coolnameismy/BabyBluetooth
+ */
+
+//  Created by 刘彦玮 on 15/9/2.
+//  Copyright (c) 2015年 刘彦玮. All rights reserved.
+//
+
+#import "BabySpeaker.h"
+#import "BabyDefine.h"
+
+
+typedef NS_ENUM(NSUInteger, BabySpeakerType) {
+    BabySpeakerTypeDiscoverPeripherals,
+    BabySpeakerTypeConnectedPeripheral,
+    BabySpeakerTypeDiscoverPeripheralsFailToConnect,
+    BabySpeakerTypeDiscoverPeripheralsDisconnect,
+    BabySpeakerTypeDiscoverPeripheralsDiscoverServices,
+    BabySpeakerTypeDiscoverPeripheralsDiscoverCharacteristics,
+    BabySpeakerTypeDiscoverPeripheralsReadValueForCharacteristic,
+    BabySpeakerTypeDiscoverPeripheralsDiscoverDescriptorsForCharacteristic,
+    BabySpeakerTypeDiscoverPeripheralsReadValueForDescriptorsBlock
+};
+
+
+@implementation BabySpeaker {
+    //所有委托频道
+    NSMutableDictionary *channels;
+    //当前委托频道
+    NSString *currChannel;
+    //notifyList
+    NSMutableDictionary *notifyList;
+}
+
+- (instancetype)init {
+    self = [super init];
+    if (self) {
+        BabyCallback *defaultCallback = [[BabyCallback alloc]init];
+        notifyList = [[NSMutableDictionary alloc]init];
+        channels = [[NSMutableDictionary alloc]init];
+        currChannel = KBABY_DETAULT_CHANNEL;
+        [channels setObject:defaultCallback forKey:KBABY_DETAULT_CHANNEL];
+    }
+    return self;
+}
+
+- (BabyCallback *)callback {
+    return [channels objectForKey:KBABY_DETAULT_CHANNEL];
+}
+
+- (BabyCallback *)callbackOnCurrChannel {
+    return [self callbackOnChnnel:currChannel];
+}
+
+- (BabyCallback *)callbackOnChnnel:(NSString *)channel {
+    if (!channel) {
+        [self callback];
+    }
+    return [channels objectForKey:channel];
+}
+
+- (BabyCallback *)callbackOnChnnel:(NSString *)channel
+               createWhenNotExist:(BOOL)createWhenNotExist {
+    
+    BabyCallback *callback = [channels objectForKey:channel];
+    if (!callback && createWhenNotExist) {
+        callback = [[BabyCallback alloc]init];
+        [channels setObject:callback forKey:channel];
+    }
+    
+    return callback;
+}
+
+- (void)switchChannel:(NSString *)channel {
+    if (channel) {
+        if ([self callbackOnChnnel:channel]) {
+            currChannel = channel;
+            BabyLog(@">>>已切换到%@",channel);
+        }
+        else {
+            BabyLog(@">>>所要切换的channel不存在");
+        }
+    }
+    else {
+        currChannel = KBABY_DETAULT_CHANNEL;
+            BabyLog(@">>>已切换到默认频道");
+    }
+}
+
+//添加到notify list
+- (void)addNotifyCallback:(CBCharacteristic *)c
+           withBlock:(void(^)(CBPeripheral *peripheral, CBCharacteristic *characteristics, NSError *error))block {
+    [notifyList setObject:block forKey:c.UUID.description];
+}
+
+//添加到notify list
+- (void)removeNotifyCallback:(CBCharacteristic *)c {
+    [notifyList removeObjectForKey:c.UUID.description];
+}
+
+//获取notify list
+- (NSMutableDictionary *)notifyCallBackList {
+    return notifyList;
+}
+
+//获取notityBlock
+- (void(^)(CBPeripheral *peripheral, CBCharacteristic *characteristics, NSError *error))notifyCallback:(CBCharacteristic *)c {
+    return [notifyList objectForKey:c.UUID.description];
+}
+@end

+ 34 - 0
Pods/BabyBluetooth/Classes/objc/BabyToy.h

@@ -0,0 +1,34 @@
+/*
+ BabyBluetooth
+ 简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
+ https://github.com/coolnameismy/BabyBluetooth
+ 
+ @brief  babybluetooth 工具类
+ 
+ */
+
+//  Created by 刘彦玮 on 15/8/1.
+//  Copyright (c) 2015年 刘彦玮. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import <CoreBluetooth/CoreBluetooth.h>
+
+
+
+@interface BabyToy : NSObject
+
+//十六进制转换为普通字符串的。
++ (NSString *)ConvertHexStringToString:(NSString *)hexString;
+//普通字符串转换为十六进制
++ (NSString *)ConvertStringToHexString:(NSString *)string;
+//int转data
++(NSData *)ConvertIntToData:(int)i;
+//data转int
++(int)ConvertDataToInt:(NSData *)data;
+//十六进制转换为普通字符串的。
++ (NSData *)ConvertHexStringToData:(NSString *)hexString;
+//根据UUIDString查找CBCharacteristic
++(CBCharacteristic *)findCharacteristicFormServices:(NSMutableArray *)services
+                                         UUIDString:(NSString *)UUIDString;
+@end

+ 91 - 0
Pods/BabyBluetooth/Classes/objc/BabyToy.m

@@ -0,0 +1,91 @@
+/*
+ BabyBluetooth
+ 简单易用的蓝牙ble库,基于CoreBluetooth 作者:刘彦玮
+ https://github.com/coolnameismy/BabyBluetooth
+ */
+
+//  Created by 刘彦玮 on 15/8/1.
+//  Copyright (c) 2015年 刘彦玮. All rights reserved.
+//
+
+#import "BabyToy.h"
+
+@implementation BabyToy
+
+
+//十六进制转换为普通字符串的。
++ (NSString *)ConvertHexStringToString:(NSString *)hexString {
+    
+    char *myBuffer = (char *)malloc((int)[hexString length] / 2 + 1);
+    bzero(myBuffer, [hexString length] / 2 + 1);
+    for (int i = 0; i < [hexString length] - 1; i += 2) {
+        unsigned int anInt;
+        NSString * hexCharStr = [hexString substringWithRange:NSMakeRange(i, 2)];
+        NSScanner *scanner = [[NSScanner alloc] initWithString:hexCharStr];
+        [scanner scanHexInt:&anInt];
+        myBuffer[i / 2] = (char)anInt;
+    }
+    NSString *unicodeString = [NSString stringWithCString:myBuffer encoding:4];
+//    BabyLog(@"===字符串===%@",unicodeString);
+    return unicodeString;
+}
+
+//普通字符串转换为十六进制
++ (NSString *)ConvertStringToHexString:(NSString *)string {
+    NSData *myD = [string dataUsingEncoding:NSUTF8StringEncoding];
+    Byte *bytes = (Byte *)[myD bytes];
+    //下面是Byte 转换为16进制。
+    NSString *hexStr=@"";
+    for (int i=0;i<[myD length];i++) {
+        NSString *newHexStr = [NSString stringWithFormat:@"%x",bytes[i]&0xff];///16进制数
+        
+        if ([newHexStr length]==1) {
+           hexStr = [NSString stringWithFormat:@"%@0%@",hexStr,newHexStr];
+        }
+        else{
+            hexStr = [NSString stringWithFormat:@"%@%@",hexStr,newHexStr];
+        }
+
+    } 
+    return hexStr; 
+}
+
+
+//int转data
++ (NSData *)ConvertIntToData:(int)i {
+
+    NSData *data = [NSData dataWithBytes: &i length: sizeof(i)];
+    return data;
+}
+
+//data转int
++ (int)ConvertDataToInt:(NSData *)data {
+    int i;
+    [data getBytes:&i length:sizeof(i)];
+    return i;
+}
+
+//十六进制转换为普通字符串的。
++ (NSData *)ConvertHexStringToData:(NSString *)hexString {
+    
+    NSData *data = [[BabyToy ConvertHexStringToString:hexString] dataUsingEncoding:NSUTF8StringEncoding];
+    return data;
+}
+
+
+//根据UUIDString查找CBCharacteristic
++ (CBCharacteristic *)findCharacteristicFormServices:(NSMutableArray *)services
+                                         UUIDString:(NSString *)UUIDString {
+    for (CBService *s in services) {
+        for (CBCharacteristic *c in s.characteristics) {
+            if ([c.UUID.UUIDString isEqualToString:UUIDString]) {
+                return c;
+            }
+        }
+    }
+    return nil;
+}
+
+@end
+
+

+ 22 - 0
Pods/BabyBluetooth/LICENSE

@@ -0,0 +1,22 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 liuyanwei
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+

+ 242 - 0
Pods/BabyBluetooth/README.md

@@ -0,0 +1,242 @@
+
+![](http://images.jumppo.com/uploads/BabyBluetooth_logo.png)
+
+The easiest way to use Bluetooth (BLE )in ios,even bady can use. 简单易用的蓝牙库,基于CoreBluetooth的封装,并兼容ios和mac osx.
+
+**为什么使用它?**
+
+- 1:基于原生CoreBluetooth框架封装的轻量级的开源库,可以帮你更简单地使用CoreBluetooth API。
+- 2:CoreBluetooth所有方法都是通过委托完成,代码冗余且顺序凌乱。BabyBluetooth使用block方法,可以重新按照功能和顺序组织代码,并提供许多方法减少蓝牙开发过程中的代码量。
+- 3:链式方法体,代码更简洁、优雅。
+- 4:通过channel切换区分委托调用,并方便切换
+- 5:便利的工具方法
+- 6:完善的文档,且项目处于活跃状态,不断的更新中
+- 7:github上star最多的纯Bluetooth类库
+- 8:包含多种类型的demo和ios蓝牙开发教程
+- 9:同时支持蓝牙设备中心模式和外设模式(central model and peripheral model)
+
+当前版本 0.6.0
+
+详细文档请参考wiki The full documentation of the project is available on its wiki.
+# [english readme link,please click it!](https://github.com/coolnameismy/BabyBluetooth/blob/master/README_en.md)
+
+# Table Of Contents
+
+* [QuickExample](#user-content-QuickExample)
+* [如何安装](#如何安装)
+* [如何使用](#如何使用)
+* [示例程序说明](#示例程序说明)
+* [兼容性](#兼容性)
+* [后期更新](#后期更新)
+* [蓝牙学习资源](#蓝牙学习资源)
+* [期待](#期待)
+
+# QuickExample
+
+## 中心模式 central model 
+>   app作为中心,连接其他BLE4.0外设
+
+```objc
+
+//导入.h文件和系统蓝牙库的头文件
+#import "BabyBluetooth.h"
+//定义变量
+BabyBluetooth *baby;
+
+-(void)viewDidLoad {
+    [super viewDidLoad];
+
+    //初始化BabyBluetooth 蓝牙库
+    baby = [BabyBluetooth shareBabyBluetooth];
+    //设置蓝牙委托
+    [self babyDelegate];
+    //设置委托后直接可以使用,无需等待CBCentralManagerStatePoweredOn状态
+    baby.scanForPeripherals().begin();
+}
+
+//设置蓝牙委托
+-(void)babyDelegate{
+
+    //设置扫描到设备的委托
+    [baby setBlockOnDiscoverToPeripherals:^(CBCentralManager *central, CBPeripheral *peripheral, NSDictionary *advertisementData, NSNumber *RSSI) {
+        NSLog(@"搜索到了设备:%@",peripheral.name);
+    }];
+   
+    //过滤器
+    //设置查找设备的过滤器
+    [baby setFilterOnDiscoverPeripherals:^BOOL(NSString *peripheralName, NSDictionary *advertisementData, NSNumber *RSSI) {
+        //最常用的场景是查找某一个前缀开头的设备 most common usage is discover for peripheral that name has common prefix
+        //if ([peripheralName hasPrefix:@"Pxxxx"] ) {
+        //    return YES;
+        //}
+        //return NO;
+        //设置查找规则是名称大于1 , the search rule is peripheral.name length > 1
+        if (peripheralName.length >1) {
+            return YES;
+        }
+        return NO;
+    }];
+
+    //.......
+}
+
+```
+
+更多蓝牙操作方法和委托请参考[wiki](https://github.com/coolnameismy/BabyBluetooth/wiki)
+
+中心模式使用示例请参考:[BabyBluetoothAppDemo](https://github.com/coolnameismy//BabyBluetoothExamples/BabyBluetoothAppDemo)
+
+## 外设模式 peripheral model 
+>   app模拟一个,BLE4.0外设,可以被其他设备连接和使用
+
+
+模拟一个有2个service和6个characteristic的外设
+
+````objc
+//导入.h文件和系统蓝牙库的头文件
+#import "BabyBluetooth.h"
+//定义变量
+BabyBluetooth *baby;
+
+-(void)viewDidLoad {
+    [super viewDidLoad];
+
+    //配置第一个服务s1
+    CBMutableService *s1 = makeCBService(@"FFF0");
+    //配置s1的3个characteristic
+    makeCharacteristicToService(s1, @"FFF1", @"r", @"hello1");//读
+    makeCharacteristicToService(s1, @"FFF2", @"w", @"hello2");//写
+    makeCharacteristicToService(s1, genUUID(), @"rw", @"hello3");//可读写,uuid自动生成
+    makeCharacteristicToService(s1, @"FFF4", nil, @"hello4");//默认读写字段
+    makeCharacteristicToService(s1, @"FFF5", @"n", @"hello5");//notify字段
+    //配置第一个服务s2
+    CBMutableService *s2 = makeCBService(@"FFE0");
+    makeStaticCharacteristicToService(s2, genUUID(), @"hello6", [@"a" dataUsingEncoding:NSUTF8StringEncoding]);//一个含初值的字段,该字段权限只能是只读
+   
+    //实例化baby
+    baby = [BabyBluetooth shareBabyBluetooth];
+    //配置委托
+    [self babyDelegate];
+    //启动外设
+    baby.bePeripheral().addServices(@[s1,s2]).startAdvertising();
+}
+
+//设置蓝牙外设模式的委托
+-(void)babyDelegate{
+
+     //设置添加service委托 | set didAddService block
+    [baby peripheralModelBlockOnPeripheralManagerDidUpdateState:^(CBPeripheralManager *peripheral) {
+        NSLog(@"PeripheralManager trun status code: %ld",(long)peripheral.state);
+    }];
+    
+    //设置添加service委托 | set didAddService block
+    [baby peripheralModelBlockOnDidStartAdvertising:^(CBPeripheralManager *peripheral, NSError *error) {
+        NSLog(@"didStartAdvertising !!!");
+    }];
+    
+    //设置添加service委托 | set didAddService block
+    [baby peripheralModelBlockOnDidAddService:^(CBPeripheralManager *peripheral, CBService *service, NSError *error) {
+        NSLog(@"Did Add Service uuid: %@ ",service.UUID);
+    }];
+
+    //.....
+}
+
+````
+  
+更多蓝牙外设模式委托请参考[wiki](https://github.com/coolnameismy/BabyBluetooth/wiki)
+
+中心模式使用示例请参考:[BluetoothStubOnIOS](https://github.com/coolnameismy//BabyBluetoothExamples/BluetoothStubOnIOS)
+
+# 如何安装
+
+##1 手动安装
+step1:将项目Classes/objc 文件夹中的文件直接拖入你的项目中即可
+
+step2:导入.h文件
+
+````objc
+#import "BabyBluetooth.h"
+````
+
+##2 cocoapods
+step1:add the following line to your Podfile:
+````
+pod 'BabyBluetooth','~> 0.6.0'
+````
+
+step2:导入.h文件
+````objc
+#import "BabyBluetooth.h"
+````
+
+# 如何使用
+[用法请见wiki](https://github.com/coolnameismy/BabyBluetooth/wiki)
+
+# 示例程序说明
+
+**BabyBluetoothExamples/BabyBluetoothAppDemo** :一个类似lightblue的程序,蓝牙操作全部使用BabyBluetooth完成。
+功能:
+- 1:扫描周围设备
+- 2:连接设备,扫描设备的全部services和characteristic
+- 3:显示characteristic,读取characteristic的value,和descriptors以及Descriptors对应的value
+- 4:写0x01到characteristic
+- 5:订阅/取消订阅 characteristic的notify
+
+**BabyBluetoothExamples/BluetoothStubOnIOS** : 一个iOS程序,启动后会用手机模拟一个外设,提供2个服务和若干characteristic。
+该程序作为Babybluetooth 外设模式使用的示例程序
+
+**BabyBluetoothExamples/BabyBluetoothOSDemo** :一个mac os程序,因为os和ios的蓝牙底层方法都一样,所以BabyBluetooth可以ios/os通用。但是os程序有个好处就是直接可以在mac上跑蓝牙设备,不像ios,必须要真机才能跑蓝牙设备。所以不能真机调试时可以使用os尝试蓝牙库的使用。
+
+功能:
+- 1:扫描周围设备、连接设备、显示characteristic,读取characteristic的value,和descriptors以及Descriptors对应的value的委托设置,并使用nslog打印信息。
+
+**BabyBluetoothExamples/BluetoothStubOnOSX** :一个mac os程序,该程序可以作为蓝牙外设使用,解决学习蓝牙时没有外设可用的囧境,并且可以作为peripheral model模式的学习示例。改程序用swift编码。
+
+
+
+
+功能:
+- 1:作为蓝牙外设使用,可以被发现,连接,读写,订阅
+- 2:提供1个service,包含了3个characteristic,分别具有读、读写、订阅功能
+
+# 兼容性
+- 蓝牙4.0,也叫做ble,ios6以上和iPhone4s以上可以自由使用
+- os和ios通用
+- 蓝牙设备相关程序必须使用真机才能运行。如果不能使用真机调试的情况,可以使用os程序调试蓝牙。可以参考示例程序中的BabyBluetoothOSDemo
+- 本项目和示例程序是使用ios 8.3开发,使用者可以自行降版本,但必须大于6.0 
+
+
+
+# 后期更新
+
+- 优化babyBluetooch的子类类名
+- 增加对Carthage Install的支持
+- swift版本开发
+
+已经更新的版本说明,请在wiki中查看
+
+# 蓝牙学习资源
+>  温馨提示:零基础做蓝牙开发很困难,所以就算使用babybluetooth降低了代码量,仍然任很有必要花上几天时间把蓝牙的基础概念弄明白后才开始动手~
+
+- [ios蓝牙开发(一)蓝牙相关基础知识](http://liuyanwei.jumppo.com/2015/07/17/ios-BLE-1.html)
+- [ios蓝牙开发(二)蓝牙中心模式的ios代码实现](http://liuyanwei.jumppo.com/2015/08/14/ios-BLE-2.html)
+- [ios蓝牙开发(三)app作为外设被连接的实现](http://liuyanwei.jumppo.com/2015/09/07/ios-BLE-3.html)
+- [ios蓝牙开发(四)BabyBluetooth蓝牙库介绍](http://liuyanwei.jumppo.com/2015/09/11/ios-BLE-4.html)
+- 暂未完成-ios蓝牙开发(五)BabyBluetooth实现原理
+- 待定...
+- [官方CoreBuetooth支持页](https://developer.apple.com/bluetooth)
+- [Bluetooth Accessory Design Guidelines for Apple Products](https://developer.apple.com/hardwaredrivers/BluetoothDesignGuidelines.pdf)
+
+qq交流群4: 313084771
+qq交流群3:530142592(满)
+qq交流群2:168756967(满)
+qq交流群1:426603940(满)
+
+# 期待
+
+  - 蓝牙库写起来很辛苦,不要忘记点击右上角小星星star和[follow](https://github.com/coolnameismy)支持一下~
+  - 如果在使用过程中遇到BUG,或发现功能不够用,希望你能Issues我,谢谢
+  - 期待大家也能一起为BabyBluetooth输出代码,这里我只是给BabyBluetooth开了个头,他可以增加和优化的地方还是非常多。也期待和大家在Pull Requests一起学习,交流,成长。
+
+

+ 1 - 0
Pods/Headers/Private/AFNetworking/AFAutoPurgingImageCache.h

@@ -0,0 +1 @@
+../../../AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.h

+ 1 - 0
Pods/Headers/Private/AFNetworking/AFHTTPSessionManager.h

@@ -0,0 +1 @@
+../../../AFNetworking/AFNetworking/AFHTTPSessionManager.h

+ 1 - 0
Pods/Headers/Private/AFNetworking/AFImageDownloader.h

@@ -0,0 +1 @@
+../../../AFNetworking/UIKit+AFNetworking/AFImageDownloader.h

+ 1 - 0
Pods/Headers/Private/AFNetworking/AFNetworkActivityIndicatorManager.h

@@ -0,0 +1 @@
+../../../AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h

+ 1 - 0
Pods/Headers/Private/AFNetworking/AFNetworkReachabilityManager.h

@@ -0,0 +1 @@
+../../../AFNetworking/AFNetworking/AFNetworkReachabilityManager.h

+ 1 - 0
Pods/Headers/Private/AFNetworking/AFNetworking.h

@@ -0,0 +1 @@
+../../../AFNetworking/AFNetworking/AFNetworking.h

+ 1 - 0
Pods/Headers/Private/AFNetworking/AFSecurityPolicy.h

@@ -0,0 +1 @@
+../../../AFNetworking/AFNetworking/AFSecurityPolicy.h

+ 1 - 0
Pods/Headers/Private/AFNetworking/AFURLRequestSerialization.h

@@ -0,0 +1 @@
+../../../AFNetworking/AFNetworking/AFURLRequestSerialization.h

+ 1 - 0
Pods/Headers/Private/AFNetworking/AFURLResponseSerialization.h

@@ -0,0 +1 @@
+../../../AFNetworking/AFNetworking/AFURLResponseSerialization.h

+ 1 - 0
Pods/Headers/Private/AFNetworking/AFURLSessionManager.h

@@ -0,0 +1 @@
+../../../AFNetworking/AFNetworking/AFURLSessionManager.h

+ 1 - 0
Pods/Headers/Private/AFNetworking/UIActivityIndicatorView+AFNetworking.h

@@ -0,0 +1 @@
+../../../AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h

+ 1 - 0
Pods/Headers/Private/AFNetworking/UIButton+AFNetworking.h

@@ -0,0 +1 @@
+../../../AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h

+ 1 - 0
Pods/Headers/Private/AFNetworking/UIImage+AFNetworking.h

@@ -0,0 +1 @@
+../../../AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h

+ 1 - 0
Pods/Headers/Private/AFNetworking/UIImageView+AFNetworking.h

@@ -0,0 +1 @@
+../../../AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h

+ 1 - 0
Pods/Headers/Private/AFNetworking/UIKit+AFNetworking.h

@@ -0,0 +1 @@
+../../../AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h

+ 1 - 0
Pods/Headers/Private/AFNetworking/UIProgressView+AFNetworking.h

@@ -0,0 +1 @@
+../../../AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h

+ 1 - 0
Pods/Headers/Private/AFNetworking/UIRefreshControl+AFNetworking.h

@@ -0,0 +1 @@
+../../../AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h

+ 1 - 0
Pods/Headers/Private/AFNetworking/UIWebView+AFNetworking.h

@@ -0,0 +1 @@
+../../../AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h

+ 1 - 0
Pods/Headers/Private/BabyBluetooth/BabyBluetooth.h

@@ -0,0 +1 @@
+../../../BabyBluetooth/Classes/objc/BabyBluetooth.h

+ 1 - 0
Pods/Headers/Private/BabyBluetooth/BabyCallback.h

@@ -0,0 +1 @@
+../../../BabyBluetooth/Classes/objc/BabyCallback.h

+ 1 - 0
Pods/Headers/Private/BabyBluetooth/BabyCentralManager.h

@@ -0,0 +1 @@
+../../../BabyBluetooth/Classes/objc/BabyCentralManager.h

+ 1 - 0
Pods/Headers/Private/BabyBluetooth/BabyDefine.h

@@ -0,0 +1 @@
+../../../BabyBluetooth/Classes/objc/BabyDefine.h

+ 1 - 0
Pods/Headers/Private/BabyBluetooth/BabyOptions.h

@@ -0,0 +1 @@
+../../../BabyBluetooth/Classes/objc/BabyOptions.h

+ 1 - 0
Pods/Headers/Private/BabyBluetooth/BabyPeripheralManager.h

@@ -0,0 +1 @@
+../../../BabyBluetooth/Classes/objc/BabyPeripheralManager.h

+ 1 - 0
Pods/Headers/Private/BabyBluetooth/BabyRhythm.h

@@ -0,0 +1 @@
+../../../BabyBluetooth/Classes/objc/BabyRhythm.h

+ 1 - 0
Pods/Headers/Private/BabyBluetooth/BabySpeaker.h

@@ -0,0 +1 @@
+../../../BabyBluetooth/Classes/objc/BabySpeaker.h

+ 1 - 0
Pods/Headers/Private/BabyBluetooth/BabyToy.h

@@ -0,0 +1 @@
+../../../BabyBluetooth/Classes/objc/BabyToy.h

+ 1 - 0
Pods/Headers/Private/IQKeyboardManager/IQBarButtonItem.h

@@ -0,0 +1 @@
+../../../IQKeyboardManager/IQKeyboardManager/IQToolbar/IQBarButtonItem.h

+ 1 - 0
Pods/Headers/Private/IQKeyboardManager/IQKeyboardManager.h

@@ -0,0 +1 @@
+../../../IQKeyboardManager/IQKeyboardManager/IQKeyboardManager.h

+ 1 - 0
Pods/Headers/Private/IQKeyboardManager/IQKeyboardManagerConstants.h

@@ -0,0 +1 @@
+../../../IQKeyboardManager/IQKeyboardManager/Constants/IQKeyboardManagerConstants.h

+ 1 - 0
Pods/Headers/Private/IQKeyboardManager/IQKeyboardManagerConstantsInternal.h

@@ -0,0 +1 @@
+../../../IQKeyboardManager/IQKeyboardManager/Constants/IQKeyboardManagerConstantsInternal.h

+ 1 - 0
Pods/Headers/Private/IQKeyboardManager/IQKeyboardReturnKeyHandler.h

@@ -0,0 +1 @@
+../../../IQKeyboardManager/IQKeyboardManager/IQKeyboardReturnKeyHandler.h

+ 1 - 0
Pods/Headers/Private/IQKeyboardManager/IQNSArray+Sort.h

@@ -0,0 +1 @@
+../../../IQKeyboardManager/IQKeyboardManager/Categories/IQNSArray+Sort.h

+ 1 - 0
Pods/Headers/Private/IQKeyboardManager/IQPreviousNextView.h

@@ -0,0 +1 @@
+../../../IQKeyboardManager/IQKeyboardManager/IQToolbar/IQPreviousNextView.h

+ 1 - 0
Pods/Headers/Private/IQKeyboardManager/IQTextView.h

@@ -0,0 +1 @@
+../../../IQKeyboardManager/IQKeyboardManager/IQTextView/IQTextView.h

+ 1 - 0
Pods/Headers/Private/IQKeyboardManager/IQTitleBarButtonItem.h

@@ -0,0 +1 @@
+../../../IQKeyboardManager/IQKeyboardManager/IQToolbar/IQTitleBarButtonItem.h

+ 1 - 0
Pods/Headers/Private/IQKeyboardManager/IQToolbar.h

@@ -0,0 +1 @@
+../../../IQKeyboardManager/IQKeyboardManager/IQToolbar/IQToolbar.h

+ 1 - 0
Pods/Headers/Private/IQKeyboardManager/IQUIScrollView+Additions.h

@@ -0,0 +1 @@
+../../../IQKeyboardManager/IQKeyboardManager/Categories/IQUIScrollView+Additions.h

+ 1 - 0
Pods/Headers/Private/IQKeyboardManager/IQUITextFieldView+Additions.h

@@ -0,0 +1 @@
+../../../IQKeyboardManager/IQKeyboardManager/Categories/IQUITextFieldView+Additions.h

+ 1 - 0
Pods/Headers/Private/IQKeyboardManager/IQUIView+Hierarchy.h

@@ -0,0 +1 @@
+../../../IQKeyboardManager/IQKeyboardManager/Categories/IQUIView+Hierarchy.h

+ 1 - 0
Pods/Headers/Private/IQKeyboardManager/IQUIView+IQKeyboardToolbar.h

@@ -0,0 +1 @@
+../../../IQKeyboardManager/IQKeyboardManager/IQToolbar/IQUIView+IQKeyboardToolbar.h

+ 1 - 0
Pods/Headers/Private/IQKeyboardManager/IQUIViewController+Additions.h

@@ -0,0 +1 @@
+../../../IQKeyboardManager/IQKeyboardManager/Categories/IQUIViewController+Additions.h

+ 0 - 0
Pods/Headers/Private/IQKeyboardManager/IQUIWindow+Hierarchy.h


部分文件因为文件数量过多而无法显示