├── .gitignore ├── DDSlackWebhook.podspec ├── DDSlackWebhook ├── DDSlackWebHookClient.h └── DDSlackWebhookClient.m ├── LICENSE ├── Podfile ├── Podfile.lock ├── Pods ├── AFNetworking │ ├── AFNetworking │ │ ├── AFHTTPRequestOperation.h │ │ ├── AFHTTPRequestOperation.m │ │ ├── AFHTTPRequestOperationManager.h │ │ ├── AFHTTPRequestOperationManager.m │ │ ├── AFHTTPSessionManager.h │ │ ├── AFHTTPSessionManager.m │ │ ├── AFNetworkReachabilityManager.h │ │ ├── AFNetworkReachabilityManager.m │ │ ├── AFNetworking.h │ │ ├── AFSecurityPolicy.h │ │ ├── AFSecurityPolicy.m │ │ ├── AFURLConnectionOperation.h │ │ ├── AFURLConnectionOperation.m │ │ ├── AFURLRequestSerialization.h │ │ ├── AFURLRequestSerialization.m │ │ ├── AFURLResponseSerialization.h │ │ ├── AFURLResponseSerialization.m │ │ ├── AFURLSessionManager.h │ │ └── AFURLSessionManager.m │ ├── LICENSE │ ├── README.md │ └── UIKit+AFNetworking │ │ ├── AFNetworkActivityIndicatorManager.h │ │ ├── AFNetworkActivityIndicatorManager.m │ │ ├── UIActivityIndicatorView+AFNetworking.h │ │ ├── UIActivityIndicatorView+AFNetworking.m │ │ ├── UIAlertView+AFNetworking.h │ │ ├── UIAlertView+AFNetworking.m │ │ ├── UIButton+AFNetworking.h │ │ ├── UIButton+AFNetworking.m │ │ ├── UIImage+AFNetworking.h │ │ ├── UIImageView+AFNetworking.h │ │ ├── UIImageView+AFNetworking.m │ │ ├── UIKit+AFNetworking.h │ │ ├── UIProgressView+AFNetworking.h │ │ ├── UIProgressView+AFNetworking.m │ │ ├── UIRefreshControl+AFNetworking.h │ │ ├── UIRefreshControl+AFNetworking.m │ │ ├── UIWebView+AFNetworking.h │ │ └── UIWebView+AFNetworking.m ├── Headers │ ├── Private │ │ └── AFNetworking │ │ │ ├── AFHTTPRequestOperation.h │ │ │ ├── AFHTTPRequestOperationManager.h │ │ │ ├── AFHTTPSessionManager.h │ │ │ ├── AFNetworkActivityIndicatorManager.h │ │ │ ├── AFNetworkReachabilityManager.h │ │ │ ├── AFNetworking.h │ │ │ ├── AFSecurityPolicy.h │ │ │ ├── AFURLConnectionOperation.h │ │ │ ├── AFURLRequestSerialization.h │ │ │ ├── AFURLResponseSerialization.h │ │ │ ├── AFURLSessionManager.h │ │ │ ├── UIActivityIndicatorView+AFNetworking.h │ │ │ ├── UIAlertView+AFNetworking.h │ │ │ ├── UIButton+AFNetworking.h │ │ │ ├── UIImage+AFNetworking.h │ │ │ ├── UIImageView+AFNetworking.h │ │ │ ├── UIKit+AFNetworking.h │ │ │ ├── UIProgressView+AFNetworking.h │ │ │ ├── UIRefreshControl+AFNetworking.h │ │ │ └── UIWebView+AFNetworking.h │ └── Public │ │ └── AFNetworking │ │ ├── AFHTTPRequestOperation.h │ │ ├── AFHTTPRequestOperationManager.h │ │ ├── AFHTTPSessionManager.h │ │ ├── AFNetworkActivityIndicatorManager.h │ │ ├── AFNetworkReachabilityManager.h │ │ ├── AFNetworking.h │ │ ├── AFSecurityPolicy.h │ │ ├── AFURLConnectionOperation.h │ │ ├── AFURLRequestSerialization.h │ │ ├── AFURLResponseSerialization.h │ │ ├── AFURLSessionManager.h │ │ ├── UIActivityIndicatorView+AFNetworking.h │ │ ├── UIAlertView+AFNetworking.h │ │ ├── UIButton+AFNetworking.h │ │ ├── UIImage+AFNetworking.h │ │ ├── UIImageView+AFNetworking.h │ │ ├── UIKit+AFNetworking.h │ │ ├── UIProgressView+AFNetworking.h │ │ ├── UIRefreshControl+AFNetworking.h │ │ └── UIWebView+AFNetworking.h ├── Manifest.lock ├── Pods.xcodeproj │ └── project.pbxproj └── Target Support Files │ ├── AFNetworking │ ├── AFNetworking-Private.xcconfig │ ├── AFNetworking-dummy.m │ ├── AFNetworking-prefix.pch │ └── AFNetworking.xcconfig │ └── Pods-SlackIncomingWebhooksDemo │ ├── Pods-SlackIncomingWebhooksDemo-acknowledgements.markdown │ ├── Pods-SlackIncomingWebhooksDemo-acknowledgements.plist │ ├── Pods-SlackIncomingWebhooksDemo-dummy.m │ ├── Pods-SlackIncomingWebhooksDemo-resources.sh │ ├── Pods-SlackIncomingWebhooksDemo.debug.xcconfig │ └── Pods-SlackIncomingWebhooksDemo.release.xcconfig ├── README.md ├── SlackIncomingWebhooksDemo.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── SlackIncomingWebhooksDemo.xcworkspace └── contents.xcworkspacedata ├── SlackIncomingWebhooksDemo ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── ViewController.h ├── ViewController.m └── main.m └── SlackIncomingWebhooksDemoTests ├── Info.plist └── SlackIncomingWebhooksDemoTests.m /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.swp 3 | *~.nib 4 | 5 | build/ 6 | xcuserdata/ 7 | *.pbxuser 8 | *.perspective 9 | *.perspectivev3 -------------------------------------------------------------------------------- /DDSlackWebhook.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod spec lint DDSlackWebhook.podspec' to ensure this is a 3 | # valid spec and to remove all comments including this before submitting the spec. 4 | # 5 | # To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html 6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | 11 | # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 12 | # 13 | # These will help people to find your library, and whilst it 14 | # can feel like a chore to fill in it's definitely to your advantage. The 15 | # summary should be tweet-length, and the description more in depth. 16 | # 17 | 18 | s.name = "DDSlackWebhook" 19 | s.version = "1.0" 20 | s.summary = "A slack webhook client written with Objective-C" 21 | 22 | s.description = <<-DESC 23 | DDSlackWebhook is a simple client post notification to your slack channel use slack incoming webhooks. Written in Objective-c. 24 | DESC 25 | 26 | s.homepage = "https://github.com/deepdevelop/DDSlackWebhook" 27 | # s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif" 28 | 29 | 30 | # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 31 | # 32 | # Licensing your code is important. See http://choosealicense.com for more info. 33 | # CocoaPods will detect a license file if there is a named LICENSE* 34 | # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'. 35 | # 36 | 37 | s.license = "MIT" 38 | # s.license = { :type => "MIT", :file => "FILE_LICENSE" } 39 | 40 | 41 | # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 42 | # 43 | # Specify the authors of the library, with email addresses. Email addresses 44 | # of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also 45 | # accepts just a name if you'd rather not provide an email address. 46 | # 47 | # Specify a social_media_url where others can refer to, for example a twitter 48 | # profile URL. 49 | # 50 | 51 | s.author = { "Liu Yi" => "61upup@gmail.com" } 52 | # Or just: s.author = "Liu Yi" 53 | # s.authors = { "Liu Yi" => "61upup@gmail.com" } 54 | # s.social_media_url = "http://twitter.com/Liu Yi" 55 | 56 | # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 57 | # 58 | # If this Pod runs only on iOS or OS X, then specify the platform and 59 | # the deployment target. You can optionally include the target after the platform. 60 | # 61 | 62 | # s.platform = :ios 63 | # s.platform = :ios, "5.0" 64 | 65 | # When using multiple platforms 66 | s.ios.deployment_target = "7.0" 67 | s.osx.deployment_target = "10.9" 68 | # s.watchos.deployment_target = "2.0" 69 | 70 | 71 | # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 72 | # 73 | # Specify the location from where the source should be retrieved. 74 | # Supports git, hg, bzr, svn and HTTP. 75 | # 76 | 77 | s.source = { :git => "https://github.com/deepdevelop/DDSlackWebhook.git", :tag => "1.0" } 78 | 79 | 80 | # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 81 | # 82 | # CocoaPods is smart about how it includes source code. For source files 83 | # giving a folder will include any swift, h, m, mm, c & cpp files. 84 | # For header files it will include any header in the folder. 85 | # Not including the public_header_files will make all headers public. 86 | # 87 | 88 | s.source_files = "DDSlackWebhook/**/*.{h,m}" 89 | 90 | # s.public_header_files = "Classes/**/*.h" 91 | 92 | 93 | # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 94 | # 95 | # A list of resources included with the Pod. These are copied into the 96 | # target bundle with a build phase script. Anything else will be cleaned. 97 | # You can preserve files from being cleaned, please don't preserve 98 | # non-essential files like tests, examples and documentation. 99 | # 100 | 101 | # s.resource = "icon.png" 102 | # s.resources = "Resources/*.png" 103 | 104 | # s.preserve_paths = "FilesToSave", "MoreFilesToSave" 105 | 106 | 107 | # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 108 | # 109 | # Link your library with frameworks, or libraries. Libraries do not include 110 | # the lib prefix of their name. 111 | # 112 | 113 | # s.framework = "SomeFramework" 114 | # s.frameworks = "SomeFramework", "AnotherFramework" 115 | 116 | # s.library = "iconv" 117 | # s.libraries = "iconv", "xml2" 118 | 119 | 120 | # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 121 | # 122 | # If your library depends on compiler flags you can set them in the xcconfig hash 123 | # where they will only apply to your library. If you depend on other Podspecs 124 | # you can include multiple dependencies to ensure it works. 125 | 126 | s.requires_arc = true 127 | 128 | # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" } 129 | s.dependency "AFNetworking", "~> 2.5" 130 | 131 | end 132 | -------------------------------------------------------------------------------- /DDSlackWebhook/DDSlackWebHookClient.h: -------------------------------------------------------------------------------- 1 | // 2 | // DDSlackWebhookClient.h 3 | // SlackIncomingWebhooksDemo 4 | // 5 | // Created by im61 on 15/10/11. 6 | // Copyright © 2015年 DeepDevelop. All rights reserved. 7 | // 8 | 9 | 10 | #import 11 | 12 | @interface DDSlackWebhookClient : NSObject 13 | 14 | /** 15 | * Initialize DDSlackWebhookClient. Call this method within your App Delegate's `application:didFinishLaunchingWithOptions:` and provide the slack incoming webhook url 16 | * 17 | * @param webhookURL the incoming webhook url from your Slack 18 | * 19 | * @return Returns the shared Fabric instance. In most cases this can be ignored. 20 | */ 21 | 22 | + (instancetype)withWebhookURL:(NSURL *)webhookURL; 23 | 24 | /** 25 | * Returns the DDSlackWebhookClient singleton object. 26 | */ 27 | 28 | + (instancetype)sharedClient; 29 | 30 | /** 31 | * Post notification to Slack Channel or a Direct Message to someone 32 | * 33 | * @param channel channel name or user id. example: #general or @61 34 | * @param text notification content 35 | * @param username displayed name 36 | * @param iconURL bot icon url 37 | * @param iconEmoji bot icon emoji 38 | * @param completion callback 39 | */ 40 | 41 | - (void)postNotificationToChannel:(NSString *)channel 42 | text:(NSString *)text 43 | username:(NSString *)username 44 | iconURL:(NSURL *)iconURL 45 | iconEmoji:(NSString *)iconEmoji 46 | completion:(void (^)(NSError *error))completion; 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /DDSlackWebhook/DDSlackWebhookClient.m: -------------------------------------------------------------------------------- 1 | // 2 | // DDSlackWebHookClient.m 3 | // SlackIncomingWebhooksDemo 4 | // 5 | // Created by im61 on 15/10/11. 6 | // Copyright © 2015年 DeepDevelop. All rights reserved. 7 | // 8 | 9 | #import "DDSlackWebhookClient.h" 10 | #import "AFHTTPSessionManager.h" 11 | #import "AFURLRequestSerialization.h" 12 | #import "AFHTTPRequestOperationManager.h" 13 | 14 | @interface DDSlackWebhookClient () 15 | 16 | @property (nonatomic, strong) AFHTTPSessionManager *manager; 17 | @property (nonatomic, strong) NSURL *webhookURL; 18 | @property (nonatomic, strong) NSString *path; 19 | 20 | @end 21 | 22 | @implementation DDSlackWebhookClient 23 | 24 | + (instancetype)withWebhookURL:(NSURL *)webhookURL { 25 | DDSlackWebhookClient *client = [DDSlackWebhookClient sharedClient]; 26 | 27 | static dispatch_once_t onceToken; 28 | 29 | dispatch_once(&onceToken, ^{ 30 | client.webhookURL = webhookURL; 31 | }); 32 | 33 | return client; 34 | } 35 | 36 | + (instancetype)sharedClient { 37 | static DDSlackWebhookClient *_sharedClient = nil; 38 | static dispatch_once_t onceToken; 39 | 40 | dispatch_once(&onceToken, ^{ 41 | _sharedClient = [[DDSlackWebhookClient alloc] init]; 42 | }); 43 | 44 | return _sharedClient; 45 | } 46 | 47 | - (void)setWebhookURL:(NSURL *)webhookURL { 48 | _webhookURL = webhookURL; 49 | 50 | NSString *baseURLString = [NSString stringWithFormat:@"%@://%@", _webhookURL.scheme, _webhookURL.host]; 51 | NSString *path = [[[_webhookURL pathComponents] componentsJoinedByString:@"/"] substringFromIndex:2]; 52 | 53 | self.manager = [[AFHTTPSessionManager alloc] initWithBaseURL:[NSURL URLWithString:baseURLString]]; 54 | self.manager.requestSerializer = [AFJSONRequestSerializer serializer]; 55 | self.manager.responseSerializer = [AFHTTPResponseSerializer serializer]; 56 | 57 | self.path = path; 58 | } 59 | 60 | - (void)postNotificationToChannel:(NSString *)channel 61 | text:(NSString *)text 62 | username:(NSString *)username 63 | iconURL:(NSURL *)iconURL 64 | iconEmoji:(NSString *)iconEmoji 65 | completion:(void (^)(NSError *error))completion { 66 | NSMutableDictionary *params = [NSMutableDictionary dictionary]; 67 | 68 | if (channel) { 69 | params[@"channel"] = channel; 70 | } 71 | 72 | if (!text) { 73 | text = @"test incoming webhook"; 74 | } 75 | 76 | if (username) { 77 | params[@"username"] = username; 78 | } 79 | 80 | if (iconURL) { 81 | params[@"icon_url"] = iconURL.absoluteString; 82 | } 83 | 84 | if (iconEmoji) { 85 | params[@"icon_emoji"] = iconEmoji; 86 | } 87 | 88 | params[@"text"] = text; 89 | 90 | [self.manager POST:self.path 91 | parameters:params 92 | success:^(NSURLSessionDataTask *task, id responseObject) { 93 | if (completion) { 94 | completion(nil); 95 | } 96 | } failure:^(NSURLSessionDataTask *task, NSError *error) { 97 | if (completion) { 98 | completion(error); 99 | } 100 | }]; 101 | } 102 | 103 | @end 104 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 DeepDevelop-Inc 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '6.0' 3 | 4 | target 'SlackIncomingWebhooksDemo' do 5 | pod 'AFNetworking', '~> 2.5' 6 | end 7 | 8 | target 'SlackIncomingWebhooksDemoTests' do 9 | 10 | end 11 | 12 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - AFNetworking (2.6.0): 3 | - AFNetworking/NSURLConnection (= 2.6.0) 4 | - AFNetworking/NSURLSession (= 2.6.0) 5 | - AFNetworking/Reachability (= 2.6.0) 6 | - AFNetworking/Security (= 2.6.0) 7 | - AFNetworking/Serialization (= 2.6.0) 8 | - AFNetworking/UIKit (= 2.6.0) 9 | - AFNetworking/NSURLConnection (2.6.0): 10 | - AFNetworking/Reachability 11 | - AFNetworking/Security 12 | - AFNetworking/Serialization 13 | - AFNetworking/NSURLSession (2.6.0): 14 | - AFNetworking/Reachability 15 | - AFNetworking/Security 16 | - AFNetworking/Serialization 17 | - AFNetworking/Reachability (2.6.0) 18 | - AFNetworking/Security (2.6.0) 19 | - AFNetworking/Serialization (2.6.0) 20 | - AFNetworking/UIKit (2.6.0): 21 | - AFNetworking/NSURLConnection 22 | - AFNetworking/NSURLSession 23 | 24 | DEPENDENCIES: 25 | - AFNetworking (~> 2.5) 26 | 27 | SPEC CHECKSUMS: 28 | AFNetworking: 79f7eb1a0fcfa7beb409332b2ca49afe9ce53b05 29 | 30 | COCOAPODS: 0.38.2 31 | -------------------------------------------------------------------------------- /Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.h: -------------------------------------------------------------------------------- 1 | // AFHTTPRequestOperation.h 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | #import "AFURLConnectionOperation.h" 24 | 25 | NS_ASSUME_NONNULL_BEGIN 26 | 27 | /** 28 | `AFHTTPRequestOperation` is a subclass of `AFURLConnectionOperation` for requests using the HTTP or HTTPS protocols. It encapsulates the concept of acceptable status codes and content types, which determine the success or failure of a request. 29 | */ 30 | @interface AFHTTPRequestOperation : AFURLConnectionOperation 31 | 32 | ///------------------------------------------------ 33 | /// @name Getting HTTP URL Connection Information 34 | ///------------------------------------------------ 35 | 36 | /** 37 | The last HTTP response received by the operation's connection. 38 | */ 39 | @property (readonly, nonatomic, strong, nullable) NSHTTPURLResponse *response; 40 | 41 | /** 42 | 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 AFHTTPResponse serializer, which uses the raw data as its response object. The serializer validates the status code to be in the `2XX` range, denoting success. If the response serializer generates an error in `-responseObjectForResponse:data:error:`, the `failure` callback of the session task or request operation will be executed; otherwise, the `success` callback will be executed. 43 | 44 | @warning `responseSerializer` must not be `nil`. Setting a response serializer will clear out any cached value 45 | */ 46 | @property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer; 47 | 48 | /** 49 | An object constructed by the `responseSerializer` from the response and response data. Returns `nil` unless the operation `isFinished`, has a `response`, and has `responseData` with non-zero content length. If an error occurs during serialization, `nil` will be returned, and the `error` property will be populated with the serialization error. 50 | */ 51 | @property (readonly, nonatomic, strong, nullable) id responseObject; 52 | 53 | ///----------------------------------------------------------- 54 | /// @name Setting Completion Block Success / Failure Callbacks 55 | ///----------------------------------------------------------- 56 | 57 | /** 58 | Sets the `completionBlock` property with a block that executes either the specified success or failure block, depending on the state of the request on completion. If `error` returns a value, which can be caused by an unacceptable status code or content type, then `failure` is executed. Otherwise, `success` is executed. 59 | 60 | This method should be overridden in subclasses in order to specify the response object passed into the success block. 61 | 62 | @param success The block to be executed on the completion of a successful request. This block has no return value and takes two arguments: the receiver operation and the object constructed from the response data of the request. 63 | @param failure The block to be executed on the completion of an unsuccessful request. This block has no return value and takes two arguments: the receiver operation and the error that occurred during the request. 64 | */ 65 | - (void)setCompletionBlockWithSuccess:(nullable void (^)(AFHTTPRequestOperation *operation, id responseObject))success 66 | failure:(nullable void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; 67 | 68 | @end 69 | 70 | NS_ASSUME_NONNULL_END 71 | -------------------------------------------------------------------------------- /Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.m: -------------------------------------------------------------------------------- 1 | // AFHTTPRequestOperation.m 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import "AFHTTPRequestOperation.h" 23 | 24 | static dispatch_queue_t http_request_operation_processing_queue() { 25 | static dispatch_queue_t af_http_request_operation_processing_queue; 26 | static dispatch_once_t onceToken; 27 | dispatch_once(&onceToken, ^{ 28 | af_http_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.http-request.processing", DISPATCH_QUEUE_CONCURRENT); 29 | }); 30 | 31 | return af_http_request_operation_processing_queue; 32 | } 33 | 34 | static dispatch_group_t http_request_operation_completion_group() { 35 | static dispatch_group_t af_http_request_operation_completion_group; 36 | static dispatch_once_t onceToken; 37 | dispatch_once(&onceToken, ^{ 38 | af_http_request_operation_completion_group = dispatch_group_create(); 39 | }); 40 | 41 | return af_http_request_operation_completion_group; 42 | } 43 | 44 | #pragma mark - 45 | 46 | @interface AFURLConnectionOperation () 47 | @property (readwrite, nonatomic, strong) NSURLRequest *request; 48 | @property (readwrite, nonatomic, strong) NSURLResponse *response; 49 | @end 50 | 51 | @interface AFHTTPRequestOperation () 52 | @property (readwrite, nonatomic, strong) NSHTTPURLResponse *response; 53 | @property (readwrite, nonatomic, strong) id responseObject; 54 | @property (readwrite, nonatomic, strong) NSError *responseSerializationError; 55 | @property (readwrite, nonatomic, strong) NSRecursiveLock *lock; 56 | @end 57 | 58 | @implementation AFHTTPRequestOperation 59 | @dynamic response; 60 | @dynamic lock; 61 | 62 | - (instancetype)initWithRequest:(NSURLRequest *)urlRequest { 63 | self = [super initWithRequest:urlRequest]; 64 | if (!self) { 65 | return nil; 66 | } 67 | 68 | self.responseSerializer = [AFHTTPResponseSerializer serializer]; 69 | 70 | return self; 71 | } 72 | 73 | - (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer { 74 | NSParameterAssert(responseSerializer); 75 | 76 | [self.lock lock]; 77 | _responseSerializer = responseSerializer; 78 | self.responseObject = nil; 79 | self.responseSerializationError = nil; 80 | [self.lock unlock]; 81 | } 82 | 83 | - (id)responseObject { 84 | [self.lock lock]; 85 | if (!_responseObject && [self isFinished] && !self.error) { 86 | NSError *error = nil; 87 | self.responseObject = [self.responseSerializer responseObjectForResponse:self.response data:self.responseData error:&error]; 88 | if (error) { 89 | self.responseSerializationError = error; 90 | } 91 | } 92 | [self.lock unlock]; 93 | 94 | return _responseObject; 95 | } 96 | 97 | - (NSError *)error { 98 | if (_responseSerializationError) { 99 | return _responseSerializationError; 100 | } else { 101 | return [super error]; 102 | } 103 | } 104 | 105 | #pragma mark - AFHTTPRequestOperation 106 | 107 | - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success 108 | failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure 109 | { 110 | // completionBlock is manually nilled out in AFURLConnectionOperation to break the retain cycle. 111 | #pragma clang diagnostic push 112 | #pragma clang diagnostic ignored "-Warc-retain-cycles" 113 | #pragma clang diagnostic ignored "-Wgnu" 114 | self.completionBlock = ^{ 115 | if (self.completionGroup) { 116 | dispatch_group_enter(self.completionGroup); 117 | } 118 | 119 | dispatch_async(http_request_operation_processing_queue(), ^{ 120 | if (self.error) { 121 | if (failure) { 122 | dispatch_group_async(self.completionGroup ?: http_request_operation_completion_group(), self.completionQueue ?: dispatch_get_main_queue(), ^{ 123 | failure(self, self.error); 124 | }); 125 | } 126 | } else { 127 | id responseObject = self.responseObject; 128 | if (self.error) { 129 | if (failure) { 130 | dispatch_group_async(self.completionGroup ?: http_request_operation_completion_group(), self.completionQueue ?: dispatch_get_main_queue(), ^{ 131 | failure(self, self.error); 132 | }); 133 | } 134 | } else { 135 | if (success) { 136 | dispatch_group_async(self.completionGroup ?: http_request_operation_completion_group(), self.completionQueue ?: dispatch_get_main_queue(), ^{ 137 | success(self, responseObject); 138 | }); 139 | } 140 | } 141 | } 142 | 143 | if (self.completionGroup) { 144 | dispatch_group_leave(self.completionGroup); 145 | } 146 | }); 147 | }; 148 | #pragma clang diagnostic pop 149 | } 150 | 151 | #pragma mark - AFURLRequestOperation 152 | 153 | - (void)pause { 154 | [super pause]; 155 | 156 | u_int64_t offset = 0; 157 | if ([self.outputStream propertyForKey:NSStreamFileCurrentOffsetKey]) { 158 | offset = [(NSNumber *)[self.outputStream propertyForKey:NSStreamFileCurrentOffsetKey] unsignedLongLongValue]; 159 | } else { 160 | offset = [(NSData *)[self.outputStream propertyForKey:NSStreamDataWrittenToMemoryStreamKey] length]; 161 | } 162 | 163 | NSMutableURLRequest *mutableURLRequest = [self.request mutableCopy]; 164 | if ([self.response respondsToSelector:@selector(allHeaderFields)] && [[self.response allHeaderFields] valueForKey:@"ETag"]) { 165 | [mutableURLRequest setValue:[[self.response allHeaderFields] valueForKey:@"ETag"] forHTTPHeaderField:@"If-Range"]; 166 | } 167 | [mutableURLRequest setValue:[NSString stringWithFormat:@"bytes=%llu-", offset] forHTTPHeaderField:@"Range"]; 168 | self.request = mutableURLRequest; 169 | } 170 | 171 | #pragma mark - NSSecureCoding 172 | 173 | + (BOOL)supportsSecureCoding { 174 | return YES; 175 | } 176 | 177 | - (id)initWithCoder:(NSCoder *)decoder { 178 | self = [super initWithCoder:decoder]; 179 | if (!self) { 180 | return nil; 181 | } 182 | 183 | self.responseSerializer = [decoder decodeObjectOfClass:[AFHTTPResponseSerializer class] forKey:NSStringFromSelector(@selector(responseSerializer))]; 184 | 185 | return self; 186 | } 187 | 188 | - (void)encodeWithCoder:(NSCoder *)coder { 189 | [super encodeWithCoder:coder]; 190 | 191 | [coder encodeObject:self.responseSerializer forKey:NSStringFromSelector(@selector(responseSerializer))]; 192 | } 193 | 194 | #pragma mark - NSCopying 195 | 196 | - (id)copyWithZone:(NSZone *)zone { 197 | AFHTTPRequestOperation *operation = [super copyWithZone:zone]; 198 | 199 | operation.responseSerializer = [self.responseSerializer copyWithZone:zone]; 200 | operation.completionQueue = self.completionQueue; 201 | operation.completionGroup = self.completionGroup; 202 | 203 | return operation; 204 | } 205 | 206 | @end 207 | -------------------------------------------------------------------------------- /Pods/AFNetworking/AFNetworking/AFHTTPRequestOperationManager.m: -------------------------------------------------------------------------------- 1 | // AFHTTPRequestOperationManager.m 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #import "AFHTTPRequestOperationManager.h" 25 | #import "AFHTTPRequestOperation.h" 26 | 27 | #import 28 | #import 29 | 30 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 31 | #import 32 | #endif 33 | 34 | @interface AFHTTPRequestOperationManager () 35 | @property (readwrite, nonatomic, strong) NSURL *baseURL; 36 | @end 37 | 38 | @implementation AFHTTPRequestOperationManager 39 | 40 | + (instancetype)manager { 41 | return [[self alloc] initWithBaseURL:nil]; 42 | } 43 | 44 | - (instancetype)init { 45 | return [self initWithBaseURL:nil]; 46 | } 47 | 48 | - (instancetype)initWithBaseURL:(NSURL *)url { 49 | self = [super init]; 50 | if (!self) { 51 | return nil; 52 | } 53 | 54 | // Ensure terminal slash for baseURL path, so that NSURL +URLWithString:relativeToURL: works as expected 55 | if ([[url path] length] > 0 && ![[url absoluteString] hasSuffix:@"/"]) { 56 | url = [url URLByAppendingPathComponent:@""]; 57 | } 58 | 59 | self.baseURL = url; 60 | 61 | self.requestSerializer = [AFHTTPRequestSerializer serializer]; 62 | self.responseSerializer = [AFJSONResponseSerializer serializer]; 63 | 64 | self.securityPolicy = [AFSecurityPolicy defaultPolicy]; 65 | 66 | self.reachabilityManager = [AFNetworkReachabilityManager sharedManager]; 67 | 68 | self.operationQueue = [[NSOperationQueue alloc] init]; 69 | 70 | self.shouldUseCredentialStorage = YES; 71 | 72 | return self; 73 | } 74 | 75 | #pragma mark - 76 | 77 | #ifdef _SYSTEMCONFIGURATION_H 78 | #endif 79 | 80 | - (void)setRequestSerializer:(AFHTTPRequestSerializer *)requestSerializer { 81 | NSParameterAssert(requestSerializer); 82 | 83 | _requestSerializer = requestSerializer; 84 | } 85 | 86 | - (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer { 87 | NSParameterAssert(responseSerializer); 88 | 89 | _responseSerializer = responseSerializer; 90 | } 91 | 92 | #pragma mark - 93 | 94 | - (AFHTTPRequestOperation *)HTTPRequestOperationWithHTTPMethod:(NSString *)method 95 | URLString:(NSString *)URLString 96 | parameters:(id)parameters 97 | success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success 98 | failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure 99 | { 100 | NSError *serializationError = nil; 101 | NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:method URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:&serializationError]; 102 | if (serializationError) { 103 | if (failure) { 104 | #pragma clang diagnostic push 105 | #pragma clang diagnostic ignored "-Wgnu" 106 | dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{ 107 | failure(nil, serializationError); 108 | }); 109 | #pragma clang diagnostic pop 110 | } 111 | 112 | return nil; 113 | } 114 | 115 | return [self HTTPRequestOperationWithRequest:request success:success failure:failure]; 116 | } 117 | 118 | - (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)request 119 | success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success 120 | failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure 121 | { 122 | AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; 123 | operation.responseSerializer = self.responseSerializer; 124 | operation.shouldUseCredentialStorage = self.shouldUseCredentialStorage; 125 | operation.credential = self.credential; 126 | operation.securityPolicy = self.securityPolicy; 127 | 128 | [operation setCompletionBlockWithSuccess:success failure:failure]; 129 | operation.completionQueue = self.completionQueue; 130 | operation.completionGroup = self.completionGroup; 131 | 132 | return operation; 133 | } 134 | 135 | #pragma mark - 136 | 137 | - (AFHTTPRequestOperation *)GET:(NSString *)URLString 138 | parameters:(id)parameters 139 | success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success 140 | failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure 141 | { 142 | AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithHTTPMethod:@"GET" URLString:URLString parameters:parameters success:success failure:failure]; 143 | 144 | [self.operationQueue addOperation:operation]; 145 | 146 | return operation; 147 | } 148 | 149 | - (AFHTTPRequestOperation *)HEAD:(NSString *)URLString 150 | parameters:(id)parameters 151 | success:(void (^)(AFHTTPRequestOperation *operation))success 152 | failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure 153 | { 154 | AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithHTTPMethod:@"HEAD" URLString:URLString parameters:parameters success:^(AFHTTPRequestOperation *requestOperation, __unused id responseObject) { 155 | if (success) { 156 | success(requestOperation); 157 | } 158 | } failure:failure]; 159 | 160 | [self.operationQueue addOperation:operation]; 161 | 162 | return operation; 163 | } 164 | 165 | - (AFHTTPRequestOperation *)POST:(NSString *)URLString 166 | parameters:(id)parameters 167 | success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success 168 | failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure 169 | { 170 | AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithHTTPMethod:@"POST" URLString:URLString parameters:parameters success:success failure:failure]; 171 | 172 | [self.operationQueue addOperation:operation]; 173 | 174 | return operation; 175 | } 176 | 177 | - (AFHTTPRequestOperation *)POST:(NSString *)URLString 178 | parameters:(id)parameters 179 | constructingBodyWithBlock:(void (^)(id formData))block 180 | success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success 181 | failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure 182 | { 183 | NSError *serializationError = nil; 184 | NSMutableURLRequest *request = [self.requestSerializer multipartFormRequestWithMethod:@"POST" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters constructingBodyWithBlock:block error:&serializationError]; 185 | if (serializationError) { 186 | if (failure) { 187 | #pragma clang diagnostic push 188 | #pragma clang diagnostic ignored "-Wgnu" 189 | dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{ 190 | failure(nil, serializationError); 191 | }); 192 | #pragma clang diagnostic pop 193 | } 194 | 195 | return nil; 196 | } 197 | 198 | AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure]; 199 | 200 | [self.operationQueue addOperation:operation]; 201 | 202 | return operation; 203 | } 204 | 205 | - (AFHTTPRequestOperation *)PUT:(NSString *)URLString 206 | parameters:(id)parameters 207 | success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success 208 | failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure 209 | { 210 | AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithHTTPMethod:@"PUT" URLString:URLString parameters:parameters success:success failure:failure]; 211 | 212 | [self.operationQueue addOperation:operation]; 213 | 214 | return operation; 215 | } 216 | 217 | - (AFHTTPRequestOperation *)PATCH:(NSString *)URLString 218 | parameters:(id)parameters 219 | success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success 220 | failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure 221 | { 222 | AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithHTTPMethod:@"PATCH" URLString:URLString parameters:parameters success:success failure:failure]; 223 | 224 | [self.operationQueue addOperation:operation]; 225 | 226 | return operation; 227 | } 228 | 229 | - (AFHTTPRequestOperation *)DELETE:(NSString *)URLString 230 | parameters:(id)parameters 231 | success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success 232 | failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure 233 | { 234 | AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithHTTPMethod:@"DELETE" URLString:URLString parameters:parameters success:success failure:failure]; 235 | 236 | [self.operationQueue addOperation:operation]; 237 | 238 | return operation; 239 | } 240 | 241 | #pragma mark - NSObject 242 | 243 | - (NSString *)description { 244 | return [NSString stringWithFormat:@"<%@: %p, baseURL: %@, operationQueue: %@>", NSStringFromClass([self class]), self, [self.baseURL absoluteString], self.operationQueue]; 245 | } 246 | 247 | #pragma mark - NSSecureCoding 248 | 249 | + (BOOL)supportsSecureCoding { 250 | return YES; 251 | } 252 | 253 | - (id)initWithCoder:(NSCoder *)decoder { 254 | NSURL *baseURL = [decoder decodeObjectForKey:NSStringFromSelector(@selector(baseURL))]; 255 | 256 | self = [self initWithBaseURL:baseURL]; 257 | if (!self) { 258 | return nil; 259 | } 260 | 261 | self.requestSerializer = [decoder decodeObjectOfClass:[AFHTTPRequestSerializer class] forKey:NSStringFromSelector(@selector(requestSerializer))]; 262 | self.responseSerializer = [decoder decodeObjectOfClass:[AFHTTPResponseSerializer class] forKey:NSStringFromSelector(@selector(responseSerializer))]; 263 | 264 | return self; 265 | } 266 | 267 | - (void)encodeWithCoder:(NSCoder *)coder { 268 | [coder encodeObject:self.baseURL forKey:NSStringFromSelector(@selector(baseURL))]; 269 | [coder encodeObject:self.requestSerializer forKey:NSStringFromSelector(@selector(requestSerializer))]; 270 | [coder encodeObject:self.responseSerializer forKey:NSStringFromSelector(@selector(responseSerializer))]; 271 | } 272 | 273 | #pragma mark - NSCopying 274 | 275 | - (id)copyWithZone:(NSZone *)zone { 276 | AFHTTPRequestOperationManager *HTTPClient = [[[self class] allocWithZone:zone] initWithBaseURL:self.baseURL]; 277 | 278 | HTTPClient.requestSerializer = [self.requestSerializer copyWithZone:zone]; 279 | HTTPClient.responseSerializer = [self.responseSerializer copyWithZone:zone]; 280 | 281 | return HTTPClient; 282 | } 283 | 284 | @end 285 | -------------------------------------------------------------------------------- /Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.h: -------------------------------------------------------------------------------- 1 | // AFNetworkReachabilityManager.h 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #if !TARGET_OS_WATCH 25 | #import 26 | 27 | #ifndef NS_DESIGNATED_INITIALIZER 28 | #if __has_attribute(objc_designated_initializer) 29 | #define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) 30 | #else 31 | #define NS_DESIGNATED_INITIALIZER 32 | #endif 33 | #endif 34 | 35 | typedef NS_ENUM(NSInteger, AFNetworkReachabilityStatus) { 36 | AFNetworkReachabilityStatusUnknown = -1, 37 | AFNetworkReachabilityStatusNotReachable = 0, 38 | AFNetworkReachabilityStatusReachableViaWWAN = 1, 39 | AFNetworkReachabilityStatusReachableViaWiFi = 2, 40 | }; 41 | 42 | NS_ASSUME_NONNULL_BEGIN 43 | 44 | /** 45 | `AFNetworkReachabilityManager` monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces. 46 | 47 | 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. 48 | 49 | See Apple's Reachability Sample Code (https://developer.apple.com/library/ios/samplecode/reachability/) 50 | 51 | @warning Instances of `AFNetworkReachabilityManager` must be started with `-startMonitoring` before reachability status can be determined. 52 | */ 53 | @interface AFNetworkReachabilityManager : NSObject 54 | 55 | /** 56 | The current network reachability status. 57 | */ 58 | @property (readonly, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus; 59 | 60 | /** 61 | Whether or not the network is currently reachable. 62 | */ 63 | @property (readonly, nonatomic, assign, getter = isReachable) BOOL reachable; 64 | 65 | /** 66 | Whether or not the network is currently reachable via WWAN. 67 | */ 68 | @property (readonly, nonatomic, assign, getter = isReachableViaWWAN) BOOL reachableViaWWAN; 69 | 70 | /** 71 | Whether or not the network is currently reachable via WiFi. 72 | */ 73 | @property (readonly, nonatomic, assign, getter = isReachableViaWiFi) BOOL reachableViaWiFi; 74 | 75 | ///--------------------- 76 | /// @name Initialization 77 | ///--------------------- 78 | 79 | /** 80 | Returns the shared network reachability manager. 81 | */ 82 | + (instancetype)sharedManager; 83 | 84 | /** 85 | Creates and returns a network reachability manager for the specified domain. 86 | 87 | @param domain The domain used to evaluate network reachability. 88 | 89 | @return An initialized network reachability manager, actively monitoring the specified domain. 90 | */ 91 | + (instancetype)managerForDomain:(NSString *)domain; 92 | 93 | /** 94 | Creates and returns a network reachability manager for the socket address. 95 | 96 | @param address The socket address (`sockaddr_in`) used to evaluate network reachability. 97 | 98 | @return An initialized network reachability manager, actively monitoring the specified socket address. 99 | */ 100 | + (instancetype)managerForAddress:(const void *)address; 101 | 102 | /** 103 | Initializes an instance of a network reachability manager from the specified reachability object. 104 | 105 | @param reachability The reachability object to monitor. 106 | 107 | @return An initialized network reachability manager, actively monitoring the specified reachability. 108 | */ 109 | - (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability NS_DESIGNATED_INITIALIZER; 110 | 111 | ///-------------------------------------------------- 112 | /// @name Starting & Stopping Reachability Monitoring 113 | ///-------------------------------------------------- 114 | 115 | /** 116 | Starts monitoring for changes in network reachability status. 117 | */ 118 | - (void)startMonitoring; 119 | 120 | /** 121 | Stops monitoring for changes in network reachability status. 122 | */ 123 | - (void)stopMonitoring; 124 | 125 | ///------------------------------------------------- 126 | /// @name Getting Localized Reachability Description 127 | ///------------------------------------------------- 128 | 129 | /** 130 | Returns a localized string representation of the current network reachability status. 131 | */ 132 | - (NSString *)localizedNetworkReachabilityStatusString; 133 | 134 | ///--------------------------------------------------- 135 | /// @name Setting Network Reachability Change Callback 136 | ///--------------------------------------------------- 137 | 138 | /** 139 | Sets a callback to be executed when the network availability of the `baseURL` host changes. 140 | 141 | @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`. 142 | */ 143 | - (void)setReachabilityStatusChangeBlock:(nullable void (^)(AFNetworkReachabilityStatus status))block; 144 | 145 | @end 146 | 147 | ///---------------- 148 | /// @name Constants 149 | ///---------------- 150 | 151 | /** 152 | ## Network Reachability 153 | 154 | The following constants are provided by `AFNetworkReachabilityManager` as possible network reachability statuses. 155 | 156 | enum { 157 | AFNetworkReachabilityStatusUnknown, 158 | AFNetworkReachabilityStatusNotReachable, 159 | AFNetworkReachabilityStatusReachableViaWWAN, 160 | AFNetworkReachabilityStatusReachableViaWiFi, 161 | } 162 | 163 | `AFNetworkReachabilityStatusUnknown` 164 | The `baseURL` host reachability is not known. 165 | 166 | `AFNetworkReachabilityStatusNotReachable` 167 | The `baseURL` host cannot be reached. 168 | 169 | `AFNetworkReachabilityStatusReachableViaWWAN` 170 | The `baseURL` host can be reached via a cellular connection, such as EDGE or GPRS. 171 | 172 | `AFNetworkReachabilityStatusReachableViaWiFi` 173 | The `baseURL` host can be reached via a Wi-Fi connection. 174 | 175 | ### Keys for Notification UserInfo Dictionary 176 | 177 | Strings that are used as keys in a `userInfo` dictionary in a network reachability status change notification. 178 | 179 | `AFNetworkingReachabilityNotificationStatusItem` 180 | A key in the userInfo dictionary in a `AFNetworkingReachabilityDidChangeNotification` notification. 181 | The corresponding value is an `NSNumber` object representing the `AFNetworkReachabilityStatus` value for the current reachability status. 182 | */ 183 | 184 | ///-------------------- 185 | /// @name Notifications 186 | ///-------------------- 187 | 188 | /** 189 | Posted when network reachability changes. 190 | 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. 191 | 192 | @warning In order for network reachability to be monitored, include the `SystemConfiguration` framework in the active target's "Link Binary With Library" build phase, and add `#import ` to the header prefix of the project (`Prefix.pch`). 193 | */ 194 | extern NSString * const AFNetworkingReachabilityDidChangeNotification; 195 | extern NSString * const AFNetworkingReachabilityNotificationStatusItem; 196 | 197 | ///-------------------- 198 | /// @name Functions 199 | ///-------------------- 200 | 201 | /** 202 | Returns a localized string representation of an `AFNetworkReachabilityStatus` value. 203 | */ 204 | extern NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status); 205 | 206 | NS_ASSUME_NONNULL_END 207 | #endif 208 | -------------------------------------------------------------------------------- /Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.m: -------------------------------------------------------------------------------- 1 | // AFNetworkReachabilityManager.m 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import "AFNetworkReachabilityManager.h" 23 | #if !TARGET_OS_WATCH 24 | 25 | #import 26 | #import 27 | #import 28 | #import 29 | #import 30 | 31 | NSString * const AFNetworkingReachabilityDidChangeNotification = @"com.alamofire.networking.reachability.change"; 32 | NSString * const AFNetworkingReachabilityNotificationStatusItem = @"AFNetworkingReachabilityNotificationStatusItem"; 33 | 34 | typedef void (^AFNetworkReachabilityStatusBlock)(AFNetworkReachabilityStatus status); 35 | 36 | typedef NS_ENUM(NSUInteger, AFNetworkReachabilityAssociation) { 37 | AFNetworkReachabilityForAddress = 1, 38 | AFNetworkReachabilityForAddressPair = 2, 39 | AFNetworkReachabilityForName = 3, 40 | }; 41 | 42 | NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status) { 43 | switch (status) { 44 | case AFNetworkReachabilityStatusNotReachable: 45 | return NSLocalizedStringFromTable(@"Not Reachable", @"AFNetworking", nil); 46 | case AFNetworkReachabilityStatusReachableViaWWAN: 47 | return NSLocalizedStringFromTable(@"Reachable via WWAN", @"AFNetworking", nil); 48 | case AFNetworkReachabilityStatusReachableViaWiFi: 49 | return NSLocalizedStringFromTable(@"Reachable via WiFi", @"AFNetworking", nil); 50 | case AFNetworkReachabilityStatusUnknown: 51 | default: 52 | return NSLocalizedStringFromTable(@"Unknown", @"AFNetworking", nil); 53 | } 54 | } 55 | 56 | static AFNetworkReachabilityStatus AFNetworkReachabilityStatusForFlags(SCNetworkReachabilityFlags flags) { 57 | BOOL isReachable = ((flags & kSCNetworkReachabilityFlagsReachable) != 0); 58 | BOOL needsConnection = ((flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0); 59 | BOOL canConnectionAutomatically = (((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0) || ((flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0)); 60 | BOOL canConnectWithoutUserInteraction = (canConnectionAutomatically && (flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0); 61 | BOOL isNetworkReachable = (isReachable && (!needsConnection || canConnectWithoutUserInteraction)); 62 | 63 | AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusUnknown; 64 | if (isNetworkReachable == NO) { 65 | status = AFNetworkReachabilityStatusNotReachable; 66 | } 67 | #if TARGET_OS_IPHONE 68 | else if ((flags & kSCNetworkReachabilityFlagsIsWWAN) != 0) { 69 | status = AFNetworkReachabilityStatusReachableViaWWAN; 70 | } 71 | #endif 72 | else { 73 | status = AFNetworkReachabilityStatusReachableViaWiFi; 74 | } 75 | 76 | return status; 77 | } 78 | 79 | static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNetworkReachabilityFlags flags, void *info) { 80 | AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusForFlags(flags); 81 | AFNetworkReachabilityStatusBlock block = (__bridge AFNetworkReachabilityStatusBlock)info; 82 | if (block) { 83 | block(status); 84 | } 85 | 86 | 87 | dispatch_async(dispatch_get_main_queue(), ^{ 88 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 89 | NSDictionary *userInfo = @{ AFNetworkingReachabilityNotificationStatusItem: @(status) }; 90 | [notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:userInfo]; 91 | }); 92 | 93 | } 94 | 95 | static const void * AFNetworkReachabilityRetainCallback(const void *info) { 96 | return Block_copy(info); 97 | } 98 | 99 | static void AFNetworkReachabilityReleaseCallback(const void *info) { 100 | if (info) { 101 | Block_release(info); 102 | } 103 | } 104 | 105 | @interface AFNetworkReachabilityManager () 106 | @property (readwrite, nonatomic, strong) id networkReachability; 107 | @property (readwrite, nonatomic, assign) AFNetworkReachabilityAssociation networkReachabilityAssociation; 108 | @property (readwrite, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus; 109 | @property (readwrite, nonatomic, copy) AFNetworkReachabilityStatusBlock networkReachabilityStatusBlock; 110 | @end 111 | 112 | @implementation AFNetworkReachabilityManager 113 | 114 | + (instancetype)sharedManager { 115 | static AFNetworkReachabilityManager *_sharedManager = nil; 116 | static dispatch_once_t onceToken; 117 | dispatch_once(&onceToken, ^{ 118 | struct sockaddr_in address; 119 | bzero(&address, sizeof(address)); 120 | address.sin_len = sizeof(address); 121 | address.sin_family = AF_INET; 122 | 123 | _sharedManager = [self managerForAddress:&address]; 124 | }); 125 | 126 | return _sharedManager; 127 | } 128 | 129 | + (instancetype)managerForDomain:(NSString *)domain { 130 | SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, [domain UTF8String]); 131 | 132 | AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability]; 133 | manager.networkReachabilityAssociation = AFNetworkReachabilityForName; 134 | 135 | return manager; 136 | } 137 | 138 | + (instancetype)managerForAddress:(const void *)address { 139 | SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr *)address); 140 | 141 | AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability]; 142 | manager.networkReachabilityAssociation = AFNetworkReachabilityForAddress; 143 | 144 | return manager; 145 | } 146 | 147 | - (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability { 148 | self = [super init]; 149 | if (!self) { 150 | return nil; 151 | } 152 | 153 | self.networkReachability = CFBridgingRelease(reachability); 154 | self.networkReachabilityStatus = AFNetworkReachabilityStatusUnknown; 155 | 156 | return self; 157 | } 158 | 159 | - (instancetype)init NS_UNAVAILABLE 160 | { 161 | return nil; 162 | } 163 | 164 | - (void)dealloc { 165 | [self stopMonitoring]; 166 | } 167 | 168 | #pragma mark - 169 | 170 | - (BOOL)isReachable { 171 | return [self isReachableViaWWAN] || [self isReachableViaWiFi]; 172 | } 173 | 174 | - (BOOL)isReachableViaWWAN { 175 | return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWWAN; 176 | } 177 | 178 | - (BOOL)isReachableViaWiFi { 179 | return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWiFi; 180 | } 181 | 182 | #pragma mark - 183 | 184 | - (void)startMonitoring { 185 | [self stopMonitoring]; 186 | 187 | if (!self.networkReachability) { 188 | return; 189 | } 190 | 191 | __weak __typeof(self)weakSelf = self; 192 | AFNetworkReachabilityStatusBlock callback = ^(AFNetworkReachabilityStatus status) { 193 | __strong __typeof(weakSelf)strongSelf = weakSelf; 194 | 195 | strongSelf.networkReachabilityStatus = status; 196 | if (strongSelf.networkReachabilityStatusBlock) { 197 | strongSelf.networkReachabilityStatusBlock(status); 198 | } 199 | 200 | }; 201 | 202 | id networkReachability = self.networkReachability; 203 | SCNetworkReachabilityContext context = {0, (__bridge void *)callback, AFNetworkReachabilityRetainCallback, AFNetworkReachabilityReleaseCallback, NULL}; 204 | SCNetworkReachabilitySetCallback((__bridge SCNetworkReachabilityRef)networkReachability, AFNetworkReachabilityCallback, &context); 205 | SCNetworkReachabilityScheduleWithRunLoop((__bridge SCNetworkReachabilityRef)networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes); 206 | 207 | switch (self.networkReachabilityAssociation) { 208 | case AFNetworkReachabilityForName: 209 | break; 210 | case AFNetworkReachabilityForAddress: 211 | case AFNetworkReachabilityForAddressPair: 212 | default: { 213 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0),^{ 214 | SCNetworkReachabilityFlags flags; 215 | SCNetworkReachabilityGetFlags((__bridge SCNetworkReachabilityRef)networkReachability, &flags); 216 | AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusForFlags(flags); 217 | dispatch_async(dispatch_get_main_queue(), ^{ 218 | callback(status); 219 | 220 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 221 | [notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:@{ AFNetworkingReachabilityNotificationStatusItem: @(status) }]; 222 | 223 | 224 | }); 225 | }); 226 | } 227 | break; 228 | } 229 | } 230 | 231 | - (void)stopMonitoring { 232 | if (!self.networkReachability) { 233 | return; 234 | } 235 | 236 | SCNetworkReachabilityUnscheduleFromRunLoop((__bridge SCNetworkReachabilityRef)self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes); 237 | } 238 | 239 | #pragma mark - 240 | 241 | - (NSString *)localizedNetworkReachabilityStatusString { 242 | return AFStringFromNetworkReachabilityStatus(self.networkReachabilityStatus); 243 | } 244 | 245 | #pragma mark - 246 | 247 | - (void)setReachabilityStatusChangeBlock:(void (^)(AFNetworkReachabilityStatus status))block { 248 | self.networkReachabilityStatusBlock = block; 249 | } 250 | 251 | #pragma mark - NSKeyValueObserving 252 | 253 | + (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key { 254 | if ([key isEqualToString:@"reachable"] || [key isEqualToString:@"reachableViaWWAN"] || [key isEqualToString:@"reachableViaWiFi"]) { 255 | return [NSSet setWithObject:@"networkReachabilityStatus"]; 256 | } 257 | 258 | return [super keyPathsForValuesAffectingValueForKey:key]; 259 | } 260 | 261 | @end 262 | #endif 263 | -------------------------------------------------------------------------------- /Pods/AFNetworking/AFNetworking/AFNetworking.h: -------------------------------------------------------------------------------- 1 | // AFNetworking.h 2 | // 3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | #import 25 | 26 | #ifndef _AFNETWORKING_ 27 | #define _AFNETWORKING_ 28 | 29 | #import "AFURLRequestSerialization.h" 30 | #import "AFURLResponseSerialization.h" 31 | #import "AFSecurityPolicy.h" 32 | #if !TARGET_OS_WATCH 33 | #import "AFNetworkReachabilityManager.h" 34 | #import "AFURLConnectionOperation.h" 35 | #import "AFHTTPRequestOperation.h" 36 | #import "AFHTTPRequestOperationManager.h" 37 | #endif 38 | 39 | #if ( ( defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) || \ 40 | ( defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 ) || \ 41 | TARGET_OS_WATCH ) 42 | #import "AFURLSessionManager.h" 43 | #import "AFHTTPSessionManager.h" 44 | #endif 45 | 46 | #endif /* _AFNETWORKING_ */ 47 | -------------------------------------------------------------------------------- /Pods/AFNetworking/AFNetworking/AFSecurityPolicy.h: -------------------------------------------------------------------------------- 1 | // AFSecurityPolicy.h 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | #import 24 | 25 | typedef NS_ENUM(NSUInteger, AFSSLPinningMode) { 26 | AFSSLPinningModeNone, 27 | AFSSLPinningModePublicKey, 28 | AFSSLPinningModeCertificate, 29 | }; 30 | 31 | /** 32 | `AFSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections. 33 | 34 | Adding pinned SSL certificates to your app helps prevent man-in-the-middle attacks and other vulnerabilities. Applications dealing with sensitive customer data or financial information are strongly encouraged to route all communication over an HTTPS connection with SSL pinning configured and enabled. 35 | */ 36 | 37 | NS_ASSUME_NONNULL_BEGIN 38 | 39 | @interface AFSecurityPolicy : NSObject 40 | 41 | /** 42 | The criteria by which server trust should be evaluated against the pinned SSL certificates. Defaults to `AFSSLPinningModeNone`. 43 | */ 44 | @property (readonly, nonatomic, assign) AFSSLPinningMode SSLPinningMode; 45 | 46 | /** 47 | The certificates used to evaluate server trust according to the SSL pinning mode. By default, this property is set to any (`.cer`) certificates included in the app bundle. Note that if you create an array with duplicate certificates, the duplicate certificates will be removed. Note that if pinning is enabled, `evaluateServerTrust:forDomain:` will return true if any pinned certificate matches. 48 | */ 49 | @property (nonatomic, strong, nullable) NSArray *pinnedCertificates; 50 | 51 | /** 52 | Whether or not to trust servers with an invalid or expired SSL certificates. Defaults to `NO`. 53 | */ 54 | @property (nonatomic, assign) BOOL allowInvalidCertificates; 55 | 56 | /** 57 | Whether or not to validate the domain name in the certificate's CN field. Defaults to `YES`. 58 | */ 59 | @property (nonatomic, assign) BOOL validatesDomainName; 60 | 61 | ///----------------------------------------- 62 | /// @name Getting Specific Security Policies 63 | ///----------------------------------------- 64 | 65 | /** 66 | 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. 67 | 68 | @return The default security policy. 69 | */ 70 | + (instancetype)defaultPolicy; 71 | 72 | ///--------------------- 73 | /// @name Initialization 74 | ///--------------------- 75 | 76 | /** 77 | Creates and returns a security policy with the specified pinning mode. 78 | 79 | @param pinningMode The SSL pinning mode. 80 | 81 | @return A new security policy. 82 | */ 83 | + (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode; 84 | 85 | ///------------------------------ 86 | /// @name Evaluating Server Trust 87 | ///------------------------------ 88 | 89 | /** 90 | Whether or not the specified server trust should be accepted, based on the security policy. 91 | 92 | This method should be used when responding to an authentication challenge from a server. 93 | 94 | @param serverTrust The X.509 certificate trust of the server. 95 | 96 | @return Whether or not to trust the server. 97 | 98 | @warning This method has been deprecated in favor of `-evaluateServerTrust:forDomain:`. 99 | */ 100 | - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust DEPRECATED_ATTRIBUTE; 101 | 102 | /** 103 | Whether or not the specified server trust should be accepted, based on the security policy. 104 | 105 | This method should be used when responding to an authentication challenge from a server. 106 | 107 | @param serverTrust The X.509 certificate trust of the server. 108 | @param domain The domain of serverTrust. If `nil`, the domain will not be validated. 109 | 110 | @return Whether or not to trust the server. 111 | */ 112 | - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust 113 | forDomain:(nullable NSString *)domain; 114 | 115 | @end 116 | 117 | NS_ASSUME_NONNULL_END 118 | 119 | ///---------------- 120 | /// @name Constants 121 | ///---------------- 122 | 123 | /** 124 | ## SSL Pinning Modes 125 | 126 | The following constants are provided by `AFSSLPinningMode` as possible SSL pinning modes. 127 | 128 | enum { 129 | AFSSLPinningModeNone, 130 | AFSSLPinningModePublicKey, 131 | AFSSLPinningModeCertificate, 132 | } 133 | 134 | `AFSSLPinningModeNone` 135 | Do not used pinned certificates to validate servers. 136 | 137 | `AFSSLPinningModePublicKey` 138 | Validate host certificates against public keys of pinned certificates. 139 | 140 | `AFSSLPinningModeCertificate` 141 | Validate host certificates against pinned certificates. 142 | */ 143 | -------------------------------------------------------------------------------- /Pods/AFNetworking/AFNetworking/AFSecurityPolicy.m: -------------------------------------------------------------------------------- 1 | // AFSecurityPolicy.m 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import "AFSecurityPolicy.h" 23 | 24 | #import 25 | 26 | #if !TARGET_OS_IOS && !TARGET_OS_WATCH 27 | static NSData * AFSecKeyGetData(SecKeyRef key) { 28 | CFDataRef data = NULL; 29 | 30 | __Require_noErr_Quiet(SecItemExport(key, kSecFormatUnknown, kSecItemPemArmour, NULL, &data), _out); 31 | 32 | return (__bridge_transfer NSData *)data; 33 | 34 | _out: 35 | if (data) { 36 | CFRelease(data); 37 | } 38 | 39 | return nil; 40 | } 41 | #endif 42 | 43 | static BOOL AFSecKeyIsEqualToKey(SecKeyRef key1, SecKeyRef key2) { 44 | #if TARGET_OS_IOS || TARGET_OS_WATCH 45 | return [(__bridge id)key1 isEqual:(__bridge id)key2]; 46 | #else 47 | return [AFSecKeyGetData(key1) isEqual:AFSecKeyGetData(key2)]; 48 | #endif 49 | } 50 | 51 | static id AFPublicKeyForCertificate(NSData *certificate) { 52 | id allowedPublicKey = nil; 53 | SecCertificateRef allowedCertificate; 54 | SecCertificateRef allowedCertificates[1]; 55 | CFArrayRef tempCertificates = nil; 56 | SecPolicyRef policy = nil; 57 | SecTrustRef allowedTrust = nil; 58 | SecTrustResultType result; 59 | 60 | allowedCertificate = SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificate); 61 | __Require_Quiet(allowedCertificate != NULL, _out); 62 | 63 | allowedCertificates[0] = allowedCertificate; 64 | tempCertificates = CFArrayCreate(NULL, (const void **)allowedCertificates, 1, NULL); 65 | 66 | policy = SecPolicyCreateBasicX509(); 67 | __Require_noErr_Quiet(SecTrustCreateWithCertificates(tempCertificates, policy, &allowedTrust), _out); 68 | __Require_noErr_Quiet(SecTrustEvaluate(allowedTrust, &result), _out); 69 | 70 | allowedPublicKey = (__bridge_transfer id)SecTrustCopyPublicKey(allowedTrust); 71 | 72 | _out: 73 | if (allowedTrust) { 74 | CFRelease(allowedTrust); 75 | } 76 | 77 | if (policy) { 78 | CFRelease(policy); 79 | } 80 | 81 | if (tempCertificates) { 82 | CFRelease(tempCertificates); 83 | } 84 | 85 | if (allowedCertificate) { 86 | CFRelease(allowedCertificate); 87 | } 88 | 89 | return allowedPublicKey; 90 | } 91 | 92 | static BOOL AFServerTrustIsValid(SecTrustRef serverTrust) { 93 | BOOL isValid = NO; 94 | SecTrustResultType result; 95 | __Require_noErr_Quiet(SecTrustEvaluate(serverTrust, &result), _out); 96 | 97 | isValid = (result == kSecTrustResultUnspecified || result == kSecTrustResultProceed); 98 | 99 | _out: 100 | return isValid; 101 | } 102 | 103 | static NSArray * AFCertificateTrustChainForServerTrust(SecTrustRef serverTrust) { 104 | CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust); 105 | NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount]; 106 | 107 | for (CFIndex i = 0; i < certificateCount; i++) { 108 | SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i); 109 | [trustChain addObject:(__bridge_transfer NSData *)SecCertificateCopyData(certificate)]; 110 | } 111 | 112 | return [NSArray arrayWithArray:trustChain]; 113 | } 114 | 115 | static NSArray * AFPublicKeyTrustChainForServerTrust(SecTrustRef serverTrust) { 116 | SecPolicyRef policy = SecPolicyCreateBasicX509(); 117 | CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust); 118 | NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount]; 119 | for (CFIndex i = 0; i < certificateCount; i++) { 120 | SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i); 121 | 122 | SecCertificateRef someCertificates[] = {certificate}; 123 | CFArrayRef certificates = CFArrayCreate(NULL, (const void **)someCertificates, 1, NULL); 124 | 125 | SecTrustRef trust; 126 | __Require_noErr_Quiet(SecTrustCreateWithCertificates(certificates, policy, &trust), _out); 127 | 128 | SecTrustResultType result; 129 | __Require_noErr_Quiet(SecTrustEvaluate(trust, &result), _out); 130 | 131 | [trustChain addObject:(__bridge_transfer id)SecTrustCopyPublicKey(trust)]; 132 | 133 | _out: 134 | if (trust) { 135 | CFRelease(trust); 136 | } 137 | 138 | if (certificates) { 139 | CFRelease(certificates); 140 | } 141 | 142 | continue; 143 | } 144 | CFRelease(policy); 145 | 146 | return [NSArray arrayWithArray:trustChain]; 147 | } 148 | 149 | #pragma mark - 150 | 151 | @interface AFSecurityPolicy() 152 | @property (readwrite, nonatomic, assign) AFSSLPinningMode SSLPinningMode; 153 | @property (readwrite, nonatomic, strong) NSArray *pinnedPublicKeys; 154 | @end 155 | 156 | @implementation AFSecurityPolicy 157 | 158 | + (NSArray *)defaultPinnedCertificates { 159 | static NSArray *_defaultPinnedCertificates = nil; 160 | static dispatch_once_t onceToken; 161 | dispatch_once(&onceToken, ^{ 162 | NSBundle *bundle = [NSBundle bundleForClass:[self class]]; 163 | NSArray *paths = [bundle pathsForResourcesOfType:@"cer" inDirectory:@"."]; 164 | 165 | NSMutableArray *certificates = [NSMutableArray arrayWithCapacity:[paths count]]; 166 | for (NSString *path in paths) { 167 | NSData *certificateData = [NSData dataWithContentsOfFile:path]; 168 | [certificates addObject:certificateData]; 169 | } 170 | 171 | _defaultPinnedCertificates = [[NSArray alloc] initWithArray:certificates]; 172 | }); 173 | 174 | return _defaultPinnedCertificates; 175 | } 176 | 177 | + (instancetype)defaultPolicy { 178 | AFSecurityPolicy *securityPolicy = [[self alloc] init]; 179 | securityPolicy.SSLPinningMode = AFSSLPinningModeNone; 180 | 181 | return securityPolicy; 182 | } 183 | 184 | + (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode { 185 | AFSecurityPolicy *securityPolicy = [[self alloc] init]; 186 | securityPolicy.SSLPinningMode = pinningMode; 187 | 188 | [securityPolicy setPinnedCertificates:[self defaultPinnedCertificates]]; 189 | 190 | return securityPolicy; 191 | } 192 | 193 | - (id)init { 194 | self = [super init]; 195 | if (!self) { 196 | return nil; 197 | } 198 | 199 | self.validatesDomainName = YES; 200 | 201 | return self; 202 | } 203 | 204 | - (void)setPinnedCertificates:(NSArray *)pinnedCertificates { 205 | _pinnedCertificates = [[NSOrderedSet orderedSetWithArray:pinnedCertificates] array]; 206 | 207 | if (self.pinnedCertificates) { 208 | NSMutableArray *mutablePinnedPublicKeys = [NSMutableArray arrayWithCapacity:[self.pinnedCertificates count]]; 209 | for (NSData *certificate in self.pinnedCertificates) { 210 | id publicKey = AFPublicKeyForCertificate(certificate); 211 | if (!publicKey) { 212 | continue; 213 | } 214 | [mutablePinnedPublicKeys addObject:publicKey]; 215 | } 216 | self.pinnedPublicKeys = [NSArray arrayWithArray:mutablePinnedPublicKeys]; 217 | } else { 218 | self.pinnedPublicKeys = nil; 219 | } 220 | } 221 | 222 | #pragma mark - 223 | 224 | - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust { 225 | return [self evaluateServerTrust:serverTrust forDomain:nil]; 226 | } 227 | 228 | - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust 229 | forDomain:(NSString *)domain 230 | { 231 | if (domain && self.allowInvalidCertificates && self.validatesDomainName && (self.SSLPinningMode == AFSSLPinningModeNone || [self.pinnedCertificates count] == 0)) { 232 | // https://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/NetworkingTopics/Articles/OverridingSSLChainValidationCorrectly.html 233 | // According to the docs, you should only trust your provided certs for evaluation. 234 | // Pinned certificates are added to the trust. Without pinned certificates, 235 | // there is nothing to evaluate against. 236 | // 237 | // From Apple Docs: 238 | // "Do not implicitly trust self-signed certificates as anchors (kSecTrustOptionImplicitAnchors). 239 | // Instead, add your own (self-signed) CA certificate to the list of trusted anchors." 240 | NSLog(@"In order to validate a domain name for self signed certificates, you MUST use pinning."); 241 | return NO; 242 | } 243 | 244 | NSMutableArray *policies = [NSMutableArray array]; 245 | if (self.validatesDomainName) { 246 | [policies addObject:(__bridge_transfer id)SecPolicyCreateSSL(true, (__bridge CFStringRef)domain)]; 247 | } else { 248 | [policies addObject:(__bridge_transfer id)SecPolicyCreateBasicX509()]; 249 | } 250 | 251 | SecTrustSetPolicies(serverTrust, (__bridge CFArrayRef)policies); 252 | 253 | if (self.SSLPinningMode == AFSSLPinningModeNone) { 254 | if (self.allowInvalidCertificates || AFServerTrustIsValid(serverTrust)){ 255 | return YES; 256 | } else { 257 | return NO; 258 | } 259 | } else if (!AFServerTrustIsValid(serverTrust) && !self.allowInvalidCertificates) { 260 | return NO; 261 | } 262 | 263 | NSArray *serverCertificates = AFCertificateTrustChainForServerTrust(serverTrust); 264 | switch (self.SSLPinningMode) { 265 | case AFSSLPinningModeNone: 266 | default: 267 | return NO; 268 | case AFSSLPinningModeCertificate: { 269 | NSMutableArray *pinnedCertificates = [NSMutableArray array]; 270 | for (NSData *certificateData in self.pinnedCertificates) { 271 | [pinnedCertificates addObject:(__bridge_transfer id)SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificateData)]; 272 | } 273 | SecTrustSetAnchorCertificates(serverTrust, (__bridge CFArrayRef)pinnedCertificates); 274 | 275 | if (!AFServerTrustIsValid(serverTrust)) { 276 | return NO; 277 | } 278 | 279 | NSUInteger trustedCertificateCount = 0; 280 | for (NSData *trustChainCertificate in serverCertificates) { 281 | if ([self.pinnedCertificates containsObject:trustChainCertificate]) { 282 | trustedCertificateCount++; 283 | } 284 | } 285 | return trustedCertificateCount > 0; 286 | } 287 | case AFSSLPinningModePublicKey: { 288 | NSUInteger trustedPublicKeyCount = 0; 289 | NSArray *publicKeys = AFPublicKeyTrustChainForServerTrust(serverTrust); 290 | 291 | for (id trustChainPublicKey in publicKeys) { 292 | for (id pinnedPublicKey in self.pinnedPublicKeys) { 293 | if (AFSecKeyIsEqualToKey((__bridge SecKeyRef)trustChainPublicKey, (__bridge SecKeyRef)pinnedPublicKey)) { 294 | trustedPublicKeyCount += 1; 295 | } 296 | } 297 | } 298 | return trustedPublicKeyCount > 0; 299 | } 300 | } 301 | 302 | return NO; 303 | } 304 | 305 | #pragma mark - NSKeyValueObserving 306 | 307 | + (NSSet *)keyPathsForValuesAffectingPinnedPublicKeys { 308 | return [NSSet setWithObject:@"pinnedCertificates"]; 309 | } 310 | 311 | @end 312 | -------------------------------------------------------------------------------- /Pods/AFNetworking/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h: -------------------------------------------------------------------------------- 1 | // AFNetworkActivityIndicatorManager.h 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #import 25 | 26 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 27 | 28 | #import 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | /** 33 | `AFNetworkActivityIndicatorManager` manages the state of the network activity indicator in the status bar. When enabled, it will listen for notifications indicating that a network request operation has started or finished, and start or stop animating the indicator accordingly. The number of active requests is incremented and decremented much like a stack or a semaphore, and the activity indicator will animate so long as that number is greater than zero. 34 | 35 | You should enable the shared instance of `AFNetworkActivityIndicatorManager` when your application finishes launching. In `AppDelegate application:didFinishLaunchingWithOptions:` you can do so with the following code: 36 | 37 | [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES]; 38 | 39 | By setting `enabled` to `YES` for `sharedManager`, the network activity indicator will show and hide automatically as requests start and finish. You should not ever need to call `incrementActivityCount` or `decrementActivityCount` yourself. 40 | 41 | See the Apple Human Interface Guidelines section about the Network Activity Indicator for more information: 42 | http://developer.apple.com/library/iOS/#documentation/UserExperience/Conceptual/MobileHIG/UIElementGuidelines/UIElementGuidelines.html#//apple_ref/doc/uid/TP40006556-CH13-SW44 43 | */ 44 | NS_EXTENSION_UNAVAILABLE_IOS("Use view controller based solutions where appropriate instead.") 45 | @interface AFNetworkActivityIndicatorManager : NSObject 46 | 47 | /** 48 | A Boolean value indicating whether the manager is enabled. 49 | 50 | If YES, the manager will change status bar network activity indicator according to network operation notifications it receives. The default value is NO. 51 | */ 52 | @property (nonatomic, assign, getter = isEnabled) BOOL enabled; 53 | 54 | /** 55 | A Boolean value indicating whether the network activity indicator is currently displayed in the status bar. 56 | */ 57 | @property (readonly, nonatomic, assign) BOOL isNetworkActivityIndicatorVisible; 58 | 59 | /** 60 | Returns the shared network activity indicator manager object for the system. 61 | 62 | @return The systemwide network activity indicator manager. 63 | */ 64 | + (instancetype)sharedManager; 65 | 66 | /** 67 | Increments the number of active network requests. If this number was zero before incrementing, this will start animating the status bar network activity indicator. 68 | */ 69 | - (void)incrementActivityCount; 70 | 71 | /** 72 | Decrements the number of active network requests. If this number becomes zero after decrementing, this will stop animating the status bar network activity indicator. 73 | */ 74 | - (void)decrementActivityCount; 75 | 76 | @end 77 | 78 | NS_ASSUME_NONNULL_END 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m: -------------------------------------------------------------------------------- 1 | // AFNetworkActivityIndicatorManager.m 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import "AFNetworkActivityIndicatorManager.h" 23 | 24 | #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) 25 | 26 | #import "AFHTTPRequestOperation.h" 27 | 28 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 29 | #import "AFURLSessionManager.h" 30 | #endif 31 | 32 | static NSTimeInterval const kAFNetworkActivityIndicatorInvisibilityDelay = 0.17; 33 | 34 | static NSURLRequest * AFNetworkRequestFromNotification(NSNotification *notification) { 35 | if ([[notification object] isKindOfClass:[AFURLConnectionOperation class]]) { 36 | return [(AFURLConnectionOperation *)[notification object] request]; 37 | } 38 | 39 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 40 | if ([[notification object] respondsToSelector:@selector(originalRequest)]) { 41 | return [(NSURLSessionTask *)[notification object] originalRequest]; 42 | } 43 | #endif 44 | 45 | return nil; 46 | } 47 | 48 | @interface AFNetworkActivityIndicatorManager () 49 | @property (readwrite, nonatomic, assign) NSInteger activityCount; 50 | @property (readwrite, nonatomic, strong) NSTimer *activityIndicatorVisibilityTimer; 51 | @property (readonly, nonatomic, getter = isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible; 52 | 53 | - (void)updateNetworkActivityIndicatorVisibility; 54 | - (void)updateNetworkActivityIndicatorVisibilityDelayed; 55 | @end 56 | 57 | @implementation AFNetworkActivityIndicatorManager 58 | @dynamic networkActivityIndicatorVisible; 59 | 60 | + (instancetype)sharedManager { 61 | static AFNetworkActivityIndicatorManager *_sharedManager = nil; 62 | static dispatch_once_t oncePredicate; 63 | dispatch_once(&oncePredicate, ^{ 64 | _sharedManager = [[self alloc] init]; 65 | }); 66 | 67 | return _sharedManager; 68 | } 69 | 70 | + (NSSet *)keyPathsForValuesAffectingIsNetworkActivityIndicatorVisible { 71 | return [NSSet setWithObject:@"activityCount"]; 72 | } 73 | 74 | - (id)init { 75 | self = [super init]; 76 | if (!self) { 77 | return nil; 78 | } 79 | 80 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidStart:) name:AFNetworkingOperationDidStartNotification object:nil]; 81 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingOperationDidFinishNotification object:nil]; 82 | 83 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 84 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidStart:) name:AFNetworkingTaskDidResumeNotification object:nil]; 85 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingTaskDidSuspendNotification object:nil]; 86 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingTaskDidCompleteNotification object:nil]; 87 | #endif 88 | 89 | return self; 90 | } 91 | 92 | - (void)dealloc { 93 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 94 | 95 | [_activityIndicatorVisibilityTimer invalidate]; 96 | } 97 | 98 | - (void)updateNetworkActivityIndicatorVisibilityDelayed { 99 | if (self.enabled) { 100 | // Delay hiding of activity indicator for a short interval, to avoid flickering 101 | if (![self isNetworkActivityIndicatorVisible]) { 102 | [self.activityIndicatorVisibilityTimer invalidate]; 103 | self.activityIndicatorVisibilityTimer = [NSTimer timerWithTimeInterval:kAFNetworkActivityIndicatorInvisibilityDelay target:self selector:@selector(updateNetworkActivityIndicatorVisibility) userInfo:nil repeats:NO]; 104 | [[NSRunLoop mainRunLoop] addTimer:self.activityIndicatorVisibilityTimer forMode:NSRunLoopCommonModes]; 105 | } else { 106 | [self performSelectorOnMainThread:@selector(updateNetworkActivityIndicatorVisibility) withObject:nil waitUntilDone:NO modes:@[NSRunLoopCommonModes]]; 107 | } 108 | } 109 | } 110 | 111 | - (BOOL)isNetworkActivityIndicatorVisible { 112 | return self.activityCount > 0; 113 | } 114 | 115 | - (void)updateNetworkActivityIndicatorVisibility { 116 | [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:[self isNetworkActivityIndicatorVisible]]; 117 | } 118 | 119 | - (void)setActivityCount:(NSInteger)activityCount { 120 | @synchronized(self) { 121 | _activityCount = activityCount; 122 | } 123 | 124 | dispatch_async(dispatch_get_main_queue(), ^{ 125 | [self updateNetworkActivityIndicatorVisibilityDelayed]; 126 | }); 127 | } 128 | 129 | - (void)incrementActivityCount { 130 | [self willChangeValueForKey:@"activityCount"]; 131 | @synchronized(self) { 132 | _activityCount++; 133 | } 134 | [self didChangeValueForKey:@"activityCount"]; 135 | 136 | dispatch_async(dispatch_get_main_queue(), ^{ 137 | [self updateNetworkActivityIndicatorVisibilityDelayed]; 138 | }); 139 | } 140 | 141 | - (void)decrementActivityCount { 142 | [self willChangeValueForKey:@"activityCount"]; 143 | @synchronized(self) { 144 | #pragma clang diagnostic push 145 | #pragma clang diagnostic ignored "-Wgnu" 146 | _activityCount = MAX(_activityCount - 1, 0); 147 | #pragma clang diagnostic pop 148 | } 149 | [self didChangeValueForKey:@"activityCount"]; 150 | 151 | dispatch_async(dispatch_get_main_queue(), ^{ 152 | [self updateNetworkActivityIndicatorVisibilityDelayed]; 153 | }); 154 | } 155 | 156 | - (void)networkRequestDidStart:(NSNotification *)notification { 157 | if ([AFNetworkRequestFromNotification(notification) URL]) { 158 | [self incrementActivityCount]; 159 | } 160 | } 161 | 162 | - (void)networkRequestDidFinish:(NSNotification *)notification { 163 | if ([AFNetworkRequestFromNotification(notification) URL]) { 164 | [self decrementActivityCount]; 165 | } 166 | } 167 | 168 | @end 169 | 170 | #endif 171 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIActivityIndicatorView+AFNetworking.h 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #import 25 | 26 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 27 | 28 | #import 29 | 30 | @class AFURLConnectionOperation; 31 | 32 | /** 33 | 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 request operation or session task. 34 | */ 35 | @interface UIActivityIndicatorView (AFNetworking) 36 | 37 | ///---------------------------------- 38 | /// @name Animating for Session Tasks 39 | ///---------------------------------- 40 | 41 | /** 42 | Binds the animating state to the state of the specified task. 43 | 44 | @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled. 45 | */ 46 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 47 | - (void)setAnimatingWithStateOfTask:(nullable NSURLSessionTask *)task; 48 | #endif 49 | 50 | ///--------------------------------------- 51 | /// @name Animating for Request Operations 52 | ///--------------------------------------- 53 | 54 | /** 55 | Binds the animating state to the execution state of the specified operation. 56 | 57 | @param operation The operation. If `nil`, automatic updating from any previously specified operation will be disabled. 58 | */ 59 | - (void)setAnimatingWithStateOfOperation:(nullable AFURLConnectionOperation *)operation; 60 | 61 | @end 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIActivityIndicatorView+AFNetworking.m 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import "UIActivityIndicatorView+AFNetworking.h" 23 | #import 24 | 25 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 26 | 27 | #import "AFHTTPRequestOperation.h" 28 | 29 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 30 | #import "AFURLSessionManager.h" 31 | #endif 32 | 33 | @interface AFActivityIndicatorViewNotificationObserver : NSObject 34 | @property (readonly, nonatomic, weak) UIActivityIndicatorView *activityIndicatorView; 35 | - (instancetype)initWithActivityIndicatorView:(UIActivityIndicatorView *)activityIndicatorView; 36 | 37 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 38 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task; 39 | #endif 40 | - (void)setAnimatingWithStateOfOperation:(AFURLConnectionOperation *)operation; 41 | 42 | @end 43 | 44 | @implementation UIActivityIndicatorView (AFNetworking) 45 | 46 | - (AFActivityIndicatorViewNotificationObserver *)af_notificationObserver { 47 | AFActivityIndicatorViewNotificationObserver *notificationObserver = objc_getAssociatedObject(self, @selector(af_notificationObserver)); 48 | if (notificationObserver == nil) { 49 | notificationObserver = [[AFActivityIndicatorViewNotificationObserver alloc] initWithActivityIndicatorView:self]; 50 | objc_setAssociatedObject(self, @selector(af_notificationObserver), notificationObserver, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 51 | } 52 | return notificationObserver; 53 | } 54 | 55 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 56 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task { 57 | [[self af_notificationObserver] setAnimatingWithStateOfTask:task]; 58 | } 59 | #endif 60 | 61 | - (void)setAnimatingWithStateOfOperation:(AFURLConnectionOperation *)operation { 62 | [[self af_notificationObserver] setAnimatingWithStateOfOperation:operation]; 63 | } 64 | 65 | @end 66 | 67 | @implementation AFActivityIndicatorViewNotificationObserver 68 | 69 | - (instancetype)initWithActivityIndicatorView:(UIActivityIndicatorView *)activityIndicatorView 70 | { 71 | self = [super init]; 72 | if (self) { 73 | _activityIndicatorView = activityIndicatorView; 74 | } 75 | return self; 76 | } 77 | 78 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 79 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task { 80 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 81 | 82 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; 83 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; 84 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; 85 | 86 | if (task) { 87 | if (task.state != NSURLSessionTaskStateCompleted) { 88 | 89 | #pragma clang diagnostic push 90 | #pragma clang diagnostic ignored "-Wreceiver-is-weak" 91 | #pragma clang diagnostic ignored "-Warc-repeated-use-of-weak" 92 | if (task.state == NSURLSessionTaskStateRunning) { 93 | [self.activityIndicatorView startAnimating]; 94 | } else { 95 | [self.activityIndicatorView stopAnimating]; 96 | } 97 | #pragma clang diagnostic pop 98 | 99 | [notificationCenter addObserver:self selector:@selector(af_startAnimating) name:AFNetworkingTaskDidResumeNotification object:task]; 100 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidCompleteNotification object:task]; 101 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidSuspendNotification object:task]; 102 | } 103 | } 104 | } 105 | #endif 106 | 107 | #pragma mark - 108 | 109 | - (void)setAnimatingWithStateOfOperation:(AFURLConnectionOperation *)operation { 110 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 111 | 112 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidStartNotification object:nil]; 113 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidFinishNotification object:nil]; 114 | 115 | if (operation) { 116 | if (![operation isFinished]) { 117 | 118 | #pragma clang diagnostic push 119 | #pragma clang diagnostic ignored "-Wreceiver-is-weak" 120 | #pragma clang diagnostic ignored "-Warc-repeated-use-of-weak" 121 | if ([operation isExecuting]) { 122 | [self.activityIndicatorView startAnimating]; 123 | } else { 124 | [self.activityIndicatorView stopAnimating]; 125 | } 126 | #pragma clang diagnostic pop 127 | 128 | [notificationCenter addObserver:self selector:@selector(af_startAnimating) name:AFNetworkingOperationDidStartNotification object:operation]; 129 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingOperationDidFinishNotification object:operation]; 130 | } 131 | } 132 | } 133 | 134 | #pragma mark - 135 | 136 | - (void)af_startAnimating { 137 | dispatch_async(dispatch_get_main_queue(), ^{ 138 | #pragma clang diagnostic push 139 | #pragma clang diagnostic ignored "-Wreceiver-is-weak" 140 | [self.activityIndicatorView startAnimating]; 141 | #pragma clang diagnostic pop 142 | }); 143 | } 144 | 145 | - (void)af_stopAnimating { 146 | dispatch_async(dispatch_get_main_queue(), ^{ 147 | #pragma clang diagnostic push 148 | #pragma clang diagnostic ignored "-Wreceiver-is-weak" 149 | [self.activityIndicatorView stopAnimating]; 150 | #pragma clang diagnostic pop 151 | }); 152 | } 153 | 154 | #pragma mark - 155 | 156 | - (void)dealloc { 157 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 158 | 159 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 160 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; 161 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; 162 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; 163 | #endif 164 | 165 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidStartNotification object:nil]; 166 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidFinishNotification object:nil]; 167 | } 168 | 169 | @end 170 | 171 | #endif 172 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIAlertView+AFNetworking.h 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #import 25 | 26 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 27 | 28 | #import 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | @class AFURLConnectionOperation; 33 | 34 | /** 35 | This category adds methods to the UIKit framework's `UIAlertView` class. The methods in this category provide support for automatically showing an alert if a session task or request operation finishes with an error. Alert title and message are filled from the corresponding `localizedDescription` & `localizedRecoverySuggestion` or `localizedFailureReason` of the error. 36 | */ 37 | @interface UIAlertView (AFNetworking) 38 | 39 | ///------------------------------------- 40 | /// @name Showing Alert for Session Task 41 | ///------------------------------------- 42 | 43 | /** 44 | Shows an alert view with the error of the specified session task, if any. 45 | 46 | @param task The session task. 47 | @param delegate The alert view delegate. 48 | */ 49 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 50 | + (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task 51 | delegate:(nullable id)delegate NS_EXTENSION_UNAVAILABLE_IOS("Not available in app extensions."); 52 | #endif 53 | 54 | /** 55 | Shows an alert view with the error of the specified session task, if any, with a custom cancel button title and other button titles. 56 | 57 | @param task The session task. 58 | @param delegate The alert view delegate. 59 | @param cancelButtonTitle The title of the cancel button or nil if there is no cancel button. Using this argument is equivalent to setting the cancel button index to the value returned by invoking addButtonWithTitle: specifying this title. 60 | @param otherButtonTitles The title of another button. Using this argument is equivalent to invoking addButtonWithTitle: with this title to add more buttons. Too many buttons can cause the alert view to scroll. For guidelines on the best ways to use an alert in an app, see "Temporary Views". Titles of additional buttons to add to the receiver, terminated with `nil`. 61 | */ 62 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 63 | + (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task 64 | delegate:(nullable id)delegate 65 | cancelButtonTitle:(nullable NSString *)cancelButtonTitle 66 | otherButtonTitles:(nullable NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION NS_EXTENSION_UNAVAILABLE_IOS("Not available in app extensions."); 67 | #endif 68 | 69 | ///------------------------------------------ 70 | /// @name Showing Alert for Request Operation 71 | ///------------------------------------------ 72 | 73 | /** 74 | Shows an alert view with the error of the specified request operation, if any. 75 | 76 | @param operation The request operation. 77 | @param delegate The alert view delegate. 78 | */ 79 | + (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation 80 | delegate:(nullable id)delegate NS_EXTENSION_UNAVAILABLE_IOS("Not available in app extensions."); 81 | 82 | /** 83 | Shows an alert view with the error of the specified request operation, if any, with a custom cancel button title and other button titles. 84 | 85 | @param operation The request operation. 86 | @param delegate The alert view delegate. 87 | @param cancelButtonTitle The title of the cancel button or nil if there is no cancel button. Using this argument is equivalent to setting the cancel button index to the value returned by invoking addButtonWithTitle: specifying this title. 88 | @param otherButtonTitles The title of another button. Using this argument is equivalent to invoking addButtonWithTitle: with this title to add more buttons. Too many buttons can cause the alert view to scroll. For guidelines on the best ways to use an alert in an app, see "Temporary Views". Titles of additional buttons to add to the receiver, terminated with `nil`. 89 | */ 90 | + (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation 91 | delegate:(nullable id)delegate 92 | cancelButtonTitle:(nullable NSString *)cancelButtonTitle 93 | otherButtonTitles:(nullable NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION NS_EXTENSION_UNAVAILABLE_IOS("Not available in app extensions."); 94 | 95 | @end 96 | 97 | NS_ASSUME_NONNULL_END 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIAlertView+AFNetworking.m 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import "UIAlertView+AFNetworking.h" 23 | 24 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 25 | 26 | #import "AFURLConnectionOperation.h" 27 | 28 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 29 | #import "AFURLSessionManager.h" 30 | #endif 31 | 32 | static void AFGetAlertViewTitleAndMessageFromError(NSError *error, NSString * __autoreleasing *title, NSString * __autoreleasing *message) { 33 | if (error.localizedDescription && (error.localizedRecoverySuggestion || error.localizedFailureReason)) { 34 | *title = error.localizedDescription; 35 | 36 | if (error.localizedRecoverySuggestion) { 37 | *message = error.localizedRecoverySuggestion; 38 | } else { 39 | *message = error.localizedFailureReason; 40 | } 41 | } else if (error.localizedDescription) { 42 | *title = NSLocalizedStringFromTable(@"Error", @"AFNetworking", @"Fallback Error Description"); 43 | *message = error.localizedDescription; 44 | } else { 45 | *title = NSLocalizedStringFromTable(@"Error", @"AFNetworking", @"Fallback Error Description"); 46 | *message = [NSString stringWithFormat:NSLocalizedStringFromTable(@"%@ Error: %ld", @"AFNetworking", @"Fallback Error Failure Reason Format"), error.domain, (long)error.code]; 47 | } 48 | } 49 | 50 | @implementation UIAlertView (AFNetworking) 51 | 52 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 53 | + (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task 54 | delegate:(id)delegate 55 | { 56 | [self showAlertViewForTaskWithErrorOnCompletion:task delegate:delegate cancelButtonTitle:NSLocalizedStringFromTable(@"Dismiss", @"AFNetworking", @"UIAlertView Cancel Button Title") otherButtonTitles:nil, nil]; 57 | } 58 | 59 | + (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task 60 | delegate:(id)delegate 61 | cancelButtonTitle:(NSString *)cancelButtonTitle 62 | otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION 63 | { 64 | NSMutableArray *mutableOtherTitles = [NSMutableArray array]; 65 | va_list otherButtonTitleList; 66 | va_start(otherButtonTitleList, otherButtonTitles); 67 | { 68 | for (NSString *otherButtonTitle = otherButtonTitles; otherButtonTitle != nil; otherButtonTitle = va_arg(otherButtonTitleList, NSString *)) { 69 | [mutableOtherTitles addObject:otherButtonTitle]; 70 | } 71 | } 72 | va_end(otherButtonTitleList); 73 | 74 | __block __weak id observer = [[NSNotificationCenter defaultCenter] addObserverForName:AFNetworkingTaskDidCompleteNotification object:task queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) { 75 | NSError *error = notification.userInfo[AFNetworkingTaskDidCompleteErrorKey]; 76 | if (error) { 77 | NSString *title, *message; 78 | AFGetAlertViewTitleAndMessageFromError(error, &title, &message); 79 | 80 | UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:delegate cancelButtonTitle:cancelButtonTitle otherButtonTitles:nil, nil]; 81 | for (NSString *otherButtonTitle in mutableOtherTitles) { 82 | [alertView addButtonWithTitle:otherButtonTitle]; 83 | } 84 | [alertView setTitle:title]; 85 | [alertView setMessage:message]; 86 | [alertView show]; 87 | } 88 | 89 | [[NSNotificationCenter defaultCenter] removeObserver:observer]; 90 | }]; 91 | } 92 | #endif 93 | 94 | #pragma mark - 95 | 96 | + (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation 97 | delegate:(id)delegate 98 | { 99 | [self showAlertViewForRequestOperationWithErrorOnCompletion:operation delegate:delegate cancelButtonTitle:NSLocalizedStringFromTable(@"Dismiss", @"AFNetworking", @"UIAlertView Cancel Button Title") otherButtonTitles:nil, nil]; 100 | } 101 | 102 | + (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation 103 | delegate:(id)delegate 104 | cancelButtonTitle:(NSString *)cancelButtonTitle 105 | otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION 106 | { 107 | NSMutableArray *mutableOtherTitles = [NSMutableArray array]; 108 | va_list otherButtonTitleList; 109 | va_start(otherButtonTitleList, otherButtonTitles); 110 | { 111 | for (NSString *otherButtonTitle = otherButtonTitles; otherButtonTitle != nil; otherButtonTitle = va_arg(otherButtonTitleList, NSString *)) { 112 | [mutableOtherTitles addObject:otherButtonTitle]; 113 | } 114 | } 115 | va_end(otherButtonTitleList); 116 | 117 | __block __weak id observer = [[NSNotificationCenter defaultCenter] addObserverForName:AFNetworkingOperationDidFinishNotification object:operation queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) { 118 | 119 | if (notification.object && [notification.object isKindOfClass:[AFURLConnectionOperation class]]) { 120 | NSError *error = [(AFURLConnectionOperation *)notification.object error]; 121 | if (error) { 122 | NSString *title, *message; 123 | AFGetAlertViewTitleAndMessageFromError(error, &title, &message); 124 | 125 | UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:delegate cancelButtonTitle:cancelButtonTitle otherButtonTitles:nil, nil]; 126 | for (NSString *otherButtonTitle in mutableOtherTitles) { 127 | [alertView addButtonWithTitle:otherButtonTitle]; 128 | } 129 | [alertView setTitle:title]; 130 | [alertView setMessage:message]; 131 | [alertView show]; 132 | } 133 | } 134 | 135 | [[NSNotificationCenter defaultCenter] removeObserver:observer]; 136 | }]; 137 | } 138 | 139 | @end 140 | 141 | #endif 142 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIButton+AFNetworking.h 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #import 25 | 26 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 27 | 28 | #import 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | @protocol AFURLResponseSerialization, AFImageCache; 33 | 34 | /** 35 | This category adds methods to the UIKit framework's `UIButton` class. The methods in this category provide support for loading remote images and background images asynchronously from a URL. 36 | 37 | @warning Compound values for control `state` (such as `UIControlStateHighlighted | UIControlStateDisabled`) are unsupported. 38 | */ 39 | @interface UIButton (AFNetworking) 40 | 41 | ///---------------------------- 42 | /// @name Accessing Image Cache 43 | ///---------------------------- 44 | 45 | /** 46 | The image cache used to improve image loading performance on scroll views. By default, `UIButton` will use the `sharedImageCache` of `UIImageView`. 47 | */ 48 | + (id )sharedImageCache; 49 | 50 | /** 51 | Set the cache used for image loading. 52 | 53 | @param imageCache The image cache. 54 | */ 55 | + (void)setSharedImageCache:(id )imageCache; 56 | 57 | ///------------------------------------ 58 | /// @name Accessing Response Serializer 59 | ///------------------------------------ 60 | 61 | /** 62 | The response serializer used to create an image representation from the server response and response data. By default, this is an instance of `AFImageResponseSerializer`. 63 | 64 | @discussion Subclasses of `AFImageResponseSerializer` could be used to perform post-processing, such as color correction, face detection, or other effects. See https://github.com/AFNetworking/AFCoreImageSerializer 65 | */ 66 | @property (nonatomic, strong) id imageResponseSerializer; 67 | 68 | ///-------------------- 69 | /// @name Setting Image 70 | ///-------------------- 71 | 72 | /** 73 | Asynchronously downloads an image from the specified URL, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. 74 | 75 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. 76 | 77 | @param state The control state. 78 | @param url The URL used for the image request. 79 | */ 80 | - (void)setImageForState:(UIControlState)state 81 | withURL:(NSURL *)url; 82 | 83 | /** 84 | 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. 85 | 86 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. 87 | 88 | @param state The control state. 89 | @param url The URL used for the image request. 90 | @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. 91 | */ 92 | - (void)setImageForState:(UIControlState)state 93 | withURL:(NSURL *)url 94 | placeholderImage:(nullable UIImage *)placeholderImage; 95 | 96 | /** 97 | 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. 98 | 99 | 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. 100 | 101 | 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. 102 | 103 | @param state The control state. 104 | @param urlRequest The URL request used for the image request. 105 | @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. 106 | @param success A block to be executed when the image request operation finishes successfully. This block has no return value and takes two arguments: the server response and the image. If the image was returned from cache, the request and response parameters will be `nil`. 107 | @param failure A block object to be executed when the image request operation finishes unsuccessfully, or that finishes successfully. This block has no return value and takes a single argument: the error that occurred. 108 | */ 109 | - (void)setImageForState:(UIControlState)state 110 | withURLRequest:(NSURLRequest *)urlRequest 111 | placeholderImage:(nullable UIImage *)placeholderImage 112 | success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success 113 | failure:(nullable void (^)(NSError *error))failure; 114 | 115 | 116 | ///------------------------------- 117 | /// @name Setting Background Image 118 | ///------------------------------- 119 | 120 | /** 121 | Asynchronously downloads an image from the specified URL, and sets it as the background image for the specified state once the request is finished. Any previous background image request for the receiver will be cancelled. 122 | 123 | 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. 124 | 125 | @param state The control state. 126 | @param url The URL used for the background image request. 127 | */ 128 | - (void)setBackgroundImageForState:(UIControlState)state 129 | withURL:(NSURL *)url; 130 | 131 | /** 132 | 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. 133 | 134 | 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. 135 | 136 | @param state The control state. 137 | @param url The URL used for the background image request. 138 | @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. 139 | */ 140 | - (void)setBackgroundImageForState:(UIControlState)state 141 | withURL:(NSURL *)url 142 | placeholderImage:(nullable UIImage *)placeholderImage; 143 | 144 | /** 145 | 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. 146 | 147 | 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. 148 | 149 | 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. 150 | 151 | @param state The control state. 152 | @param urlRequest The URL request used for the image request. 153 | @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. 154 | */ 155 | - (void)setBackgroundImageForState:(UIControlState)state 156 | withURLRequest:(NSURLRequest *)urlRequest 157 | placeholderImage:(nullable UIImage *)placeholderImage 158 | success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success 159 | failure:(nullable void (^)(NSError *error))failure; 160 | 161 | 162 | ///------------------------------ 163 | /// @name Canceling Image Loading 164 | ///------------------------------ 165 | 166 | /** 167 | Cancels any executing image operation for the specified control state of the receiver, if one exists. 168 | 169 | @param state The control state. 170 | */ 171 | - (void)cancelImageRequestOperationForState:(UIControlState)state; 172 | 173 | /** 174 | Cancels any executing background image operation for the specified control state of the receiver, if one exists. 175 | 176 | @param state The control state. 177 | */ 178 | - (void)cancelBackgroundImageRequestOperationForState:(UIControlState)state; 179 | 180 | @end 181 | 182 | NS_ASSUME_NONNULL_END 183 | 184 | #endif 185 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+AFNetworking.h 3 | // 4 | // 5 | // Created by Paulo Ferreira on 08/07/15. 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 26 | 27 | #import 28 | 29 | @interface UIImage (AFNetworking) 30 | 31 | + (UIImage*) safeImageWithData:(NSData*)data; 32 | 33 | @end 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIImageView+AFNetworking.h 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #import 25 | 26 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 27 | 28 | #import 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | @protocol AFURLResponseSerialization, AFImageCache; 33 | 34 | /** 35 | This category adds methods to the UIKit framework's `UIImageView` class. The methods in this category provide support for loading remote images asynchronously from a URL. 36 | */ 37 | @interface UIImageView (AFNetworking) 38 | 39 | ///---------------------------- 40 | /// @name Accessing Image Cache 41 | ///---------------------------- 42 | 43 | /** 44 | The image cache used to improve image loading performance on scroll views. By default, this is an `NSCache` subclass conforming to the `AFImageCache` protocol, which listens for notification warnings and evicts objects accordingly. 45 | */ 46 | + (id )sharedImageCache; 47 | 48 | /** 49 | Set the cache used for image loading. 50 | 51 | @param imageCache The image cache. 52 | */ 53 | + (void)setSharedImageCache:(id )imageCache; 54 | 55 | ///------------------------------------ 56 | /// @name Accessing Response Serializer 57 | ///------------------------------------ 58 | 59 | /** 60 | The response serializer used to create an image representation from the server response and response data. By default, this is an instance of `AFImageResponseSerializer`. 61 | 62 | @discussion Subclasses of `AFImageResponseSerializer` could be used to perform post-processing, such as color correction, face detection, or other effects. See https://github.com/AFNetworking/AFCoreImageSerializer 63 | */ 64 | @property (nonatomic, strong) id imageResponseSerializer; 65 | 66 | ///-------------------- 67 | /// @name Setting Image 68 | ///-------------------- 69 | 70 | /** 71 | Asynchronously downloads an image from the specified URL, and sets it once the request is finished. Any previous image request for the receiver will be cancelled. 72 | 73 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. 74 | 75 | By default, URL requests have a `Accept` header field value of "image / *", a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:` 76 | 77 | @param url The URL used for the image request. 78 | */ 79 | - (void)setImageWithURL:(NSURL *)url; 80 | 81 | /** 82 | 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. 83 | 84 | 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. 85 | 86 | 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:` 87 | 88 | @param url The URL used for the image request. 89 | @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. 90 | */ 91 | - (void)setImageWithURL:(NSURL *)url 92 | placeholderImage:(nullable UIImage *)placeholderImage; 93 | 94 | /** 95 | 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. 96 | 97 | 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. 98 | 99 | 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. 100 | 101 | @param urlRequest The URL request used for the image request. 102 | @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. 103 | @param success A block to be executed when the image request operation finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`. 104 | @param failure A block object to be executed when the image request operation 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. 105 | */ 106 | - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest 107 | placeholderImage:(nullable UIImage *)placeholderImage 108 | success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success 109 | failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure; 110 | 111 | /** 112 | Cancels any executing image operation for the receiver, if one exists. 113 | */ 114 | - (void)cancelImageRequestOperation; 115 | 116 | @end 117 | 118 | #pragma mark - 119 | 120 | /** 121 | The `AFImageCache` protocol is adopted by an object used to cache images loaded by the AFNetworking category on `UIImageView`. 122 | */ 123 | @protocol AFImageCache 124 | 125 | /** 126 | Returns a cached image for the specified request, if available. 127 | 128 | @param request The image request. 129 | 130 | @return The cached image. 131 | */ 132 | - (nullable UIImage *)cachedImageForRequest:(NSURLRequest *)request; 133 | 134 | /** 135 | Caches a particular image for the specified request. 136 | 137 | @param image The image to cache. 138 | @param request The request to be used as a cache key. 139 | */ 140 | - (void)cacheImage:(UIImage *)image 141 | forRequest:(NSURLRequest *)request; 142 | @end 143 | 144 | NS_ASSUME_NONNULL_END 145 | 146 | #endif 147 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIImageView+AFNetworking.m 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import "UIImageView+AFNetworking.h" 23 | 24 | #import 25 | 26 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 27 | 28 | #import "AFHTTPRequestOperation.h" 29 | 30 | @interface AFImageCache : NSCache 31 | @end 32 | 33 | #pragma mark - 34 | 35 | @interface UIImageView (_AFNetworking) 36 | @property (readwrite, nonatomic, strong, setter = af_setImageRequestOperation:) AFHTTPRequestOperation *af_imageRequestOperation; 37 | @end 38 | 39 | @implementation UIImageView (_AFNetworking) 40 | 41 | + (NSOperationQueue *)af_sharedImageRequestOperationQueue { 42 | static NSOperationQueue *_af_sharedImageRequestOperationQueue = nil; 43 | static dispatch_once_t onceToken; 44 | dispatch_once(&onceToken, ^{ 45 | _af_sharedImageRequestOperationQueue = [[NSOperationQueue alloc] init]; 46 | _af_sharedImageRequestOperationQueue.maxConcurrentOperationCount = NSOperationQueueDefaultMaxConcurrentOperationCount; 47 | }); 48 | 49 | return _af_sharedImageRequestOperationQueue; 50 | } 51 | 52 | - (AFHTTPRequestOperation *)af_imageRequestOperation { 53 | return (AFHTTPRequestOperation *)objc_getAssociatedObject(self, @selector(af_imageRequestOperation)); 54 | } 55 | 56 | - (void)af_setImageRequestOperation:(AFHTTPRequestOperation *)imageRequestOperation { 57 | objc_setAssociatedObject(self, @selector(af_imageRequestOperation), imageRequestOperation, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 58 | } 59 | 60 | @end 61 | 62 | #pragma mark - 63 | 64 | @implementation UIImageView (AFNetworking) 65 | @dynamic imageResponseSerializer; 66 | 67 | + (id )sharedImageCache { 68 | static AFImageCache *_af_defaultImageCache = nil; 69 | static dispatch_once_t oncePredicate; 70 | dispatch_once(&oncePredicate, ^{ 71 | _af_defaultImageCache = [[AFImageCache alloc] init]; 72 | 73 | [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidReceiveMemoryWarningNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * __unused notification) { 74 | [_af_defaultImageCache removeAllObjects]; 75 | }]; 76 | }); 77 | 78 | #pragma clang diagnostic push 79 | #pragma clang diagnostic ignored "-Wgnu" 80 | return objc_getAssociatedObject(self, @selector(sharedImageCache)) ?: _af_defaultImageCache; 81 | #pragma clang diagnostic pop 82 | } 83 | 84 | + (void)setSharedImageCache:(id )imageCache { 85 | objc_setAssociatedObject(self, @selector(sharedImageCache), imageCache, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 86 | } 87 | 88 | #pragma mark - 89 | 90 | - (id )imageResponseSerializer { 91 | static id _af_defaultImageResponseSerializer = nil; 92 | static dispatch_once_t onceToken; 93 | dispatch_once(&onceToken, ^{ 94 | _af_defaultImageResponseSerializer = [AFImageResponseSerializer serializer]; 95 | }); 96 | 97 | #pragma clang diagnostic push 98 | #pragma clang diagnostic ignored "-Wgnu" 99 | return objc_getAssociatedObject(self, @selector(imageResponseSerializer)) ?: _af_defaultImageResponseSerializer; 100 | #pragma clang diagnostic pop 101 | } 102 | 103 | - (void)setImageResponseSerializer:(id )serializer { 104 | objc_setAssociatedObject(self, @selector(imageResponseSerializer), serializer, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 105 | } 106 | 107 | #pragma mark - 108 | 109 | - (void)setImageWithURL:(NSURL *)url { 110 | [self setImageWithURL:url placeholderImage:nil]; 111 | } 112 | 113 | - (void)setImageWithURL:(NSURL *)url 114 | placeholderImage:(UIImage *)placeholderImage 115 | { 116 | NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; 117 | [request addValue:@"image/*" forHTTPHeaderField:@"Accept"]; 118 | 119 | [self setImageWithURLRequest:request placeholderImage:placeholderImage success:nil failure:nil]; 120 | } 121 | 122 | - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest 123 | placeholderImage:(UIImage *)placeholderImage 124 | success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success 125 | failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure 126 | { 127 | [self cancelImageRequestOperation]; 128 | 129 | UIImage *cachedImage = [[[self class] sharedImageCache] cachedImageForRequest:urlRequest]; 130 | if (cachedImage) { 131 | if (success) { 132 | success(urlRequest, nil, cachedImage); 133 | } else { 134 | self.image = cachedImage; 135 | } 136 | 137 | self.af_imageRequestOperation = nil; 138 | } else { 139 | if (placeholderImage) { 140 | self.image = placeholderImage; 141 | } 142 | 143 | __weak __typeof(self)weakSelf = self; 144 | self.af_imageRequestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:urlRequest]; 145 | self.af_imageRequestOperation.responseSerializer = self.imageResponseSerializer; 146 | [self.af_imageRequestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { 147 | __strong __typeof(weakSelf)strongSelf = weakSelf; 148 | if ([[urlRequest URL] isEqual:[strongSelf.af_imageRequestOperation.request URL]]) { 149 | if (success) { 150 | success(urlRequest, operation.response, responseObject); 151 | } else if (responseObject) { 152 | strongSelf.image = responseObject; 153 | } 154 | 155 | if (operation == strongSelf.af_imageRequestOperation){ 156 | strongSelf.af_imageRequestOperation = nil; 157 | } 158 | } 159 | 160 | [[[strongSelf class] sharedImageCache] cacheImage:responseObject forRequest:urlRequest]; 161 | } failure:^(AFHTTPRequestOperation *operation, NSError *error) { 162 | __strong __typeof(weakSelf)strongSelf = weakSelf; 163 | if ([[urlRequest URL] isEqual:[strongSelf.af_imageRequestOperation.request URL]]) { 164 | if (failure) { 165 | failure(urlRequest, operation.response, error); 166 | } 167 | 168 | if (operation == strongSelf.af_imageRequestOperation){ 169 | strongSelf.af_imageRequestOperation = nil; 170 | } 171 | } 172 | }]; 173 | 174 | [[[self class] af_sharedImageRequestOperationQueue] addOperation:self.af_imageRequestOperation]; 175 | } 176 | } 177 | 178 | - (void)cancelImageRequestOperation { 179 | [self.af_imageRequestOperation cancel]; 180 | self.af_imageRequestOperation = nil; 181 | } 182 | 183 | @end 184 | 185 | #pragma mark - 186 | 187 | static inline NSString * AFImageCacheKeyFromURLRequest(NSURLRequest *request) { 188 | return [[request URL] absoluteString]; 189 | } 190 | 191 | @implementation AFImageCache 192 | 193 | - (UIImage *)cachedImageForRequest:(NSURLRequest *)request { 194 | switch ([request cachePolicy]) { 195 | case NSURLRequestReloadIgnoringCacheData: 196 | case NSURLRequestReloadIgnoringLocalAndRemoteCacheData: 197 | return nil; 198 | default: 199 | break; 200 | } 201 | 202 | return [self objectForKey:AFImageCacheKeyFromURLRequest(request)]; 203 | } 204 | 205 | - (void)cacheImage:(UIImage *)image 206 | forRequest:(NSURLRequest *)request 207 | { 208 | if (image && request) { 209 | [self setObject:image forKey:AFImageCacheKeyFromURLRequest(request)]; 210 | } 211 | } 212 | 213 | @end 214 | 215 | #endif 216 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIKit+AFNetworking.h 2 | // 3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #if TARGET_OS_IOS 24 | #import 25 | 26 | #ifndef _UIKIT_AFNETWORKING_ 27 | #define _UIKIT_AFNETWORKING_ 28 | 29 | #import "AFNetworkActivityIndicatorManager.h" 30 | 31 | #import "UIActivityIndicatorView+AFNetworking.h" 32 | #import "UIAlertView+AFNetworking.h" 33 | #import "UIButton+AFNetworking.h" 34 | #import "UIImageView+AFNetworking.h" 35 | #import "UIProgressView+AFNetworking.h" 36 | #import "UIRefreshControl+AFNetworking.h" 37 | #import "UIWebView+AFNetworking.h" 38 | #endif /* _UIKIT_AFNETWORKING_ */ 39 | #endif 40 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIProgressView+AFNetworking.h 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #import 25 | 26 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 27 | 28 | #import 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | @class AFURLConnectionOperation; 33 | 34 | /** 35 | 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 or request operation. 36 | */ 37 | @interface UIProgressView (AFNetworking) 38 | 39 | ///------------------------------------ 40 | /// @name Setting Session Task Progress 41 | ///------------------------------------ 42 | 43 | /** 44 | Binds the progress to the upload progress of the specified session task. 45 | 46 | @param task The session task. 47 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. 48 | */ 49 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 50 | - (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task 51 | animated:(BOOL)animated; 52 | #endif 53 | 54 | /** 55 | Binds the progress to the download progress of the specified session task. 56 | 57 | @param task The session task. 58 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. 59 | */ 60 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 61 | - (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task 62 | animated:(BOOL)animated; 63 | #endif 64 | 65 | ///------------------------------------ 66 | /// @name Setting Session Task Progress 67 | ///------------------------------------ 68 | 69 | /** 70 | Binds the progress to the upload progress of the specified request operation. 71 | 72 | @param operation The request operation. 73 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. 74 | */ 75 | - (void)setProgressWithUploadProgressOfOperation:(AFURLConnectionOperation *)operation 76 | animated:(BOOL)animated; 77 | 78 | /** 79 | Binds the progress to the download progress of the specified request operation. 80 | 81 | @param operation The request operation. 82 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. 83 | */ 84 | - (void)setProgressWithDownloadProgressOfOperation:(AFURLConnectionOperation *)operation 85 | animated:(BOOL)animated; 86 | 87 | @end 88 | 89 | NS_ASSUME_NONNULL_END 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIProgressView+AFNetworking.m 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import "UIProgressView+AFNetworking.h" 23 | 24 | #import 25 | 26 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 27 | 28 | #import "AFURLConnectionOperation.h" 29 | 30 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 31 | #import "AFURLSessionManager.h" 32 | #endif 33 | 34 | static void * AFTaskCountOfBytesSentContext = &AFTaskCountOfBytesSentContext; 35 | static void * AFTaskCountOfBytesReceivedContext = &AFTaskCountOfBytesReceivedContext; 36 | 37 | @interface AFURLConnectionOperation (_UIProgressView) 38 | @property (readwrite, nonatomic, copy) void (^uploadProgress)(NSUInteger bytes, long long totalBytes, long long totalBytesExpected); 39 | @property (readwrite, nonatomic, assign, setter = af_setUploadProgressAnimated:) BOOL af_uploadProgressAnimated; 40 | 41 | @property (readwrite, nonatomic, copy) void (^downloadProgress)(NSUInteger bytes, long long totalBytes, long long totalBytesExpected); 42 | @property (readwrite, nonatomic, assign, setter = af_setDownloadProgressAnimated:) BOOL af_downloadProgressAnimated; 43 | @end 44 | 45 | @implementation AFURLConnectionOperation (_UIProgressView) 46 | @dynamic uploadProgress; // Implemented in AFURLConnectionOperation 47 | @dynamic af_uploadProgressAnimated; 48 | 49 | @dynamic downloadProgress; // Implemented in AFURLConnectionOperation 50 | @dynamic af_downloadProgressAnimated; 51 | @end 52 | 53 | #pragma mark - 54 | 55 | @implementation UIProgressView (AFNetworking) 56 | 57 | - (BOOL)af_uploadProgressAnimated { 58 | return [(NSNumber *)objc_getAssociatedObject(self, @selector(af_uploadProgressAnimated)) boolValue]; 59 | } 60 | 61 | - (void)af_setUploadProgressAnimated:(BOOL)animated { 62 | objc_setAssociatedObject(self, @selector(af_uploadProgressAnimated), @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 63 | } 64 | 65 | - (BOOL)af_downloadProgressAnimated { 66 | return [(NSNumber *)objc_getAssociatedObject(self, @selector(af_downloadProgressAnimated)) boolValue]; 67 | } 68 | 69 | - (void)af_setDownloadProgressAnimated:(BOOL)animated { 70 | objc_setAssociatedObject(self, @selector(af_downloadProgressAnimated), @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 71 | } 72 | 73 | #pragma mark - 74 | 75 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 76 | - (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task 77 | animated:(BOOL)animated 78 | { 79 | [task addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesSentContext]; 80 | [task addObserver:self forKeyPath:@"countOfBytesSent" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesSentContext]; 81 | 82 | [self af_setUploadProgressAnimated:animated]; 83 | } 84 | 85 | - (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task 86 | animated:(BOOL)animated 87 | { 88 | [task addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesReceivedContext]; 89 | [task addObserver:self forKeyPath:@"countOfBytesReceived" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesReceivedContext]; 90 | 91 | [self af_setDownloadProgressAnimated:animated]; 92 | } 93 | #endif 94 | 95 | #pragma mark - 96 | 97 | - (void)setProgressWithUploadProgressOfOperation:(AFURLConnectionOperation *)operation 98 | animated:(BOOL)animated 99 | { 100 | __weak __typeof(self)weakSelf = self; 101 | void (^original)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) = [operation.uploadProgress copy]; 102 | [operation setUploadProgressBlock:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) { 103 | if (original) { 104 | original(bytesWritten, totalBytesWritten, totalBytesExpectedToWrite); 105 | } 106 | 107 | dispatch_async(dispatch_get_main_queue(), ^{ 108 | if (totalBytesExpectedToWrite > 0) { 109 | __strong __typeof(weakSelf)strongSelf = weakSelf; 110 | [strongSelf setProgress:(totalBytesWritten / (totalBytesExpectedToWrite * 1.0f)) animated:animated]; 111 | } 112 | }); 113 | }]; 114 | } 115 | 116 | - (void)setProgressWithDownloadProgressOfOperation:(AFURLConnectionOperation *)operation 117 | animated:(BOOL)animated 118 | { 119 | __weak __typeof(self)weakSelf = self; 120 | void (^original)(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) = [operation.downloadProgress copy]; 121 | [operation setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) { 122 | if (original) { 123 | original(bytesRead, totalBytesRead, totalBytesExpectedToRead); 124 | } 125 | 126 | dispatch_async(dispatch_get_main_queue(), ^{ 127 | if (totalBytesExpectedToRead > 0) { 128 | __strong __typeof(weakSelf)strongSelf = weakSelf; 129 | [strongSelf setProgress:(totalBytesRead / (totalBytesExpectedToRead * 1.0f)) animated:animated]; 130 | } 131 | }); 132 | }]; 133 | } 134 | 135 | #pragma mark - NSKeyValueObserving 136 | 137 | - (void)observeValueForKeyPath:(NSString *)keyPath 138 | ofObject:(id)object 139 | change:(__unused NSDictionary *)change 140 | context:(void *)context 141 | { 142 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 143 | if (context == AFTaskCountOfBytesSentContext || context == AFTaskCountOfBytesReceivedContext) { 144 | if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesSent))]) { 145 | if ([object countOfBytesExpectedToSend] > 0) { 146 | dispatch_async(dispatch_get_main_queue(), ^{ 147 | [self setProgress:[object countOfBytesSent] / ([object countOfBytesExpectedToSend] * 1.0f) animated:self.af_uploadProgressAnimated]; 148 | }); 149 | } 150 | } 151 | 152 | if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesReceived))]) { 153 | if ([object countOfBytesExpectedToReceive] > 0) { 154 | dispatch_async(dispatch_get_main_queue(), ^{ 155 | [self setProgress:[object countOfBytesReceived] / ([object countOfBytesExpectedToReceive] * 1.0f) animated:self.af_downloadProgressAnimated]; 156 | }); 157 | } 158 | } 159 | 160 | if ([keyPath isEqualToString:NSStringFromSelector(@selector(state))]) { 161 | if ([(NSURLSessionTask *)object state] == NSURLSessionTaskStateCompleted) { 162 | @try { 163 | [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(state))]; 164 | 165 | if (context == AFTaskCountOfBytesSentContext) { 166 | [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesSent))]; 167 | } 168 | 169 | if (context == AFTaskCountOfBytesReceivedContext) { 170 | [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesReceived))]; 171 | } 172 | } 173 | @catch (NSException * __unused exception) {} 174 | } 175 | } 176 | } 177 | #endif 178 | } 179 | 180 | @end 181 | 182 | #endif 183 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIRefreshControl+AFNetworking.m 2 | // 3 | // Copyright (c) 2014 AFNetworking (http://afnetworking.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | 25 | #import 26 | 27 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 28 | 29 | #import 30 | 31 | NS_ASSUME_NONNULL_BEGIN 32 | 33 | @class AFURLConnectionOperation; 34 | 35 | /** 36 | 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 request operation or session task. 37 | */ 38 | @interface UIRefreshControl (AFNetworking) 39 | 40 | ///----------------------------------- 41 | /// @name Refreshing for Session Tasks 42 | ///----------------------------------- 43 | 44 | /** 45 | Binds the refreshing state to the state of the specified task. 46 | 47 | @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled. 48 | */ 49 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 50 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task; 51 | #endif 52 | 53 | ///---------------------------------------- 54 | /// @name Refreshing for Request Operations 55 | ///---------------------------------------- 56 | 57 | /** 58 | Binds the refreshing state to the execution state of the specified operation. 59 | 60 | @param operation The operation. If `nil`, automatic updating from any previously specified operation will be disabled. 61 | */ 62 | - (void)setRefreshingWithStateOfOperation:(AFURLConnectionOperation *)operation; 63 | 64 | @end 65 | 66 | NS_ASSUME_NONNULL_END 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIRefreshControl+AFNetworking.m 2 | // 3 | // Copyright (c) 2014 AFNetworking (http://afnetworking.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import "UIRefreshControl+AFNetworking.h" 24 | #import 25 | 26 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 27 | 28 | #import "AFHTTPRequestOperation.h" 29 | 30 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 31 | #import "AFURLSessionManager.h" 32 | #endif 33 | 34 | @interface AFRefreshControlNotificationObserver : NSObject 35 | @property (readonly, nonatomic, weak) UIRefreshControl *refreshControl; 36 | - (instancetype)initWithActivityRefreshControl:(UIRefreshControl *)refreshControl; 37 | 38 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 39 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task; 40 | #endif 41 | - (void)setRefreshingWithStateOfOperation:(AFURLConnectionOperation *)operation; 42 | 43 | @end 44 | 45 | @implementation UIRefreshControl (AFNetworking) 46 | 47 | - (AFRefreshControlNotificationObserver *)af_notificationObserver { 48 | AFRefreshControlNotificationObserver *notificationObserver = objc_getAssociatedObject(self, @selector(af_notificationObserver)); 49 | if (notificationObserver == nil) { 50 | notificationObserver = [[AFRefreshControlNotificationObserver alloc] initWithActivityRefreshControl:self]; 51 | objc_setAssociatedObject(self, @selector(af_notificationObserver), notificationObserver, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 52 | } 53 | return notificationObserver; 54 | } 55 | 56 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 57 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task { 58 | [[self af_notificationObserver] setRefreshingWithStateOfTask:task]; 59 | } 60 | #endif 61 | 62 | - (void)setRefreshingWithStateOfOperation:(AFURLConnectionOperation *)operation { 63 | [[self af_notificationObserver] setRefreshingWithStateOfOperation:operation]; 64 | } 65 | 66 | @end 67 | 68 | @implementation AFRefreshControlNotificationObserver 69 | 70 | - (instancetype)initWithActivityRefreshControl:(UIRefreshControl *)refreshControl 71 | { 72 | self = [super init]; 73 | if (self) { 74 | _refreshControl = refreshControl; 75 | } 76 | return self; 77 | } 78 | 79 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 80 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task { 81 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 82 | 83 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; 84 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; 85 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; 86 | 87 | if (task) { 88 | #pragma clang diagnostic push 89 | #pragma clang diagnostic ignored "-Wreceiver-is-weak" 90 | #pragma clang diagnostic ignored "-Warc-repeated-use-of-weak" 91 | if (task.state == NSURLSessionTaskStateRunning) { 92 | [self.refreshControl beginRefreshing]; 93 | 94 | [notificationCenter addObserver:self selector:@selector(af_beginRefreshing) name:AFNetworkingTaskDidResumeNotification object:task]; 95 | [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidCompleteNotification object:task]; 96 | [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidSuspendNotification object:task]; 97 | } else { 98 | [self.refreshControl endRefreshing]; 99 | } 100 | #pragma clang diagnostic pop 101 | } 102 | } 103 | #endif 104 | 105 | - (void)setRefreshingWithStateOfOperation:(AFURLConnectionOperation *)operation { 106 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 107 | 108 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidStartNotification object:nil]; 109 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidFinishNotification object:nil]; 110 | 111 | if (operation) { 112 | #pragma clang diagnostic push 113 | #pragma clang diagnostic ignored "-Wreceiver-is-weak" 114 | #pragma clang diagnostic ignored "-Warc-repeated-use-of-weak" 115 | if (![operation isFinished]) { 116 | if ([operation isExecuting]) { 117 | [self.refreshControl beginRefreshing]; 118 | } else { 119 | [self.refreshControl endRefreshing]; 120 | } 121 | 122 | [notificationCenter addObserver:self selector:@selector(af_beginRefreshing) name:AFNetworkingOperationDidStartNotification object:operation]; 123 | [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingOperationDidFinishNotification object:operation]; 124 | } 125 | #pragma clang diagnostic pop 126 | } 127 | } 128 | 129 | #pragma mark - 130 | 131 | - (void)af_beginRefreshing { 132 | dispatch_async(dispatch_get_main_queue(), ^{ 133 | #pragma clang diagnostic push 134 | #pragma clang diagnostic ignored "-Wreceiver-is-weak" 135 | [self.refreshControl beginRefreshing]; 136 | #pragma clang diagnostic pop 137 | }); 138 | } 139 | 140 | - (void)af_endRefreshing { 141 | dispatch_async(dispatch_get_main_queue(), ^{ 142 | #pragma clang diagnostic push 143 | #pragma clang diagnostic ignored "-Wreceiver-is-weak" 144 | [self.refreshControl endRefreshing]; 145 | #pragma clang diagnostic pop 146 | }); 147 | } 148 | 149 | #pragma mark - 150 | 151 | - (void)dealloc { 152 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 153 | 154 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 155 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; 156 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; 157 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; 158 | #endif 159 | 160 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidStartNotification object:nil]; 161 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidFinishNotification object:nil]; 162 | } 163 | 164 | @end 165 | 166 | #endif 167 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIWebView+AFNetworking.h 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #import 25 | 26 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 27 | 28 | #import 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | @class AFHTTPRequestSerializer, AFHTTPResponseSerializer; 33 | @protocol AFURLRequestSerialization, AFURLResponseSerialization; 34 | 35 | /** 36 | 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. 37 | 38 | @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. 39 | */ 40 | @interface UIWebView (AFNetworking) 41 | 42 | /** 43 | The request serializer used to serialize requests made with the `-loadRequest:...` category methods. By default, this is an instance of `AFHTTPRequestSerializer`. 44 | */ 45 | @property (nonatomic, strong) AFHTTPRequestSerializer * requestSerializer; 46 | 47 | /** 48 | The response serializer used to serialize responses made with the `-loadRequest:...` category methods. By default, this is an instance of `AFHTTPResponseSerializer`. 49 | */ 50 | @property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer; 51 | 52 | /** 53 | Asynchronously loads the specified request. 54 | 55 | @param request A URL request identifying the location of the content to load. This must not be `nil`. 56 | @param progress A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the number of bytes read since the last time the download progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times, and will execute on the main thread. 57 | @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. 58 | @param failure A block object to be executed when the request operation 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. 59 | */ 60 | - (void)loadRequest:(NSURLRequest *)request 61 | progress:(nullable void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress 62 | success:(nullable NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success 63 | failure:(nullable void (^)(NSError *error))failure; 64 | 65 | /** 66 | Asynchronously loads the data associated with a particular request with a specified MIME type and text encoding. 67 | 68 | @param request A URL request identifying the location of the content to load. This must not be `nil`. 69 | @param MIMEType The MIME type of the content. Defaults to the content type of the response if not specified. 70 | @param textEncodingName The IANA encoding name, as in `utf-8` or `utf-16`. Defaults to the response text encoding if not specified. 71 | @param progress A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the number of bytes read since the last time the download progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times, and will execute on the main thread. 72 | @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. 73 | @param failure A block object to be executed when the request operation 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. 74 | */ 75 | - (void)loadRequest:(NSURLRequest *)request 76 | MIMEType:(nullable NSString *)MIMEType 77 | textEncodingName:(nullable NSString *)textEncodingName 78 | progress:(nullable void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress 79 | success:(nullable NSData * (^)(NSHTTPURLResponse *response, NSData *data))success 80 | failure:(nullable void (^)(NSError *error))failure; 81 | 82 | @end 83 | 84 | NS_ASSUME_NONNULL_END 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIWebView+AFNetworking.m 2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import "UIWebView+AFNetworking.h" 23 | 24 | #import 25 | 26 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 27 | 28 | #import "AFHTTPRequestOperation.h" 29 | #import "AFURLResponseSerialization.h" 30 | #import "AFURLRequestSerialization.h" 31 | 32 | @interface UIWebView (_AFNetworking) 33 | @property (readwrite, nonatomic, strong, setter = af_setHTTPRequestOperation:) AFHTTPRequestOperation *af_HTTPRequestOperation; 34 | @end 35 | 36 | @implementation UIWebView (_AFNetworking) 37 | 38 | - (AFHTTPRequestOperation *)af_HTTPRequestOperation { 39 | return (AFHTTPRequestOperation *)objc_getAssociatedObject(self, @selector(af_HTTPRequestOperation)); 40 | } 41 | 42 | - (void)af_setHTTPRequestOperation:(AFHTTPRequestOperation *)operation { 43 | objc_setAssociatedObject(self, @selector(af_HTTPRequestOperation), operation, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 44 | } 45 | 46 | @end 47 | 48 | #pragma mark - 49 | 50 | @implementation UIWebView (AFNetworking) 51 | 52 | - (AFHTTPRequestSerializer *)requestSerializer { 53 | static AFHTTPRequestSerializer *_af_defaultRequestSerializer = nil; 54 | static dispatch_once_t onceToken; 55 | dispatch_once(&onceToken, ^{ 56 | _af_defaultRequestSerializer = [AFHTTPRequestSerializer serializer]; 57 | }); 58 | 59 | #pragma clang diagnostic push 60 | #pragma clang diagnostic ignored "-Wgnu" 61 | return objc_getAssociatedObject(self, @selector(requestSerializer)) ?: _af_defaultRequestSerializer; 62 | #pragma clang diagnostic pop 63 | } 64 | 65 | - (void)setRequestSerializer:(AFHTTPRequestSerializer *)requestSerializer { 66 | objc_setAssociatedObject(self, @selector(requestSerializer), requestSerializer, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 67 | } 68 | 69 | - (AFHTTPResponseSerializer *)responseSerializer { 70 | static AFHTTPResponseSerializer *_af_defaultResponseSerializer = nil; 71 | static dispatch_once_t onceToken; 72 | dispatch_once(&onceToken, ^{ 73 | _af_defaultResponseSerializer = [AFHTTPResponseSerializer serializer]; 74 | }); 75 | 76 | #pragma clang diagnostic push 77 | #pragma clang diagnostic ignored "-Wgnu" 78 | return objc_getAssociatedObject(self, @selector(responseSerializer)) ?: _af_defaultResponseSerializer; 79 | #pragma clang diagnostic pop 80 | } 81 | 82 | - (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer { 83 | objc_setAssociatedObject(self, @selector(responseSerializer), responseSerializer, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 84 | } 85 | 86 | #pragma mark - 87 | 88 | - (void)loadRequest:(NSURLRequest *)request 89 | progress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress 90 | success:(NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success 91 | failure:(void (^)(NSError *error))failure 92 | { 93 | [self loadRequest:request MIMEType:nil textEncodingName:nil progress:progress success:^NSData *(NSHTTPURLResponse *response, NSData *data) { 94 | NSStringEncoding stringEncoding = NSUTF8StringEncoding; 95 | if (response.textEncodingName) { 96 | CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)response.textEncodingName); 97 | if (encoding != kCFStringEncodingInvalidId) { 98 | stringEncoding = CFStringConvertEncodingToNSStringEncoding(encoding); 99 | } 100 | } 101 | 102 | NSString *string = [[NSString alloc] initWithData:data encoding:stringEncoding]; 103 | if (success) { 104 | string = success(response, string); 105 | } 106 | 107 | return [string dataUsingEncoding:stringEncoding]; 108 | } failure:failure]; 109 | } 110 | 111 | - (void)loadRequest:(NSURLRequest *)request 112 | MIMEType:(NSString *)MIMEType 113 | textEncodingName:(NSString *)textEncodingName 114 | progress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress 115 | success:(NSData * (^)(NSHTTPURLResponse *response, NSData *data))success 116 | failure:(void (^)(NSError *error))failure 117 | { 118 | NSParameterAssert(request); 119 | 120 | if (self.af_HTTPRequestOperation) { 121 | [self.af_HTTPRequestOperation cancel]; 122 | } 123 | 124 | request = [self.requestSerializer requestBySerializingRequest:request withParameters:nil error:nil]; 125 | 126 | self.af_HTTPRequestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; 127 | self.af_HTTPRequestOperation.responseSerializer = self.responseSerializer; 128 | 129 | __weak __typeof(self)weakSelf = self; 130 | [self.af_HTTPRequestOperation setDownloadProgressBlock:progress]; 131 | [self.af_HTTPRequestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id __unused responseObject) { 132 | NSData *data = success ? success(operation.response, operation.responseData) : operation.responseData; 133 | 134 | #pragma clang diagnostic push 135 | #pragma clang diagnostic ignored "-Wgnu" 136 | __strong __typeof(weakSelf) strongSelf = weakSelf; 137 | [strongSelf loadData:data MIMEType:(MIMEType ?: [operation.response MIMEType]) textEncodingName:(textEncodingName ?: [operation.response textEncodingName]) baseURL:[operation.response URL]]; 138 | 139 | if ([strongSelf.delegate respondsToSelector:@selector(webViewDidFinishLoad:)]) { 140 | [strongSelf.delegate webViewDidFinishLoad:strongSelf]; 141 | } 142 | 143 | #pragma clang diagnostic pop 144 | } failure:^(AFHTTPRequestOperation * __unused operation, NSError *error) { 145 | if (failure) { 146 | failure(error); 147 | } 148 | }]; 149 | 150 | [self.af_HTTPRequestOperation start]; 151 | 152 | if ([self.delegate respondsToSelector:@selector(webViewDidStartLoad:)]) { 153 | [self.delegate webViewDidStartLoad:self]; 154 | } 155 | } 156 | 157 | @end 158 | 159 | #endif 160 | -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/AFHTTPRequestOperation.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFHTTPRequestOperation.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/AFHTTPRequestOperationManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFHTTPRequestOperationManager.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/AFHTTPSessionManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFHTTPSessionManager.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/AFNetworkActivityIndicatorManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/AFNetworkReachabilityManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFNetworkReachabilityManager.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/AFSecurityPolicy.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFSecurityPolicy.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/AFURLConnectionOperation.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLConnectionOperation.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/AFURLRequestSerialization.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLRequestSerialization.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/AFURLResponseSerialization.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLResponseSerialization.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/AFURLSessionManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLSessionManager.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/UIActivityIndicatorView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/UIAlertView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/UIButton+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/UIImage+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/UIImageView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/UIKit+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/UIProgressView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/UIRefreshControl+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Private/AFNetworking/UIWebView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/AFHTTPRequestOperation.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFHTTPRequestOperation.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/AFHTTPRequestOperationManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFHTTPRequestOperationManager.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/AFHTTPSessionManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFHTTPSessionManager.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/AFNetworkActivityIndicatorManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/AFNetworkReachabilityManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFNetworkReachabilityManager.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/AFSecurityPolicy.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFSecurityPolicy.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/AFURLConnectionOperation.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLConnectionOperation.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/AFURLRequestSerialization.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLRequestSerialization.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/AFURLResponseSerialization.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLResponseSerialization.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/AFURLSessionManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLSessionManager.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/UIActivityIndicatorView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/UIAlertView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/UIButton+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/UIImage+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/UIImageView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/UIKit+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/UIProgressView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/UIRefreshControl+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Headers/Public/AFNetworking/UIWebView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h -------------------------------------------------------------------------------- /Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - AFNetworking (2.6.0): 3 | - AFNetworking/NSURLConnection (= 2.6.0) 4 | - AFNetworking/NSURLSession (= 2.6.0) 5 | - AFNetworking/Reachability (= 2.6.0) 6 | - AFNetworking/Security (= 2.6.0) 7 | - AFNetworking/Serialization (= 2.6.0) 8 | - AFNetworking/UIKit (= 2.6.0) 9 | - AFNetworking/NSURLConnection (2.6.0): 10 | - AFNetworking/Reachability 11 | - AFNetworking/Security 12 | - AFNetworking/Serialization 13 | - AFNetworking/NSURLSession (2.6.0): 14 | - AFNetworking/Reachability 15 | - AFNetworking/Security 16 | - AFNetworking/Serialization 17 | - AFNetworking/Reachability (2.6.0) 18 | - AFNetworking/Security (2.6.0) 19 | - AFNetworking/Serialization (2.6.0) 20 | - AFNetworking/UIKit (2.6.0): 21 | - AFNetworking/NSURLConnection 22 | - AFNetworking/NSURLSession 23 | 24 | DEPENDENCIES: 25 | - AFNetworking (~> 2.5) 26 | 27 | SPEC CHECKSUMS: 28 | AFNetworking: 79f7eb1a0fcfa7beb409332b2ca49afe9ce53b05 29 | 30 | COCOAPODS: 0.38.2 31 | -------------------------------------------------------------------------------- /Pods/Target Support Files/AFNetworking/AFNetworking-Private.xcconfig: -------------------------------------------------------------------------------- 1 | #include "AFNetworking.xcconfig" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/AFNetworking" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" 4 | OTHER_LDFLAGS = ${AFNETWORKING_OTHER_LDFLAGS} 5 | PODS_ROOT = ${SRCROOT} 6 | SKIP_INSTALL = YES -------------------------------------------------------------------------------- /Pods/Target Support Files/AFNetworking/AFNetworking-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_AFNetworking : NSObject 3 | @end 4 | @implementation PodsDummy_AFNetworking 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/AFNetworking/AFNetworking-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | #ifndef TARGET_OS_IOS 6 | #define TARGET_OS_IOS TARGET_OS_IPHONE 7 | #endif 8 | 9 | #ifndef TARGET_OS_WATCH 10 | #define TARGET_OS_WATCH 0 11 | #endif 12 | -------------------------------------------------------------------------------- /Pods/Target Support Files/AFNetworking/AFNetworking.xcconfig: -------------------------------------------------------------------------------- 1 | AFNETWORKING_OTHER_LDFLAGS = -framework "CoreGraphics" -framework "MobileCoreServices" -framework "Security" -framework "SystemConfiguration" -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-SlackIncomingWebhooksDemo/Pods-SlackIncomingWebhooksDemo-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## AFNetworking 5 | 6 | Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | 26 | Generated by CocoaPods - http://cocoapods.org 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-SlackIncomingWebhooksDemo/Pods-SlackIncomingWebhooksDemo-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) 18 | 19 | Permission is hereby granted, free of charge, to any person obtaining a copy 20 | of this software and associated documentation files (the "Software"), to deal 21 | in the Software without restriction, including without limitation the rights 22 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 23 | copies of the Software, and to permit persons to whom the Software is 24 | furnished to do so, subject to the following conditions: 25 | 26 | The above copyright notice and this permission notice shall be included in 27 | all copies or substantial portions of the Software. 28 | 29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 35 | THE SOFTWARE. 36 | 37 | Title 38 | AFNetworking 39 | Type 40 | PSGroupSpecifier 41 | 42 | 43 | FooterText 44 | Generated by CocoaPods - http://cocoapods.org 45 | Title 46 | 47 | Type 48 | PSGroupSpecifier 49 | 50 | 51 | StringsTable 52 | Acknowledgements 53 | Title 54 | Acknowledgements 55 | 56 | 57 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-SlackIncomingWebhooksDemo/Pods-SlackIncomingWebhooksDemo-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_SlackIncomingWebhooksDemo : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_SlackIncomingWebhooksDemo 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-SlackIncomingWebhooksDemo/Pods-SlackIncomingWebhooksDemo-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | XCASSET_FILES=() 10 | 11 | realpath() { 12 | DIRECTORY="$(cd "${1%/*}" && pwd)" 13 | FILENAME="${1##*/}" 14 | echo "$DIRECTORY/$FILENAME" 15 | } 16 | 17 | install_resource() 18 | { 19 | case $1 in 20 | *.storyboard) 21 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc ${PODS_ROOT}/$1 --sdk ${SDKROOT}" 22 | ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" 23 | ;; 24 | *.xib) 25 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib ${PODS_ROOT}/$1 --sdk ${SDKROOT}" 26 | ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" 27 | ;; 28 | *.framework) 29 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 30 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 31 | echo "rsync -av ${PODS_ROOT}/$1 ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 32 | rsync -av "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 33 | ;; 34 | *.xcdatamodel) 35 | echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1"`.mom\"" 36 | xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodel`.mom" 37 | ;; 38 | *.xcdatamodeld) 39 | echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd\"" 40 | xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd" 41 | ;; 42 | *.xcmappingmodel) 43 | echo "xcrun mapc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm\"" 44 | xcrun mapc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm" 45 | ;; 46 | *.xcassets) 47 | ABSOLUTE_XCASSET_FILE=$(realpath "${PODS_ROOT}/$1") 48 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") 49 | ;; 50 | /*) 51 | echo "$1" 52 | echo "$1" >> "$RESOURCES_TO_COPY" 53 | ;; 54 | *) 55 | echo "${PODS_ROOT}/$1" 56 | echo "${PODS_ROOT}/$1" >> "$RESOURCES_TO_COPY" 57 | ;; 58 | esac 59 | } 60 | 61 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 62 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 63 | if [[ "${ACTION}" == "install" ]]; then 64 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 65 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 66 | fi 67 | rm -f "$RESOURCES_TO_COPY" 68 | 69 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] 70 | then 71 | case "${TARGETED_DEVICE_FAMILY}" in 72 | 1,2) 73 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 74 | ;; 75 | 1) 76 | TARGET_DEVICE_ARGS="--target-device iphone" 77 | ;; 78 | 2) 79 | TARGET_DEVICE_ARGS="--target-device ipad" 80 | ;; 81 | *) 82 | TARGET_DEVICE_ARGS="--target-device mac" 83 | ;; 84 | esac 85 | 86 | # Find all other xcassets (this unfortunately includes those of path pods and other targets). 87 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) 88 | while read line; do 89 | if [[ $line != "`realpath $PODS_ROOT`*" ]]; then 90 | XCASSET_FILES+=("$line") 91 | fi 92 | done <<<"$OTHER_XCASSETS" 93 | 94 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${IPHONEOS_DEPLOYMENT_TARGET}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 95 | fi 96 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-SlackIncomingWebhooksDemo/Pods-SlackIncomingWebhooksDemo.debug.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" 3 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/AFNetworking" 4 | OTHER_LDFLAGS = $(inherited) -ObjC -l"AFNetworking" -framework "CoreGraphics" -framework "MobileCoreServices" -framework "Security" -framework "SystemConfiguration" 5 | PODS_ROOT = ${SRCROOT}/Pods -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-SlackIncomingWebhooksDemo/Pods-SlackIncomingWebhooksDemo.release.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" 3 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/AFNetworking" 4 | OTHER_LDFLAGS = $(inherited) -ObjC -l"AFNetworking" -framework "CoreGraphics" -framework "MobileCoreServices" -framework "Security" -framework "SystemConfiguration" 5 | PODS_ROOT = ${SRCROOT}/Pods -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DDSlackWebhook 2 | 3 | DDSlackWebhook is a simple client post notification to your slack channel use slack incoming webhooks. Written in Objective-c. 4 | 5 | ## Installation 6 | 7 | #### CocoaPods 8 | 9 | pod 'DDSlackWebhook' 10 | 11 | #### Source File 12 | You can copy all the files under the `DDSlackWebhook` folder into your project. 13 | 14 | ## Usage 15 | 16 | ```objective-c 17 | 18 | // Config 19 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 20 | [DDSlackWebhookClient withWebhookURL:[NSURL URLWithString:@""]]; 21 | 22 | return YES; 23 | } 24 | 25 | // Post 26 | [[DDSlackWebhookClient sharedClient] postNotificationToChannel:nil 27 | text:nil 28 | username:nil 29 | iconURL:nil 30 | iconEmoji:nil 31 | completion:nil]; 32 | 33 | ``` 34 | 35 | ## Dependency 36 | 37 | - AFNetworking 38 | 39 | ## Author 40 | 41 | Liu Yi, 61upup@gmail.com 42 | 43 | ## License 44 | 45 | DDSlackWebhook is available under the MIT license. See the LICENSE file for more info. -------------------------------------------------------------------------------- /SlackIncomingWebhooksDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SlackIncomingWebhooksDemo.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /SlackIncomingWebhooksDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // SlackIncomingWebhooksDemo 4 | // 5 | // Created by im61 on 15/10/11. 6 | // Copyright © 2015年 DeepDevelop. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /SlackIncomingWebhooksDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // SlackIncomingWebhooksDemo 4 | // 5 | // Created by im61 on 15/10/11. 6 | // Copyright © 2015年 DeepDevelop. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "DDSlackWebhookClient.h" 11 | 12 | @interface AppDelegate () 13 | 14 | @end 15 | 16 | @implementation AppDelegate 17 | 18 | 19 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 20 | [DDSlackWebhookClient withWebhookURL:[NSURL URLWithString:@""]]; 21 | 22 | return YES; 23 | } 24 | 25 | - (void)applicationWillResignActive:(UIApplication *)application { 26 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 27 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 28 | } 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | - (void)applicationWillEnterForeground:(UIApplication *)application { 36 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 37 | } 38 | 39 | - (void)applicationDidBecomeActive:(UIApplication *)application { 40 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 41 | } 42 | 43 | - (void)applicationWillTerminate:(UIApplication *)application { 44 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 45 | } 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /SlackIncomingWebhooksDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /SlackIncomingWebhooksDemo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /SlackIncomingWebhooksDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /SlackIncomingWebhooksDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /SlackIncomingWebhooksDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // SlackIncomingWebhooksDemo 4 | // 5 | // Created by im61 on 15/10/11. 6 | // Copyright © 2015年 DeepDevelop. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /SlackIncomingWebhooksDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // SlackIncomingWebhooksDemo 4 | // 5 | // Created by im61 on 15/10/11. 6 | // Copyright © 2015年 DeepDevelop. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "DDSlackWebhookClient.h" 11 | 12 | @interface ViewController () 13 | 14 | @end 15 | 16 | @implementation ViewController 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | // Do any additional setup after loading the view, typically from a nib. 21 | } 22 | 23 | - (void)didReceiveMemoryWarning { 24 | [super didReceiveMemoryWarning]; 25 | // Dispose of any resources that can be recreated. 26 | } 27 | 28 | - (IBAction)postNotification:(id)sender { 29 | [[DDSlackWebhookClient sharedClient] postNotificationToChannel:nil 30 | text:nil 31 | username:nil 32 | iconURL:nil 33 | iconEmoji:nil 34 | completion:nil]; 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /SlackIncomingWebhooksDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // SlackIncomingWebhooksDemo 4 | // 5 | // Created by im61 on 15/10/11. 6 | // Copyright © 2015年 DeepDevelop. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /SlackIncomingWebhooksDemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /SlackIncomingWebhooksDemoTests/SlackIncomingWebhooksDemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // SlackIncomingWebhooksDemoTests.m 3 | // SlackIncomingWebhooksDemoTests 4 | // 5 | // Created by im61 on 15/10/11. 6 | // Copyright © 2015年 DeepDevelop. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SlackIncomingWebhooksDemoTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation SlackIncomingWebhooksDemoTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | --------------------------------------------------------------------------------