├── NSURLProtocolExample.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcuserdata
│ │ └── houxh.xcuserdatad
│ │ └── UserInterfaceState.xcuserstate
└── xcuserdata
│ └── houxh.xcuserdatad
│ ├── xcdebugger
│ └── Breakpoints_v2.xcbkptlist
│ └── xcschemes
│ ├── NSURLProtocolExample.xcscheme
│ └── xcschememanagement.plist
├── NSURLProtocolExample.xcworkspace
├── contents.xcworkspacedata
├── xcshareddata
│ └── NSURLProtocolExample.xccheckout
└── xcuserdata
│ └── houxh.xcuserdatad
│ ├── UserInterfaceState.xcuserstate
│ └── xcdebugger
│ └── Breakpoints_v2.xcbkptlist
├── NSURLProtocolExample
├── AppDelegate.h
├── AppDelegate.m
├── Base.lproj
│ ├── LaunchScreen.xib
│ └── Main.storyboard
├── CustomURLProtocol.h
├── CustomURLProtocol.m
├── Images.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
├── Info.plist
├── ViewController.h
├── ViewController.m
└── main.m
├── NSURLProtocolExampleTests
├── Info.plist
└── NSURLProtocolExampleTests.m
├── 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
│ ├── 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
│ │ ├── 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
│ ├── UIImageView+AFNetworking.h
│ ├── UIKit+AFNetworking.h
│ ├── UIProgressView+AFNetworking.h
│ ├── UIRefreshControl+AFNetworking.h
│ └── UIWebView+AFNetworking.h
├── Manifest.lock
├── Pods.xcodeproj
├── project.pbxproj
└── xcuserdata
│ └── houxh.xcuserdatad
│ └── xcschemes
│ ├── Pods-AFNetworking.xcscheme
│ ├── Pods.xcscheme
│ └── xcschememanagement.plist
└── Target Support Files
├── Pods-AFNetworking
├── Pods-AFNetworking-Private.xcconfig
├── Pods-AFNetworking-dummy.m
├── Pods-AFNetworking-prefix.pch
└── Pods-AFNetworking.xcconfig
└── Pods
├── Pods-acknowledgements.markdown
├── Pods-acknowledgements.plist
├── Pods-dummy.m
├── Pods-environment.h
├── Pods-resources.sh
├── Pods.debug.xcconfig
└── Pods.release.xcconfig
/NSURLProtocolExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/NSURLProtocolExample.xcodeproj/project.xcworkspace/xcuserdata/houxh.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FreeMind-LJ/NSURLProtocolExample/042aebf2d2608b00c7d3c7b33f4617e390cd7fef/NSURLProtocolExample.xcodeproj/project.xcworkspace/xcuserdata/houxh.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/NSURLProtocolExample.xcodeproj/xcuserdata/houxh.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/NSURLProtocolExample.xcodeproj/xcuserdata/houxh.xcuserdatad/xcschemes/NSURLProtocolExample.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
29 |
35 |
36 |
37 |
38 |
39 |
44 |
45 |
47 |
53 |
54 |
55 |
56 |
57 |
63 |
64 |
65 |
66 |
75 |
76 |
82 |
83 |
84 |
85 |
86 |
87 |
93 |
94 |
100 |
101 |
102 |
103 |
105 |
106 |
109 |
110 |
111 |
--------------------------------------------------------------------------------
/NSURLProtocolExample.xcodeproj/xcuserdata/houxh.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | NSURLProtocolExample.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 6D5CCAEA1B2EBC7C00F295E9
16 |
17 | primary
18 |
19 |
20 | 6D5CCB031B2EBC7C00F295E9
21 |
22 | primary
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/NSURLProtocolExample.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/NSURLProtocolExample.xcworkspace/xcshareddata/NSURLProtocolExample.xccheckout:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDESourceControlProjectFavoriteDictionaryKey
6 |
7 | IDESourceControlProjectIdentifier
8 | 14325DDF-A5C4-4B91-B6C2-3A891D0C88C9
9 | IDESourceControlProjectName
10 | NSURLProtocolExample
11 | IDESourceControlProjectOriginsDictionary
12 |
13 | 0F7856B7B7C4C6277F307B15A7AB33375244F9C0
14 | https://github.com/FreeMind-LJ/NSURLProtocolExample.git
15 |
16 | IDESourceControlProjectPath
17 | NSURLProtocolExample.xcworkspace
18 | IDESourceControlProjectRelativeInstallPathDictionary
19 |
20 | 0F7856B7B7C4C6277F307B15A7AB33375244F9C0
21 | ..
22 |
23 | IDESourceControlProjectURL
24 | https://github.com/FreeMind-LJ/NSURLProtocolExample.git
25 | IDESourceControlProjectVersion
26 | 111
27 | IDESourceControlProjectWCCIdentifier
28 | 0F7856B7B7C4C6277F307B15A7AB33375244F9C0
29 | IDESourceControlProjectWCConfigurations
30 |
31 |
32 | IDESourceControlRepositoryExtensionIdentifierKey
33 | public.vcs.git
34 | IDESourceControlWCCIdentifierKey
35 | 0F7856B7B7C4C6277F307B15A7AB33375244F9C0
36 | IDESourceControlWCCName
37 | NSURLProtocolExample
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/NSURLProtocolExample.xcworkspace/xcuserdata/houxh.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FreeMind-LJ/NSURLProtocolExample/042aebf2d2608b00c7d3c7b33f4617e390cd7fef/NSURLProtocolExample.xcworkspace/xcuserdata/houxh.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/NSURLProtocolExample.xcworkspace/xcuserdata/houxh.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/NSURLProtocolExample/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // NSURLProtocolExample
4 | //
5 | // Created by lujb on 15/6/15.
6 | // Copyright (c) 2015年 lujb. 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 |
--------------------------------------------------------------------------------
/NSURLProtocolExample/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // NSURLProtocolExample
4 | //
5 | // Created by lujb on 15/6/15.
6 | // Copyright (c) 2015年 lujb. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 | #import "CustomURLProtocol.h"
11 |
12 | @interface AppDelegate ()
13 |
14 | @end
15 |
16 | @implementation AppDelegate
17 |
18 |
19 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
20 | // Override point for customization after application launch.
21 |
22 | //注册protocol
23 | [NSURLProtocol registerClass:[CustomURLProtocol class]];
24 | return YES;
25 | }
26 |
27 | - (void)applicationWillResignActive:(UIApplication *)application {
28 | // 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.
29 | // 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.
30 | }
31 |
32 | - (void)applicationDidEnterBackground:(UIApplication *)application {
33 | // 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.
34 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
35 | }
36 |
37 | - (void)applicationWillEnterForeground:(UIApplication *)application {
38 | // 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.
39 | }
40 |
41 | - (void)applicationDidBecomeActive:(UIApplication *)application {
42 | // 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.
43 | }
44 |
45 | - (void)applicationWillTerminate:(UIApplication *)application {
46 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
47 | }
48 |
49 | @end
50 |
--------------------------------------------------------------------------------
/NSURLProtocolExample/Base.lproj/LaunchScreen.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
20 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/NSURLProtocolExample/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
33 |
39 |
40 |
41 |
42 |
43 |
52 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/NSURLProtocolExample/CustomURLProtocol.h:
--------------------------------------------------------------------------------
1 | //
2 | // CustomURLProtocol.h
3 | // NSURLProtocolExample
4 | //
5 | // Created by lujb on 15/6/15.
6 | // Copyright (c) 2015年 lujb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CustomURLProtocol : NSURLProtocol
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/NSURLProtocolExample/CustomURLProtocol.m:
--------------------------------------------------------------------------------
1 | //
2 | // CustomURLProtocol.m
3 | // NSURLProtocolExample
4 | //
5 | // Created by lujb on 15/6/15.
6 | // Copyright (c) 2015年 lujb. All rights reserved.
7 | //
8 |
9 | #import "CustomURLProtocol.h"
10 |
11 | static NSString * const URLProtocolHandledKey = @"URLProtocolHandledKey";
12 |
13 | @interface CustomURLProtocol ()
14 |
15 | @property (nonatomic, strong) NSURLConnection *connection;
16 |
17 | @end
18 |
19 | @implementation CustomURLProtocol
20 |
21 | + (BOOL)canInitWithRequest:(NSURLRequest *)request
22 | {
23 | //只处理http和https请求
24 | NSString *scheme = [[request URL] scheme];
25 | if ( ([scheme caseInsensitiveCompare:@"http"] == NSOrderedSame ||
26 | [scheme caseInsensitiveCompare:@"https"] == NSOrderedSame))
27 | {
28 | //看看是否已经处理过了,防止无限循环
29 | if ([NSURLProtocol propertyForKey:URLProtocolHandledKey inRequest:request]) {
30 | return NO;
31 | }
32 |
33 | return YES;
34 | }
35 | return NO;
36 | }
37 |
38 | + (NSURLRequest *) canonicalRequestForRequest:(NSURLRequest *)request {
39 | NSMutableURLRequest *mutableReqeust = [request mutableCopy];
40 | mutableReqeust = [self redirectHostInRequset:mutableReqeust];
41 | return mutableReqeust;
42 | }
43 |
44 | + (BOOL)requestIsCacheEquivalent:(NSURLRequest *)a toRequest:(NSURLRequest *)b
45 | {
46 | return [super requestIsCacheEquivalent:a toRequest:b];
47 | }
48 |
49 | - (void)startLoading
50 | {
51 | /* 如果想直接返回缓存的结果,构建一个NSURLResponse对象
52 | if (cachedResponse) {
53 |
54 | NSData *data = cachedResponse.data; //缓存的数据
55 | NSString *mimeType = cachedResponse.mimeType;
56 | NSString *encoding = cachedResponse.encoding;
57 |
58 | NSURLResponse *response = [[NSURLResponse alloc] initWithURL:self.request.URL
59 | MIMEType:mimeType
60 | expectedContentLength:data.length
61 | textEncodingName:encoding];
62 |
63 | [self.client URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];
64 | [self.client URLProtocol:self didLoadData:data];
65 | [self.client URLProtocolDidFinishLoading:self];
66 | */
67 |
68 | NSMutableURLRequest *mutableReqeust = [[self request] mutableCopy];
69 |
70 | //打标签,防止无限循环
71 | [NSURLProtocol setProperty:@YES forKey:URLProtocolHandledKey inRequest:mutableReqeust];
72 |
73 | self.connection = [NSURLConnection connectionWithRequest:mutableReqeust delegate:self];
74 | }
75 |
76 | - (void)stopLoading
77 | {
78 | [self.connection cancel];
79 | }
80 |
81 | #pragma mark - NSURLConnectionDelegate
82 |
83 | - (void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
84 | [self.client URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];
85 | }
86 |
87 | - (void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
88 | [self.client URLProtocol:self didLoadData:data];
89 | }
90 |
91 | - (void) connectionDidFinishLoading:(NSURLConnection *)connection {
92 | [self.client URLProtocolDidFinishLoading:self];
93 | }
94 |
95 | - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
96 | [self.client URLProtocol:self didFailWithError:error];
97 | }
98 |
99 | #pragma mark -- private
100 |
101 | +(NSMutableURLRequest*)redirectHostInRequset:(NSMutableURLRequest*)request
102 | {
103 | if ([request.URL host].length == 0) {
104 | return request;
105 | }
106 |
107 | NSString *originUrlString = [request.URL absoluteString];
108 | NSString *originHostString = [request.URL host];
109 | NSRange hostRange = [originUrlString rangeOfString:originHostString];
110 | if (hostRange.location == NSNotFound) {
111 | return request;
112 | }
113 |
114 | //定向到bing搜索主页
115 | NSString *ip = @"cn.bing.com";
116 |
117 | // 替换host
118 | NSString *urlString = [originUrlString stringByReplacingCharactersInRange:hostRange withString:ip];
119 | NSURL *url = [NSURL URLWithString:urlString];
120 | request.URL = url;
121 |
122 | return request;
123 | }
124 |
125 |
126 | @end
127 |
--------------------------------------------------------------------------------
/NSURLProtocolExample/Images.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 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/NSURLProtocolExample/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | lujb.$(PRODUCT_NAME:rfc1034identifier)
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 |
40 |
41 |
--------------------------------------------------------------------------------
/NSURLProtocolExample/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // NSURLProtocolExample
4 | //
5 | // Created by lujb on 15/6/15.
6 | // Copyright (c) 2015年 lujb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/NSURLProtocolExample/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // NSURLProtocolExample
4 | //
5 | // Created by lujb on 15/6/15.
6 | // Copyright (c) 2015年 lujb. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import
11 |
12 | @interface ViewController ()
13 | @property (weak, nonatomic) IBOutlet UITextField *urlTextField;
14 | @property (weak, nonatomic) IBOutlet UIButton *go;
15 |
16 | @property (weak, nonatomic) IBOutlet UIWebView *webView;
17 | @end
18 |
19 | @implementation ViewController
20 |
21 | - (void)viewDidLoad {
22 | [super viewDidLoad];
23 | // Do any additional setup after loading the view, typically from a nib.
24 | }
25 |
26 | - (void)didReceiveMemoryWarning {
27 | [super didReceiveMemoryWarning];
28 | // Dispose of any resources that can be recreated.
29 | }
30 |
31 | - (IBAction)go:(id)sender {
32 | if ([self.urlTextField isFirstResponder]) {
33 | [self.urlTextField resignFirstResponder];
34 | }
35 |
36 | [self sendRequest];
37 |
38 | }
39 |
40 | #pragma mark - UITextFieldDelegate
41 |
42 | - (BOOL)textFieldShouldReturn:(UITextField *)textField {
43 | [textField resignFirstResponder];
44 |
45 | [self sendRequest];
46 |
47 | return YES;
48 | }
49 |
50 | #pragma mark - request
51 |
52 | - (void) sendRequest {
53 |
54 | NSString *text = self.urlTextField.text;
55 | if (![text isEqualToString:@""]) {
56 |
57 | NSURL *url = [NSURL URLWithString:text];
58 | NSURLRequest *request = [NSURLRequest requestWithURL:url];
59 | [self.webView loadRequest:request];
60 |
61 | }
62 |
63 | }
64 | - (IBAction)afnetworkingGo:(id)sender {
65 | AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
66 | [manager GET:@"http://api.douban.com/v2/book/isbn/9787505715660" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
67 | NSDictionary *bookInfo = (NSDictionary*)responseObject;
68 | NSLog(@"bookInfo:%@",bookInfo);
69 |
70 | } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
71 | NSLog(@"request faile:%@",error.description);
72 | }];
73 |
74 | }
75 |
76 | @end
77 |
--------------------------------------------------------------------------------
/NSURLProtocolExample/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // NSURLProtocolExample
4 | //
5 | // Created by lujb on 15/6/15.
6 | // Copyright (c) 2015年 lujb. 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 |
--------------------------------------------------------------------------------
/NSURLProtocolExampleTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | lujb.$(PRODUCT_NAME:rfc1034identifier)
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 |
--------------------------------------------------------------------------------
/NSURLProtocolExampleTests/NSURLProtocolExampleTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSURLProtocolExampleTests.m
3 | // NSURLProtocolExampleTests
4 | //
5 | // Created by lujb on 15/6/15.
6 | // Copyright (c) 2015年 lujb. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface NSURLProtocolExampleTests : XCTestCase
13 |
14 | @end
15 |
16 | @implementation NSURLProtocolExampleTests
17 |
18 | - (void)setUp {
19 | [super setUp];
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 | }
22 |
23 | - (void)tearDown {
24 | // Put teardown code here. This method is called after the invocation of each test method in the class.
25 | [super tearDown];
26 | }
27 |
28 | - (void)testExample {
29 | // This is an example of a functional test case.
30 | XCTAssert(YES, @"Pass");
31 | }
32 |
33 | - (void)testPerformanceExample {
34 | // This is an example of a performance test case.
35 | [self measureBlock:^{
36 | // Put the code you want to measure the time of here.
37 | }];
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/Podfile:
--------------------------------------------------------------------------------
1 | pod 'AFNetworking', '~> 2.5.4'
--------------------------------------------------------------------------------
/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - AFNetworking (2.5.4):
3 | - AFNetworking/NSURLConnection (= 2.5.4)
4 | - AFNetworking/NSURLSession (= 2.5.4)
5 | - AFNetworking/Reachability (= 2.5.4)
6 | - AFNetworking/Security (= 2.5.4)
7 | - AFNetworking/Serialization (= 2.5.4)
8 | - AFNetworking/UIKit (= 2.5.4)
9 | - AFNetworking/NSURLConnection (2.5.4):
10 | - AFNetworking/Reachability
11 | - AFNetworking/Security
12 | - AFNetworking/Serialization
13 | - AFNetworking/NSURLSession (2.5.4):
14 | - AFNetworking/Reachability
15 | - AFNetworking/Security
16 | - AFNetworking/Serialization
17 | - AFNetworking/Reachability (2.5.4)
18 | - AFNetworking/Security (2.5.4)
19 | - AFNetworking/Serialization (2.5.4)
20 | - AFNetworking/UIKit (2.5.4):
21 | - AFNetworking/NSURLConnection
22 | - AFNetworking/NSURLSession
23 |
24 | DEPENDENCIES:
25 | - AFNetworking (~> 2.5.4)
26 |
27 | SPEC CHECKSUMS:
28 | AFNetworking: 05edc0ac4c4c8cf57bcf4b84be5b0744b6d8e71e
29 |
30 | COCOAPODS: 0.37.1
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 | /**
26 | `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.
27 | */
28 | @interface AFHTTPRequestOperation : AFURLConnectionOperation
29 |
30 | ///------------------------------------------------
31 | /// @name Getting HTTP URL Connection Information
32 | ///------------------------------------------------
33 |
34 | /**
35 | The last HTTP response received by the operation's connection.
36 | */
37 | @property (readonly, nonatomic, strong) NSHTTPURLResponse *response;
38 |
39 | /**
40 | 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.
41 |
42 | @warning `responseSerializer` must not be `nil`. Setting a response serializer will clear out any cached value
43 | */
44 | @property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer;
45 |
46 | /**
47 | 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.
48 | */
49 | @property (readonly, nonatomic, strong) id responseObject;
50 |
51 | ///-----------------------------------------------------------
52 | /// @name Setting Completion Block Success / Failure Callbacks
53 | ///-----------------------------------------------------------
54 |
55 | /**
56 | 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.
57 |
58 | This method should be overridden in subclasses in order to specify the response object passed into the success block.
59 |
60 | @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.
61 | @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.
62 | */
63 | - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
64 | failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
65 |
66 | @end
67 |
--------------------------------------------------------------------------------
/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 | #import
24 |
25 | #ifndef NS_DESIGNATED_INITIALIZER
26 | #if __has_attribute(objc_designated_initializer)
27 | #define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
28 | #else
29 | #define NS_DESIGNATED_INITIALIZER
30 | #endif
31 | #endif
32 |
33 | typedef NS_ENUM(NSInteger, AFNetworkReachabilityStatus) {
34 | AFNetworkReachabilityStatusUnknown = -1,
35 | AFNetworkReachabilityStatusNotReachable = 0,
36 | AFNetworkReachabilityStatusReachableViaWWAN = 1,
37 | AFNetworkReachabilityStatusReachableViaWiFi = 2,
38 | };
39 |
40 | /**
41 | `AFNetworkReachabilityManager` monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces.
42 |
43 | 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.
44 |
45 | See Apple's Reachability Sample Code (https://developer.apple.com/library/ios/samplecode/reachability/)
46 |
47 | @warning Instances of `AFNetworkReachabilityManager` must be started with `-startMonitoring` before reachability status can be determined.
48 | */
49 | @interface AFNetworkReachabilityManager : NSObject
50 |
51 | /**
52 | The current network reachability status.
53 | */
54 | @property (readonly, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus;
55 |
56 | /**
57 | Whether or not the network is currently reachable.
58 | */
59 | @property (readonly, nonatomic, assign, getter = isReachable) BOOL reachable;
60 |
61 | /**
62 | Whether or not the network is currently reachable via WWAN.
63 | */
64 | @property (readonly, nonatomic, assign, getter = isReachableViaWWAN) BOOL reachableViaWWAN;
65 |
66 | /**
67 | Whether or not the network is currently reachable via WiFi.
68 | */
69 | @property (readonly, nonatomic, assign, getter = isReachableViaWiFi) BOOL reachableViaWiFi;
70 |
71 | ///---------------------
72 | /// @name Initialization
73 | ///---------------------
74 |
75 | /**
76 | Returns the shared network reachability manager.
77 | */
78 | + (instancetype)sharedManager;
79 |
80 | /**
81 | Creates and returns a network reachability manager for the specified domain.
82 |
83 | @param domain The domain used to evaluate network reachability.
84 |
85 | @return An initialized network reachability manager, actively monitoring the specified domain.
86 | */
87 | + (instancetype)managerForDomain:(NSString *)domain;
88 |
89 | /**
90 | Creates and returns a network reachability manager for the socket address.
91 |
92 | @param address The socket address (`sockaddr_in`) used to evaluate network reachability.
93 |
94 | @return An initialized network reachability manager, actively monitoring the specified socket address.
95 | */
96 | + (instancetype)managerForAddress:(const void *)address;
97 |
98 | /**
99 | Initializes an instance of a network reachability manager from the specified reachability object.
100 |
101 | @param reachability The reachability object to monitor.
102 |
103 | @return An initialized network reachability manager, actively monitoring the specified reachability.
104 | */
105 | - (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability NS_DESIGNATED_INITIALIZER;
106 |
107 | ///--------------------------------------------------
108 | /// @name Starting & Stopping Reachability Monitoring
109 | ///--------------------------------------------------
110 |
111 | /**
112 | Starts monitoring for changes in network reachability status.
113 | */
114 | - (void)startMonitoring;
115 |
116 | /**
117 | Stops monitoring for changes in network reachability status.
118 | */
119 | - (void)stopMonitoring;
120 |
121 | ///-------------------------------------------------
122 | /// @name Getting Localized Reachability Description
123 | ///-------------------------------------------------
124 |
125 | /**
126 | Returns a localized string representation of the current network reachability status.
127 | */
128 | - (NSString *)localizedNetworkReachabilityStatusString;
129 |
130 | ///---------------------------------------------------
131 | /// @name Setting Network Reachability Change Callback
132 | ///---------------------------------------------------
133 |
134 | /**
135 | Sets a callback to be executed when the network availability of the `baseURL` host changes.
136 |
137 | @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`.
138 | */
139 | - (void)setReachabilityStatusChangeBlock:(void (^)(AFNetworkReachabilityStatus status))block;
140 |
141 | @end
142 |
143 | ///----------------
144 | /// @name Constants
145 | ///----------------
146 |
147 | /**
148 | ## Network Reachability
149 |
150 | The following constants are provided by `AFNetworkReachabilityManager` as possible network reachability statuses.
151 |
152 | enum {
153 | AFNetworkReachabilityStatusUnknown,
154 | AFNetworkReachabilityStatusNotReachable,
155 | AFNetworkReachabilityStatusReachableViaWWAN,
156 | AFNetworkReachabilityStatusReachableViaWiFi,
157 | }
158 |
159 | `AFNetworkReachabilityStatusUnknown`
160 | The `baseURL` host reachability is not known.
161 |
162 | `AFNetworkReachabilityStatusNotReachable`
163 | The `baseURL` host cannot be reached.
164 |
165 | `AFNetworkReachabilityStatusReachableViaWWAN`
166 | The `baseURL` host can be reached via a cellular connection, such as EDGE or GPRS.
167 |
168 | `AFNetworkReachabilityStatusReachableViaWiFi`
169 | The `baseURL` host can be reached via a Wi-Fi connection.
170 |
171 | ### Keys for Notification UserInfo Dictionary
172 |
173 | Strings that are used as keys in a `userInfo` dictionary in a network reachability status change notification.
174 |
175 | `AFNetworkingReachabilityNotificationStatusItem`
176 | A key in the userInfo dictionary in a `AFNetworkingReachabilityDidChangeNotification` notification.
177 | The corresponding value is an `NSNumber` object representing the `AFNetworkReachabilityStatus` value for the current reachability status.
178 | */
179 |
180 | ///--------------------
181 | /// @name Notifications
182 | ///--------------------
183 |
184 | /**
185 | Posted when network reachability changes.
186 | 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.
187 |
188 | @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`).
189 | */
190 | extern NSString * const AFNetworkingReachabilityDidChangeNotification;
191 | extern NSString * const AFNetworkingReachabilityNotificationStatusItem;
192 |
193 | ///--------------------
194 | /// @name Functions
195 | ///--------------------
196 |
197 | /**
198 | Returns a localized string representation of an `AFNetworkReachabilityStatus` value.
199 | */
200 | extern NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status);
201 |
--------------------------------------------------------------------------------
/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 |
24 | #import
25 | #import
26 | #import
27 | #import
28 | #import
29 |
30 | NSString * const AFNetworkingReachabilityDidChangeNotification = @"com.alamofire.networking.reachability.change";
31 | NSString * const AFNetworkingReachabilityNotificationStatusItem = @"AFNetworkingReachabilityNotificationStatusItem";
32 |
33 | typedef void (^AFNetworkReachabilityStatusBlock)(AFNetworkReachabilityStatus status);
34 |
35 | typedef NS_ENUM(NSUInteger, AFNetworkReachabilityAssociation) {
36 | AFNetworkReachabilityForAddress = 1,
37 | AFNetworkReachabilityForAddressPair = 2,
38 | AFNetworkReachabilityForName = 3,
39 | };
40 |
41 | NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status) {
42 | switch (status) {
43 | case AFNetworkReachabilityStatusNotReachable:
44 | return NSLocalizedStringFromTable(@"Not Reachable", @"AFNetworking", nil);
45 | case AFNetworkReachabilityStatusReachableViaWWAN:
46 | return NSLocalizedStringFromTable(@"Reachable via WWAN", @"AFNetworking", nil);
47 | case AFNetworkReachabilityStatusReachableViaWiFi:
48 | return NSLocalizedStringFromTable(@"Reachable via WiFi", @"AFNetworking", nil);
49 | case AFNetworkReachabilityStatusUnknown:
50 | default:
51 | return NSLocalizedStringFromTable(@"Unknown", @"AFNetworking", nil);
52 | }
53 | }
54 |
55 | static AFNetworkReachabilityStatus AFNetworkReachabilityStatusForFlags(SCNetworkReachabilityFlags flags) {
56 | BOOL isReachable = ((flags & kSCNetworkReachabilityFlagsReachable) != 0);
57 | BOOL needsConnection = ((flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0);
58 | BOOL canConnectionAutomatically = (((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0) || ((flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0));
59 | BOOL canConnectWithoutUserInteraction = (canConnectionAutomatically && (flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0);
60 | BOOL isNetworkReachable = (isReachable && (!needsConnection || canConnectWithoutUserInteraction));
61 |
62 | AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusUnknown;
63 | if (isNetworkReachable == NO) {
64 | status = AFNetworkReachabilityStatusNotReachable;
65 | }
66 | #if TARGET_OS_IPHONE
67 | else if ((flags & kSCNetworkReachabilityFlagsIsWWAN) != 0) {
68 | status = AFNetworkReachabilityStatusReachableViaWWAN;
69 | }
70 | #endif
71 | else {
72 | status = AFNetworkReachabilityStatusReachableViaWiFi;
73 | }
74 |
75 | return status;
76 | }
77 |
78 | static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNetworkReachabilityFlags flags, void *info) {
79 | AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusForFlags(flags);
80 | AFNetworkReachabilityStatusBlock block = (__bridge AFNetworkReachabilityStatusBlock)info;
81 | if (block) {
82 | block(status);
83 | }
84 |
85 |
86 | dispatch_async(dispatch_get_main_queue(), ^{
87 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
88 | NSDictionary *userInfo = @{ AFNetworkingReachabilityNotificationStatusItem: @(status) };
89 | [notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:userInfo];
90 | });
91 |
92 | }
93 |
94 | static const void * AFNetworkReachabilityRetainCallback(const void *info) {
95 | return Block_copy(info);
96 | }
97 |
98 | static void AFNetworkReachabilityReleaseCallback(const void *info) {
99 | if (info) {
100 | Block_release(info);
101 | }
102 | }
103 |
104 | @interface AFNetworkReachabilityManager ()
105 | @property (readwrite, nonatomic, assign) SCNetworkReachabilityRef networkReachability;
106 | @property (readwrite, nonatomic, assign) AFNetworkReachabilityAssociation networkReachabilityAssociation;
107 | @property (readwrite, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus;
108 | @property (readwrite, nonatomic, copy) AFNetworkReachabilityStatusBlock networkReachabilityStatusBlock;
109 | @end
110 |
111 | @implementation AFNetworkReachabilityManager
112 |
113 | + (instancetype)sharedManager {
114 | static AFNetworkReachabilityManager *_sharedManager = nil;
115 | static dispatch_once_t onceToken;
116 | dispatch_once(&onceToken, ^{
117 | struct sockaddr_in address;
118 | bzero(&address, sizeof(address));
119 | address.sin_len = sizeof(address);
120 | address.sin_family = AF_INET;
121 |
122 | _sharedManager = [self managerForAddress:&address];
123 | });
124 |
125 | return _sharedManager;
126 | }
127 |
128 | + (instancetype)managerForDomain:(NSString *)domain {
129 | SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, [domain UTF8String]);
130 |
131 | AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability];
132 | manager.networkReachabilityAssociation = AFNetworkReachabilityForName;
133 |
134 | return manager;
135 | }
136 |
137 | + (instancetype)managerForAddress:(const void *)address {
138 | SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr *)address);
139 |
140 | AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability];
141 | manager.networkReachabilityAssociation = AFNetworkReachabilityForAddress;
142 |
143 | return manager;
144 | }
145 |
146 | - (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability {
147 | self = [super init];
148 | if (!self) {
149 | return nil;
150 | }
151 |
152 | self.networkReachability = reachability;
153 | self.networkReachabilityStatus = AFNetworkReachabilityStatusUnknown;
154 |
155 | return self;
156 | }
157 |
158 | - (void)dealloc {
159 | [self stopMonitoring];
160 |
161 | if (_networkReachability) {
162 | CFRelease(_networkReachability);
163 | _networkReachability = NULL;
164 | }
165 | }
166 |
167 | #pragma mark -
168 |
169 | - (BOOL)isReachable {
170 | return [self isReachableViaWWAN] || [self isReachableViaWiFi];
171 | }
172 |
173 | - (BOOL)isReachableViaWWAN {
174 | return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWWAN;
175 | }
176 |
177 | - (BOOL)isReachableViaWiFi {
178 | return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWiFi;
179 | }
180 |
181 | #pragma mark -
182 |
183 | - (void)startMonitoring {
184 | [self stopMonitoring];
185 |
186 | if (!self.networkReachability) {
187 | return;
188 | }
189 |
190 | __weak __typeof(self)weakSelf = self;
191 | AFNetworkReachabilityStatusBlock callback = ^(AFNetworkReachabilityStatus status) {
192 | __strong __typeof(weakSelf)strongSelf = weakSelf;
193 |
194 | strongSelf.networkReachabilityStatus = status;
195 | if (strongSelf.networkReachabilityStatusBlock) {
196 | strongSelf.networkReachabilityStatusBlock(status);
197 | }
198 |
199 | };
200 |
201 | SCNetworkReachabilityContext context = {0, (__bridge void *)callback, AFNetworkReachabilityRetainCallback, AFNetworkReachabilityReleaseCallback, NULL};
202 | SCNetworkReachabilitySetCallback(self.networkReachability, AFNetworkReachabilityCallback, &context);
203 | SCNetworkReachabilityScheduleWithRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes);
204 |
205 | switch (self.networkReachabilityAssociation) {
206 | case AFNetworkReachabilityForName:
207 | break;
208 | case AFNetworkReachabilityForAddress:
209 | case AFNetworkReachabilityForAddressPair:
210 | default: {
211 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0),^{
212 | SCNetworkReachabilityFlags flags;
213 | SCNetworkReachabilityGetFlags(self.networkReachability, &flags);
214 | AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusForFlags(flags);
215 | dispatch_async(dispatch_get_main_queue(), ^{
216 | callback(status);
217 |
218 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
219 | [notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:@{ AFNetworkingReachabilityNotificationStatusItem: @(status) }];
220 |
221 |
222 | });
223 | });
224 | }
225 | break;
226 | }
227 | }
228 |
229 | - (void)stopMonitoring {
230 | if (!self.networkReachability) {
231 | return;
232 | }
233 |
234 | SCNetworkReachabilityUnscheduleFromRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes);
235 | }
236 |
237 | #pragma mark -
238 |
239 | - (NSString *)localizedNetworkReachabilityStatusString {
240 | return AFStringFromNetworkReachabilityStatus(self.networkReachabilityStatus);
241 | }
242 |
243 | #pragma mark -
244 |
245 | - (void)setReachabilityStatusChangeBlock:(void (^)(AFNetworkReachabilityStatus status))block {
246 | self.networkReachabilityStatusBlock = block;
247 | }
248 |
249 | #pragma mark - NSKeyValueObserving
250 |
251 | + (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key {
252 | if ([key isEqualToString:@"reachable"] || [key isEqualToString:@"reachableViaWWAN"] || [key isEqualToString:@"reachableViaWiFi"]) {
253 | return [NSSet setWithObject:@"networkReachabilityStatus"];
254 | }
255 |
256 | return [super keyPathsForValuesAffectingValueForKey:key];
257 | }
258 |
259 | @end
260 |
--------------------------------------------------------------------------------
/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 | #import "AFNetworkReachabilityManager.h"
33 |
34 | #import "AFURLConnectionOperation.h"
35 | #import "AFHTTPRequestOperation.h"
36 | #import "AFHTTPRequestOperationManager.h"
37 |
38 | #if ( ( defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) || \
39 | ( defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 ) )
40 | #import "AFURLSessionManager.h"
41 | #import "AFHTTPSessionManager.h"
42 | #endif
43 |
44 | #endif /* _AFNETWORKING_ */
45 |
--------------------------------------------------------------------------------
/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 | @interface AFSecurityPolicy : NSObject
37 |
38 | /**
39 | The criteria by which server trust should be evaluated against the pinned SSL certificates. Defaults to `AFSSLPinningModeNone`.
40 | */
41 | @property (readonly, nonatomic, assign) AFSSLPinningMode SSLPinningMode;
42 |
43 | /**
44 | Whether to evaluate an entire SSL certificate chain, or just the leaf certificate. Defaults to `YES`.
45 | */
46 | @property (nonatomic, assign) BOOL validatesCertificateChain;
47 |
48 | /**
49 | 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.
50 | */
51 | @property (nonatomic, strong) NSArray *pinnedCertificates;
52 |
53 | /**
54 | Whether or not to trust servers with an invalid or expired SSL certificates. Defaults to `NO`.
55 | */
56 | @property (nonatomic, assign) BOOL allowInvalidCertificates;
57 |
58 | /**
59 | Whether or not to validate the domain name in the certificate's CN field. Defaults to `YES`.
60 | */
61 | @property (nonatomic, assign) BOOL validatesDomainName;
62 |
63 | ///-----------------------------------------
64 | /// @name Getting Specific Security Policies
65 | ///-----------------------------------------
66 |
67 | /**
68 | 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.
69 |
70 | @return The default security policy.
71 | */
72 | + (instancetype)defaultPolicy;
73 |
74 | ///---------------------
75 | /// @name Initialization
76 | ///---------------------
77 |
78 | /**
79 | Creates and returns a security policy with the specified pinning mode.
80 |
81 | @param pinningMode The SSL pinning mode.
82 |
83 | @return A new security policy.
84 | */
85 | + (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode;
86 |
87 | ///------------------------------
88 | /// @name Evaluating Server Trust
89 | ///------------------------------
90 |
91 | /**
92 | Whether or not the specified server trust should be accepted, based on the security policy.
93 |
94 | This method should be used when responding to an authentication challenge from a server.
95 |
96 | @param serverTrust The X.509 certificate trust of the server.
97 |
98 | @return Whether or not to trust the server.
99 |
100 | @warning This method has been deprecated in favor of `-evaluateServerTrust:forDomain:`.
101 | */
102 | - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust DEPRECATED_ATTRIBUTE;
103 |
104 | /**
105 | Whether or not the specified server trust should be accepted, based on the security policy.
106 |
107 | This method should be used when responding to an authentication challenge from a server.
108 |
109 | @param serverTrust The X.509 certificate trust of the server.
110 | @param domain The domain of serverTrust. If `nil`, the domain will not be validated.
111 |
112 | @return Whether or not to trust the server.
113 | */
114 | - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust
115 | forDomain:(NSString *)domain;
116 |
117 | @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 !defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
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 defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
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.validatesCertificateChain = YES;
200 | self.validatesDomainName = YES;
201 |
202 | return self;
203 | }
204 |
205 | - (void)setPinnedCertificates:(NSArray *)pinnedCertificates {
206 | _pinnedCertificates = pinnedCertificates;
207 |
208 | if (self.pinnedCertificates) {
209 | NSMutableArray *mutablePinnedPublicKeys = [NSMutableArray arrayWithCapacity:[self.pinnedCertificates count]];
210 | for (NSData *certificate in self.pinnedCertificates) {
211 | id publicKey = AFPublicKeyForCertificate(certificate);
212 | if (!publicKey) {
213 | continue;
214 | }
215 | [mutablePinnedPublicKeys addObject:publicKey];
216 | }
217 | self.pinnedPublicKeys = [NSArray arrayWithArray:mutablePinnedPublicKeys];
218 | } else {
219 | self.pinnedPublicKeys = nil;
220 | }
221 | }
222 |
223 | #pragma mark -
224 |
225 | - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust {
226 | return [self evaluateServerTrust:serverTrust forDomain:nil];
227 | }
228 |
229 | - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust
230 | forDomain:(NSString *)domain
231 | {
232 | NSMutableArray *policies = [NSMutableArray array];
233 | if (self.validatesDomainName) {
234 | [policies addObject:(__bridge_transfer id)SecPolicyCreateSSL(true, (__bridge CFStringRef)domain)];
235 | } else {
236 | [policies addObject:(__bridge_transfer id)SecPolicyCreateBasicX509()];
237 | }
238 |
239 | SecTrustSetPolicies(serverTrust, (__bridge CFArrayRef)policies);
240 |
241 | if (self.SSLPinningMode == AFSSLPinningModeNone) {
242 | if (self.allowInvalidCertificates || AFServerTrustIsValid(serverTrust)){
243 | return YES;
244 | } else {
245 | return NO;
246 | }
247 | } else if (!AFServerTrustIsValid(serverTrust) && !self.allowInvalidCertificates) {
248 | return NO;
249 | }
250 |
251 | NSArray *serverCertificates = AFCertificateTrustChainForServerTrust(serverTrust);
252 | switch (self.SSLPinningMode) {
253 | case AFSSLPinningModeNone:
254 | default:
255 | return NO;
256 | case AFSSLPinningModeCertificate: {
257 | NSMutableArray *pinnedCertificates = [NSMutableArray array];
258 | for (NSData *certificateData in self.pinnedCertificates) {
259 | [pinnedCertificates addObject:(__bridge_transfer id)SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificateData)];
260 | }
261 | SecTrustSetAnchorCertificates(serverTrust, (__bridge CFArrayRef)pinnedCertificates);
262 |
263 | if (!AFServerTrustIsValid(serverTrust)) {
264 | return NO;
265 | }
266 |
267 | if (!self.validatesCertificateChain) {
268 | return YES;
269 | }
270 |
271 | NSUInteger trustedCertificateCount = 0;
272 | for (NSData *trustChainCertificate in serverCertificates) {
273 | if ([self.pinnedCertificates containsObject:trustChainCertificate]) {
274 | trustedCertificateCount++;
275 | }
276 | }
277 |
278 | return trustedCertificateCount == [serverCertificates count];
279 | }
280 | case AFSSLPinningModePublicKey: {
281 | NSUInteger trustedPublicKeyCount = 0;
282 | NSArray *publicKeys = AFPublicKeyTrustChainForServerTrust(serverTrust);
283 | if (!self.validatesCertificateChain && [publicKeys count] > 0) {
284 | publicKeys = @[[publicKeys firstObject]];
285 | }
286 |
287 | for (id trustChainPublicKey in publicKeys) {
288 | for (id pinnedPublicKey in self.pinnedPublicKeys) {
289 | if (AFSecKeyIsEqualToKey((__bridge SecKeyRef)trustChainPublicKey, (__bridge SecKeyRef)pinnedPublicKey)) {
290 | trustedPublicKeyCount += 1;
291 | }
292 | }
293 | }
294 |
295 | return trustedPublicKeyCount > 0 && ((self.validatesCertificateChain && trustedPublicKeyCount == [serverCertificates count]) || (!self.validatesCertificateChain && trustedPublicKeyCount >= 1));
296 | }
297 | }
298 |
299 | return NO;
300 | }
301 |
302 | #pragma mark - NSKeyValueObserving
303 |
304 | + (NSSet *)keyPathsForValuesAffectingPinnedPublicKeys {
305 | return [NSSet setWithObject:@"pinnedCertificates"];
306 | }
307 |
308 | @end
309 |
--------------------------------------------------------------------------------
/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 | /**
31 | `AFNetworkActivityIndicatorManager` manages the state of the network activity indicator in the status bar. When enabled, it will listen for notifications indicating that a network request operation has started or finished, and start or stop animating the indicator accordingly. The number of active requests is incremented and decremented much like a stack or a semaphore, and the activity indicator will animate so long as that number is greater than zero.
32 |
33 | You should enable the shared instance of `AFNetworkActivityIndicatorManager` when your application finishes launching. In `AppDelegate application:didFinishLaunchingWithOptions:` you can do so with the following code:
34 |
35 | [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES];
36 |
37 | By setting `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.
38 |
39 | See the Apple Human Interface Guidelines section about the Network Activity Indicator for more information:
40 | http://developer.apple.com/library/iOS/#documentation/UserExperience/Conceptual/MobileHIG/UIElementGuidelines/UIElementGuidelines.html#//apple_ref/doc/uid/TP40006556-CH13-SW44
41 | */
42 | @interface AFNetworkActivityIndicatorManager : NSObject
43 |
44 | /**
45 | A Boolean value indicating whether the manager is enabled.
46 |
47 | If YES, the manager will change status bar network activity indicator according to network operation notifications it receives. The default value is NO.
48 | */
49 | @property (nonatomic, assign, getter = isEnabled) BOOL enabled;
50 |
51 | /**
52 | A Boolean value indicating whether the network activity indicator is currently displayed in the status bar.
53 | */
54 | @property (readonly, nonatomic, assign) BOOL isNetworkActivityIndicatorVisible;
55 |
56 | /**
57 | Returns the shared network activity indicator manager object for the system.
58 |
59 | @return The systemwide network activity indicator manager.
60 | */
61 | + (instancetype)sharedManager;
62 |
63 | /**
64 | Increments the number of active network requests. If this number was zero before incrementing, this will start animating the status bar network activity indicator.
65 | */
66 | - (void)incrementActivityCount;
67 |
68 | /**
69 | Decrements the number of active network requests. If this number becomes zero after decrementing, this will stop animating the status bar network activity indicator.
70 | */
71 | - (void)decrementActivityCount;
72 |
73 | @end
74 |
75 | #endif
76 |
--------------------------------------------------------------------------------
/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 | #if !defined(AF_APP_EXTENSIONS)
117 | [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:[self isNetworkActivityIndicatorVisible]];
118 | #endif
119 | }
120 |
121 | - (void)setActivityCount:(NSInteger)activityCount {
122 | @synchronized(self) {
123 | _activityCount = activityCount;
124 | }
125 |
126 | dispatch_async(dispatch_get_main_queue(), ^{
127 | [self updateNetworkActivityIndicatorVisibilityDelayed];
128 | });
129 | }
130 |
131 | - (void)incrementActivityCount {
132 | [self willChangeValueForKey:@"activityCount"];
133 | @synchronized(self) {
134 | _activityCount++;
135 | }
136 | [self didChangeValueForKey:@"activityCount"];
137 |
138 | dispatch_async(dispatch_get_main_queue(), ^{
139 | [self updateNetworkActivityIndicatorVisibilityDelayed];
140 | });
141 | }
142 |
143 | - (void)decrementActivityCount {
144 | [self willChangeValueForKey:@"activityCount"];
145 | @synchronized(self) {
146 | #pragma clang diagnostic push
147 | #pragma clang diagnostic ignored "-Wgnu"
148 | _activityCount = MAX(_activityCount - 1, 0);
149 | #pragma clang diagnostic pop
150 | }
151 | [self didChangeValueForKey:@"activityCount"];
152 |
153 | dispatch_async(dispatch_get_main_queue(), ^{
154 | [self updateNetworkActivityIndicatorVisibilityDelayed];
155 | });
156 | }
157 |
158 | - (void)networkRequestDidStart:(NSNotification *)notification {
159 | if ([AFNetworkRequestFromNotification(notification) URL]) {
160 | [self incrementActivityCount];
161 | }
162 | }
163 |
164 | - (void)networkRequestDidFinish:(NSNotification *)notification {
165 | if ([AFNetworkRequestFromNotification(notification) URL]) {
166 | [self decrementActivityCount];
167 | }
168 | }
169 |
170 | @end
171 |
172 | #endif
173 |
--------------------------------------------------------------------------------
/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:(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:(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 |
24 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
25 |
26 | #import "AFHTTPRequestOperation.h"
27 |
28 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
29 | #import "AFURLSessionManager.h"
30 | #endif
31 |
32 | @implementation UIActivityIndicatorView (AFNetworking)
33 |
34 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
35 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task {
36 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
37 |
38 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil];
39 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil];
40 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil];
41 |
42 | if (task) {
43 | if (task.state != NSURLSessionTaskStateCompleted) {
44 | if (task.state == NSURLSessionTaskStateRunning) {
45 | [self startAnimating];
46 | } else {
47 | [self stopAnimating];
48 | }
49 |
50 | [notificationCenter addObserver:self selector:@selector(af_startAnimating) name:AFNetworkingTaskDidResumeNotification object:task];
51 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidCompleteNotification object:task];
52 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidSuspendNotification object:task];
53 | }
54 | }
55 | }
56 | #endif
57 |
58 | #pragma mark -
59 |
60 | - (void)setAnimatingWithStateOfOperation:(AFURLConnectionOperation *)operation {
61 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
62 |
63 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidStartNotification object:nil];
64 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidFinishNotification object:nil];
65 |
66 | if (operation) {
67 | if (![operation isFinished]) {
68 | if ([operation isExecuting]) {
69 | [self startAnimating];
70 | } else {
71 | [self stopAnimating];
72 | }
73 |
74 | [notificationCenter addObserver:self selector:@selector(af_startAnimating) name:AFNetworkingOperationDidStartNotification object:operation];
75 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingOperationDidFinishNotification object:operation];
76 | }
77 | }
78 | }
79 |
80 | #pragma mark -
81 |
82 | - (void)af_startAnimating {
83 | dispatch_async(dispatch_get_main_queue(), ^{
84 | [self startAnimating];
85 | });
86 | }
87 |
88 | - (void)af_stopAnimating {
89 | dispatch_async(dispatch_get_main_queue(), ^{
90 | [self stopAnimating];
91 | });
92 | }
93 |
94 | @end
95 |
96 | #endif
97 |
--------------------------------------------------------------------------------
/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) && !defined(AF_APP_EXTENSIONS)
27 |
28 | #import
29 |
30 | @class AFURLConnectionOperation;
31 |
32 | /**
33 | 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.
34 | */
35 | @interface UIAlertView (AFNetworking)
36 |
37 | ///-------------------------------------
38 | /// @name Showing Alert for Session Task
39 | ///-------------------------------------
40 |
41 | /**
42 | Shows an alert view with the error of the specified session task, if any.
43 |
44 | @param task The session task.
45 | @param delegate The alert view delegate.
46 | */
47 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
48 | + (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task
49 | delegate:(id)delegate;
50 | #endif
51 |
52 | /**
53 | Shows an alert view with the error of the specified session task, if any, with a custom cancel button title and other button titles.
54 |
55 | @param task The session task.
56 | @param delegate The alert view delegate.
57 | @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.
58 | @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`.
59 | */
60 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
61 | + (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task
62 | delegate:(id)delegate
63 | cancelButtonTitle:(NSString *)cancelButtonTitle
64 | otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION;
65 | #endif
66 |
67 | ///------------------------------------------
68 | /// @name Showing Alert for Request Operation
69 | ///------------------------------------------
70 |
71 | /**
72 | Shows an alert view with the error of the specified request operation, if any.
73 |
74 | @param operation The request operation.
75 | @param delegate The alert view delegate.
76 | */
77 | + (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation
78 | delegate:(id)delegate;
79 |
80 | /**
81 | Shows an alert view with the error of the specified request operation, if any, with a custom cancel button title and other button titles.
82 |
83 | @param operation The request operation.
84 | @param delegate The alert view delegate.
85 | @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.
86 | @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`.
87 | */
88 | + (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation
89 | delegate:(id)delegate
90 | cancelButtonTitle:(NSString *)cancelButtonTitle
91 | otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION;
92 |
93 | @end
94 |
95 | #endif
96 |
--------------------------------------------------------------------------------
/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) && !defined(AF_APP_EXTENSIONS)
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 | @protocol AFURLResponseSerialization, AFImageCache;
31 |
32 | /**
33 | 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.
34 |
35 | @warning Compound values for control `state` (such as `UIControlStateHighlighted | UIControlStateDisabled`) are unsupported.
36 | */
37 | @interface UIButton (AFNetworking)
38 |
39 | ///----------------------------
40 | /// @name Accessing Image Cache
41 | ///----------------------------
42 |
43 | /**
44 | The image cache used to improve image loadiing performance on scroll views. By default, `UIButton` will use the `sharedImageCache` of `UIImageView`.
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 as the image for the specified state 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 | @param state The control state.
76 | @param url The URL used for the image request.
77 | */
78 | - (void)setImageForState:(UIControlState)state
79 | withURL:(NSURL *)url;
80 |
81 | /**
82 | 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.
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 | @param state The control state.
87 | @param url The URL used for the image request.
88 | @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.
89 | */
90 | - (void)setImageForState:(UIControlState)state
91 | withURL:(NSURL *)url
92 | placeholderImage:(UIImage *)placeholderImage;
93 |
94 | /**
95 | 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.
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 button before returning. If no success block is specified, the default behavior of setting the image with `setImage:forState:` is applied.
100 |
101 | @param state The control state.
102 | @param urlRequest The URL request used for the image request.
103 | @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.
104 | @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`.
105 | @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.
106 | */
107 | - (void)setImageForState:(UIControlState)state
108 | withURLRequest:(NSURLRequest *)urlRequest
109 | placeholderImage:(UIImage *)placeholderImage
110 | success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success
111 | failure:(void (^)(NSError *error))failure;
112 |
113 |
114 | ///-------------------------------
115 | /// @name Setting Background Image
116 | ///-------------------------------
117 |
118 | /**
119 | 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.
120 |
121 | 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.
122 |
123 | @param state The control state.
124 | @param url The URL used for the background image request.
125 | */
126 | - (void)setBackgroundImageForState:(UIControlState)state
127 | withURL:(NSURL *)url;
128 |
129 | /**
130 | 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.
131 |
132 | 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.
133 |
134 | @param state The control state.
135 | @param url The URL used for the background image request.
136 | @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.
137 | */
138 | - (void)setBackgroundImageForState:(UIControlState)state
139 | withURL:(NSURL *)url
140 | placeholderImage:(UIImage *)placeholderImage;
141 |
142 | /**
143 | 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.
144 |
145 | 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.
146 |
147 | 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.
148 |
149 | @param state The control state.
150 | @param urlRequest The URL request used for the image request.
151 | @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.
152 | */
153 | - (void)setBackgroundImageForState:(UIControlState)state
154 | withURLRequest:(NSURLRequest *)urlRequest
155 | placeholderImage:(UIImage *)placeholderImage
156 | success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success
157 | failure:(void (^)(NSError *error))failure;
158 |
159 |
160 | ///------------------------------
161 | /// @name Canceling Image Loading
162 | ///------------------------------
163 |
164 | /**
165 | Cancels any executing image operation for the specified control state of the receiver, if one exists.
166 |
167 | @param state The control state.
168 | */
169 | - (void)cancelImageRequestOperationForState:(UIControlState)state;
170 |
171 | /**
172 | Cancels any executing background image operation for the specified control state of the receiver, if one exists.
173 |
174 | @param state The control state.
175 | */
176 | - (void)cancelBackgroundImageRequestOperationForState:(UIControlState)state;
177 |
178 | @end
179 |
180 | #endif
181 |
--------------------------------------------------------------------------------
/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 | @protocol AFURLResponseSerialization, AFImageCache;
31 |
32 | /**
33 | 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.
34 | */
35 | @interface UIImageView (AFNetworking)
36 |
37 | ///----------------------------
38 | /// @name Accessing Image Cache
39 | ///----------------------------
40 |
41 | /**
42 | 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.
43 | */
44 | + (id )sharedImageCache;
45 |
46 | /**
47 | Set the cache used for image loading.
48 |
49 | @param imageCache The image cache.
50 | */
51 | + (void)setSharedImageCache:(id )imageCache;
52 |
53 | ///------------------------------------
54 | /// @name Accessing Response Serializer
55 | ///------------------------------------
56 |
57 | /**
58 | The response serializer used to create an image representation from the server response and response data. By default, this is an instance of `AFImageResponseSerializer`.
59 |
60 | @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
61 | */
62 | @property (nonatomic, strong) id imageResponseSerializer;
63 |
64 | ///--------------------
65 | /// @name Setting Image
66 | ///--------------------
67 |
68 | /**
69 | 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.
70 |
71 | 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.
72 |
73 | 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:`
74 |
75 | @param url The URL used for the image request.
76 | */
77 | - (void)setImageWithURL:(NSURL *)url;
78 |
79 | /**
80 | 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.
81 |
82 | 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.
83 |
84 | 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:`
85 |
86 | @param url The URL used for the image request.
87 | @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.
88 | */
89 | - (void)setImageWithURL:(NSURL *)url
90 | placeholderImage:(UIImage *)placeholderImage;
91 |
92 | /**
93 | 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.
94 |
95 | 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.
96 |
97 | 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.
98 |
99 | @param urlRequest The URL request used for the image request.
100 | @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.
101 | @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 request and response parameters will be `nil`.
102 | @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.
103 | */
104 | - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest
105 | placeholderImage:(UIImage *)placeholderImage
106 | success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success
107 | failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure;
108 |
109 | /**
110 | Cancels any executing image operation for the receiver, if one exists.
111 | */
112 | - (void)cancelImageRequestOperation;
113 |
114 | @end
115 |
116 | #pragma mark -
117 |
118 | /**
119 | The `AFImageCache` protocol is adopted by an object used to cache images loaded by the AFNetworking category on `UIImageView`.
120 | */
121 | @protocol AFImageCache
122 |
123 | /**
124 | Returns a cached image for the specififed request, if available.
125 |
126 | @param request The image request.
127 |
128 | @return The cached image.
129 | */
130 | - (UIImage *)cachedImageForRequest:(NSURLRequest *)request;
131 |
132 | /**
133 | Caches a particular image for the specified request.
134 |
135 | @param image The image to cache.
136 | @param request The request to be used as a cache key.
137 | */
138 | - (void)cacheImage:(UIImage *)image
139 | forRequest:(NSURLRequest *)request;
140 | @end
141 |
142 | #endif
143 |
--------------------------------------------------------------------------------
/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(nil, 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 | #import
24 |
25 | #ifndef _UIKIT_AFNETWORKING_
26 | #define _UIKIT_AFNETWORKING_
27 |
28 | #import "AFNetworkActivityIndicatorManager.h"
29 |
30 | #import "UIActivityIndicatorView+AFNetworking.h"
31 | #import "UIAlertView+AFNetworking.h"
32 | #import "UIButton+AFNetworking.h"
33 | #import "UIImageView+AFNetworking.h"
34 | #import "UIKit+AFNetworking.h"
35 | #import "UIProgressView+AFNetworking.h"
36 | #import "UIRefreshControl+AFNetworking.h"
37 | #import "UIWebView+AFNetworking.h"
38 | #endif /* _UIKIT_AFNETWORKING_ */
39 |
--------------------------------------------------------------------------------
/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 | @class AFURLConnectionOperation;
31 |
32 | /**
33 | 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.
34 | */
35 | @interface UIProgressView (AFNetworking)
36 |
37 | ///------------------------------------
38 | /// @name Setting Session Task Progress
39 | ///------------------------------------
40 |
41 | /**
42 | Binds the progress to the upload progress of the specified session task.
43 |
44 | @param task The session task.
45 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately.
46 | */
47 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
48 | - (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task
49 | animated:(BOOL)animated;
50 | #endif
51 |
52 | /**
53 | Binds the progress to the download progress of the specified session task.
54 |
55 | @param task The session task.
56 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately.
57 | */
58 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
59 | - (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task
60 | animated:(BOOL)animated;
61 | #endif
62 |
63 | ///------------------------------------
64 | /// @name Setting Session Task Progress
65 | ///------------------------------------
66 |
67 | /**
68 | Binds the progress to the upload progress of the specified request operation.
69 |
70 | @param operation The request operation.
71 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately.
72 | */
73 | - (void)setProgressWithUploadProgressOfOperation:(AFURLConnectionOperation *)operation
74 | animated:(BOOL)animated;
75 |
76 | /**
77 | Binds the progress to the download progress of the specified request operation.
78 |
79 | @param operation The request operation.
80 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately.
81 | */
82 | - (void)setProgressWithDownloadProgressOfOperation:(AFURLConnectionOperation *)operation
83 | animated:(BOOL)animated;
84 |
85 | @end
86 |
87 | #endif
88 |
--------------------------------------------------------------------------------
/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 | @class AFURLConnectionOperation;
32 |
33 | /**
34 | This category adds methods to the UIKit framework's `UIRefreshControl` class. The methods in this category provide support for automatically begining and ending refreshing depending on the loading state of a request operation or session task.
35 | */
36 | @interface UIRefreshControl (AFNetworking)
37 |
38 | ///-----------------------------------
39 | /// @name Refreshing for Session Tasks
40 | ///-----------------------------------
41 |
42 | /**
43 | Binds the refreshing state to the state of the specified task.
44 |
45 | @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled.
46 | */
47 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
48 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task;
49 | #endif
50 |
51 | ///----------------------------------------
52 | /// @name Refreshing for Request Operations
53 | ///----------------------------------------
54 |
55 | /**
56 | Binds the refreshing state to the execution state of the specified operation.
57 |
58 | @param operation The operation. If `nil`, automatic updating from any previously specified operation will be disabled.
59 | */
60 | - (void)setRefreshingWithStateOfOperation:(AFURLConnectionOperation *)operation;
61 |
62 | @end
63 |
64 | #endif
65 |
--------------------------------------------------------------------------------
/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 |
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 | @implementation UIRefreshControl (AFNetworking)
34 |
35 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
36 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task {
37 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
38 |
39 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil];
40 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil];
41 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil];
42 |
43 | if (task) {
44 | if (task.state == NSURLSessionTaskStateRunning) {
45 | [self beginRefreshing];
46 |
47 | [notificationCenter addObserver:self selector:@selector(af_beginRefreshing) name:AFNetworkingTaskDidResumeNotification object:task];
48 | [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidCompleteNotification object:task];
49 | [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidSuspendNotification object:task];
50 | } else {
51 | [self endRefreshing];
52 | }
53 | }
54 | }
55 | #endif
56 |
57 | - (void)setRefreshingWithStateOfOperation:(AFURLConnectionOperation *)operation {
58 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
59 |
60 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidStartNotification object:nil];
61 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidFinishNotification object:nil];
62 |
63 | if (operation) {
64 | if (![operation isFinished]) {
65 | if ([operation isExecuting]) {
66 | [self beginRefreshing];
67 | } else {
68 | [self endRefreshing];
69 | }
70 |
71 | [notificationCenter addObserver:self selector:@selector(af_beginRefreshing) name:AFNetworkingOperationDidStartNotification object:operation];
72 | [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingOperationDidFinishNotification object:operation];
73 | }
74 | }
75 | }
76 |
77 | #pragma mark -
78 |
79 | - (void)af_beginRefreshing {
80 | dispatch_async(dispatch_get_main_queue(), ^{
81 | [self beginRefreshing];
82 | });
83 | }
84 |
85 | - (void)af_endRefreshing {
86 | dispatch_async(dispatch_get_main_queue(), ^{
87 | [self endRefreshing];
88 | });
89 | }
90 |
91 | @end
92 |
93 | #endif
94 |
--------------------------------------------------------------------------------
/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 | @class AFHTTPRequestSerializer, AFHTTPResponseSerializer;
31 | @protocol AFURLRequestSerialization, AFURLResponseSerialization;
32 |
33 | /**
34 | 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.
35 |
36 | @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.
37 | */
38 | @interface UIWebView (AFNetworking)
39 |
40 | /**
41 | The request serializer used to serialize requests made with the `-loadRequest:...` category methods. By default, this is an instance of `AFHTTPRequestSerializer`.
42 | */
43 | @property (nonatomic, strong) AFHTTPRequestSerializer * requestSerializer;
44 |
45 | /**
46 | The response serializer used to serialize responses made with the `-loadRequest:...` category methods. By default, this is an instance of `AFHTTPResponseSerializer`.
47 | */
48 | @property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer;
49 |
50 | /**
51 | Asynchronously loads the specified request.
52 |
53 | @param request A URL request identifying the location of the content to load. This must not be `nil`.
54 | @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.
55 | @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.
56 | @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.
57 | */
58 | - (void)loadRequest:(NSURLRequest *)request
59 | progress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress
60 | success:(NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success
61 | failure:(void (^)(NSError *error))failure;
62 |
63 | /**
64 | Asynchronously loads the data associated with a particular request with a specified MIME type and text encoding.
65 |
66 | @param request A URL request identifying the location of the content to load. This must not be `nil`.
67 | @param MIMEType The MIME type of the content. Defaults to the content type of the response if not specified.
68 | @param textEncodingName The IANA encoding name, as in `utf-8` or `utf-16`. Defaults to the response text encoding if not specified.
69 | @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.
70 | @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.
71 | @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.
72 | */
73 | - (void)loadRequest:(NSURLRequest *)request
74 | MIMEType:(NSString *)MIMEType
75 | textEncodingName:(NSString *)textEncodingName
76 | progress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress
77 | success:(NSData * (^)(NSHTTPURLResponse *response, NSData *data))success
78 | failure:(void (^)(NSError *error))failure;
79 |
80 | @end
81 |
82 | #endif
83 |
--------------------------------------------------------------------------------
/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/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/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.5.4):
3 | - AFNetworking/NSURLConnection (= 2.5.4)
4 | - AFNetworking/NSURLSession (= 2.5.4)
5 | - AFNetworking/Reachability (= 2.5.4)
6 | - AFNetworking/Security (= 2.5.4)
7 | - AFNetworking/Serialization (= 2.5.4)
8 | - AFNetworking/UIKit (= 2.5.4)
9 | - AFNetworking/NSURLConnection (2.5.4):
10 | - AFNetworking/Reachability
11 | - AFNetworking/Security
12 | - AFNetworking/Serialization
13 | - AFNetworking/NSURLSession (2.5.4):
14 | - AFNetworking/Reachability
15 | - AFNetworking/Security
16 | - AFNetworking/Serialization
17 | - AFNetworking/Reachability (2.5.4)
18 | - AFNetworking/Security (2.5.4)
19 | - AFNetworking/Serialization (2.5.4)
20 | - AFNetworking/UIKit (2.5.4):
21 | - AFNetworking/NSURLConnection
22 | - AFNetworking/NSURLSession
23 |
24 | DEPENDENCIES:
25 | - AFNetworking (~> 2.5.4)
26 |
27 | SPEC CHECKSUMS:
28 | AFNetworking: 05edc0ac4c4c8cf57bcf4b84be5b0744b6d8e71e
29 |
30 | COCOAPODS: 0.37.1
31 |
--------------------------------------------------------------------------------
/Pods/Pods.xcodeproj/xcuserdata/houxh.xcuserdatad/xcschemes/Pods-AFNetworking.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
42 |
43 |
44 |
45 |
51 |
52 |
54 |
55 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/Pods/Pods.xcodeproj/xcuserdata/houxh.xcuserdatad/xcschemes/Pods.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
42 |
43 |
44 |
45 |
51 |
52 |
54 |
55 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/Pods/Pods.xcodeproj/xcuserdata/houxh.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | Pods-AFNetworking.xcscheme
8 |
9 | isShown
10 |
11 |
12 | Pods.xcscheme
13 |
14 | isShown
15 |
16 |
17 |
18 | SuppressBuildableAutocreation
19 |
20 | 3E64184EC73E42E6046C2235
21 |
22 | primary
23 |
24 |
25 | D48C505C94C659359BE07370
26 |
27 | primary
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/Pods-AFNetworking/Pods-AFNetworking-Private.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Pods-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 = ${PODS_AFNETWORKING_OTHER_LDFLAGS} -ObjC
5 | PODS_ROOT = ${SRCROOT}
6 | SKIP_INSTALL = YES
--------------------------------------------------------------------------------
/Pods/Target Support Files/Pods-AFNetworking/Pods-AFNetworking-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_Pods_AFNetworking : NSObject
3 | @end
4 | @implementation PodsDummy_Pods_AFNetworking
5 | @end
6 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/Pods-AFNetworking/Pods-AFNetworking-prefix.pch:
--------------------------------------------------------------------------------
1 | #ifdef __OBJC__
2 | #import
3 | #endif
4 |
5 | #import "Pods-environment.h"
6 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/Pods-AFNetworking/Pods-AFNetworking.xcconfig:
--------------------------------------------------------------------------------
1 | PODS_AFNETWORKING_OTHER_LDFLAGS = -framework "CoreGraphics" -framework "MobileCoreServices" -framework "Security" -framework "SystemConfiguration"
--------------------------------------------------------------------------------
/Pods/Target Support Files/Pods/Pods-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/Pods-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/Pods-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_Pods : NSObject
3 | @end
4 | @implementation PodsDummy_Pods
5 | @end
6 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/Pods/Pods-environment.h:
--------------------------------------------------------------------------------
1 |
2 | // To check if a library is compiled with CocoaPods you
3 | // can use the `COCOAPODS` macro definition which is
4 | // defined in the xcconfigs so it is available in
5 | // headers also when they are imported in the client
6 | // project.
7 |
8 |
9 | // AFNetworking
10 | #define COCOAPODS_POD_AVAILABLE_AFNetworking
11 | #define COCOAPODS_VERSION_MAJOR_AFNetworking 2
12 | #define COCOAPODS_VERSION_MINOR_AFNetworking 5
13 | #define COCOAPODS_VERSION_PATCH_AFNetworking 4
14 |
15 | // AFNetworking/NSURLConnection
16 | #define COCOAPODS_POD_AVAILABLE_AFNetworking_NSURLConnection
17 | #define COCOAPODS_VERSION_MAJOR_AFNetworking_NSURLConnection 2
18 | #define COCOAPODS_VERSION_MINOR_AFNetworking_NSURLConnection 5
19 | #define COCOAPODS_VERSION_PATCH_AFNetworking_NSURLConnection 4
20 |
21 | // AFNetworking/NSURLSession
22 | #define COCOAPODS_POD_AVAILABLE_AFNetworking_NSURLSession
23 | #define COCOAPODS_VERSION_MAJOR_AFNetworking_NSURLSession 2
24 | #define COCOAPODS_VERSION_MINOR_AFNetworking_NSURLSession 5
25 | #define COCOAPODS_VERSION_PATCH_AFNetworking_NSURLSession 4
26 |
27 | // AFNetworking/Reachability
28 | #define COCOAPODS_POD_AVAILABLE_AFNetworking_Reachability
29 | #define COCOAPODS_VERSION_MAJOR_AFNetworking_Reachability 2
30 | #define COCOAPODS_VERSION_MINOR_AFNetworking_Reachability 5
31 | #define COCOAPODS_VERSION_PATCH_AFNetworking_Reachability 4
32 |
33 | // AFNetworking/Security
34 | #define COCOAPODS_POD_AVAILABLE_AFNetworking_Security
35 | #define COCOAPODS_VERSION_MAJOR_AFNetworking_Security 2
36 | #define COCOAPODS_VERSION_MINOR_AFNetworking_Security 5
37 | #define COCOAPODS_VERSION_PATCH_AFNetworking_Security 4
38 |
39 | // AFNetworking/Serialization
40 | #define COCOAPODS_POD_AVAILABLE_AFNetworking_Serialization
41 | #define COCOAPODS_VERSION_MAJOR_AFNetworking_Serialization 2
42 | #define COCOAPODS_VERSION_MINOR_AFNetworking_Serialization 5
43 | #define COCOAPODS_VERSION_PATCH_AFNetworking_Serialization 4
44 |
45 | // AFNetworking/UIKit
46 | #define COCOAPODS_POD_AVAILABLE_AFNetworking_UIKit
47 | #define COCOAPODS_VERSION_MAJOR_AFNetworking_UIKit 2
48 | #define COCOAPODS_VERSION_MINOR_AFNetworking_UIKit 5
49 | #define COCOAPODS_VERSION_PATCH_AFNetworking_UIKit 4
50 |
51 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/Pods/Pods-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 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
62 | if [[ "${ACTION}" == "install" ]]; then
63 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
64 | fi
65 | rm -f "$RESOURCES_TO_COPY"
66 |
67 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ]
68 | then
69 | case "${TARGETED_DEVICE_FAMILY}" in
70 | 1,2)
71 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone"
72 | ;;
73 | 1)
74 | TARGET_DEVICE_ARGS="--target-device iphone"
75 | ;;
76 | 2)
77 | TARGET_DEVICE_ARGS="--target-device ipad"
78 | ;;
79 | *)
80 | TARGET_DEVICE_ARGS="--target-device mac"
81 | ;;
82 | esac
83 |
84 | # Find all other xcassets (this unfortunately includes those of path pods and other targets).
85 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d)
86 | while read line; do
87 | if [[ $line != "`realpath $PODS_ROOT`*" ]]; then
88 | XCASSET_FILES+=("$line")
89 | fi
90 | done <<<"$OTHER_XCASSETS"
91 |
92 | 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}"
93 | fi
94 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/Pods/Pods.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"Pods-AFNetworking" -framework "CoreGraphics" -framework "MobileCoreServices" -framework "Security" -framework "SystemConfiguration"
5 | OTHER_LIBTOOLFLAGS = $(OTHER_LDFLAGS)
6 | PODS_ROOT = ${SRCROOT}/Pods
--------------------------------------------------------------------------------
/Pods/Target Support Files/Pods/Pods.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"Pods-AFNetworking" -framework "CoreGraphics" -framework "MobileCoreServices" -framework "Security" -framework "SystemConfiguration"
5 | OTHER_LIBTOOLFLAGS = $(OTHER_LDFLAGS)
6 | PODS_ROOT = ${SRCROOT}/Pods
--------------------------------------------------------------------------------