├── .gitignore
├── NetworkRequest.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ └── contents.xcworkspacedata
└── xcuserdata
│ └── chenyufeng.xcuserdatad
│ └── xcschemes
│ ├── NetworkRequest.xcscheme
│ └── xcschememanagement.plist
├── NetworkRequest.xcworkspace
└── contents.xcworkspacedata
├── NetworkRequest
├── AFNHttp1ViewController.h
├── AFNHttp1ViewController.m
├── AFNHttp2ViewController.h
├── AFNHttp2ViewController.m
├── AFNHttp3ViewController.h
├── AFNHttp3ViewController.m
├── AFNXMLHttpViewController.h
├── AFNXMLHttpViewController.m
├── AFNsoapViewController.h
├── AFNsoapViewController.m
├── AppDelegate.h
├── AppDelegate.m
├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
├── Base.lproj
│ ├── LaunchScreen.storyboard
│ └── Main.storyboard
├── HttpGet1ViewController.h
├── HttpGet1ViewController.m
├── HttpGet2ViewController.h
├── HttpGet2ViewController.m
├── Info.plist
├── MainTableViewController.h
├── MainTableViewController.m
├── SOAP1ViewController.h
├── SOAP1ViewController.m
├── SOAP2ViewController.h
├── SOAP2ViewController.m
├── SOAP3ViewController.h
├── SOAP3ViewController.m
└── main.m
├── NetworkRequestTests
├── Info.plist
└── NetworkRequestTests.m
├── NetworkRequestUITests
├── Info.plist
└── NetworkRequestUITests.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
│ │ ├── UIImage+AFNetworking.h
│ │ ├── UIImageView+AFNetworking.h
│ │ ├── UIImageView+AFNetworking.m
│ │ ├── UIKit+AFNetworking.h
│ │ ├── UIProgressView+AFNetworking.h
│ │ ├── UIProgressView+AFNetworking.m
│ │ ├── UIRefreshControl+AFNetworking.h
│ │ ├── UIRefreshControl+AFNetworking.m
│ │ ├── UIWebView+AFNetworking.h
│ │ └── UIWebView+AFNetworking.m
├── Headers
│ ├── Private
│ │ └── AFNetworking
│ │ │ ├── AFHTTPRequestOperation.h
│ │ │ ├── AFHTTPRequestOperationManager.h
│ │ │ ├── AFHTTPSessionManager.h
│ │ │ ├── AFNetworkActivityIndicatorManager.h
│ │ │ ├── AFNetworkReachabilityManager.h
│ │ │ ├── AFNetworking.h
│ │ │ ├── AFSecurityPolicy.h
│ │ │ ├── AFURLConnectionOperation.h
│ │ │ ├── AFURLRequestSerialization.h
│ │ │ ├── AFURLResponseSerialization.h
│ │ │ ├── AFURLSessionManager.h
│ │ │ ├── UIActivityIndicatorView+AFNetworking.h
│ │ │ ├── UIAlertView+AFNetworking.h
│ │ │ ├── UIButton+AFNetworking.h
│ │ │ ├── UIImage+AFNetworking.h
│ │ │ ├── UIImageView+AFNetworking.h
│ │ │ ├── UIKit+AFNetworking.h
│ │ │ ├── UIProgressView+AFNetworking.h
│ │ │ ├── UIRefreshControl+AFNetworking.h
│ │ │ └── UIWebView+AFNetworking.h
│ └── Public
│ │ └── AFNetworking
│ │ ├── AFHTTPRequestOperation.h
│ │ ├── AFHTTPRequestOperationManager.h
│ │ ├── AFHTTPSessionManager.h
│ │ ├── AFNetworkActivityIndicatorManager.h
│ │ ├── AFNetworkReachabilityManager.h
│ │ ├── AFNetworking.h
│ │ ├── AFSecurityPolicy.h
│ │ ├── AFURLConnectionOperation.h
│ │ ├── AFURLRequestSerialization.h
│ │ ├── AFURLResponseSerialization.h
│ │ ├── AFURLSessionManager.h
│ │ ├── UIActivityIndicatorView+AFNetworking.h
│ │ ├── UIAlertView+AFNetworking.h
│ │ ├── UIButton+AFNetworking.h
│ │ ├── UIImage+AFNetworking.h
│ │ ├── UIImageView+AFNetworking.h
│ │ ├── UIKit+AFNetworking.h
│ │ ├── UIProgressView+AFNetworking.h
│ │ ├── UIRefreshControl+AFNetworking.h
│ │ └── UIWebView+AFNetworking.h
├── Manifest.lock
├── Pods.xcodeproj
│ └── project.pbxproj
└── Target Support Files
│ ├── AFNetworking
│ ├── AFNetworking-dummy.m
│ ├── AFNetworking-prefix.pch
│ └── AFNetworking.xcconfig
│ └── Pods
│ ├── Pods-acknowledgements.markdown
│ ├── Pods-acknowledgements.plist
│ ├── Pods-dummy.m
│ ├── Pods-frameworks.sh
│ ├── Pods-resources.sh
│ ├── Pods.debug.xcconfig
│ └── Pods.release.xcconfig
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | *.xcuserstate
3 | *.xcscheme
4 |
5 |
6 | build/
7 | DerivedData
8 |
9 | *.pbxuser
10 | !default.pbxuser
11 | *.mode1v3
12 | !default.mode1v3
13 | *.mode2v3
14 | !default.mode2v3
15 | *.perspectivev3
16 | !default.perspectivev3
17 | xcuserdata
18 |
19 | *.xccheckout
20 | *.moved-aside
21 |
22 |
23 |
24 | .AppleDouble
25 | .LSOverride
26 |
27 |
28 | .DocumentRevisions-V100
29 | .fseventsd
30 | .Spotlight-V100
31 | .TemporaryItems
32 | .Trashes
33 | .VolumeIcon.icns
34 |
35 |
36 | .AppleDB
37 | .AppleDesktop
38 | Network Trash Folder
39 | Temporary Items
40 | .apdisk
41 |
--------------------------------------------------------------------------------
/NetworkRequest.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/NetworkRequest.xcodeproj/xcuserdata/chenyufeng.xcuserdatad/xcschemes/NetworkRequest.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
43 |
49 |
50 |
51 |
52 |
53 |
59 |
60 |
61 |
62 |
63 |
64 |
74 |
76 |
82 |
83 |
84 |
85 |
86 |
87 |
93 |
95 |
101 |
102 |
103 |
104 |
106 |
107 |
110 |
111 |
112 |
--------------------------------------------------------------------------------
/NetworkRequest.xcodeproj/xcuserdata/chenyufeng.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | NetworkRequest.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 71DBBF811C068C5C00DE661C
16 |
17 | primary
18 |
19 |
20 | 71DBBF9A1C068C5C00DE661C
21 |
22 | primary
23 |
24 |
25 | 71DBBFA51C068C5C00DE661C
26 |
27 | primary
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/NetworkRequest.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/NetworkRequest/AFNHttp1ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // AFNWebServiceViewController.h
3 | // NetworkRequest
4 | //
5 | // Created by chenyufeng on 15/11/26.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AFNHttp1ViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/NetworkRequest/AFNHttp1ViewController.m:
--------------------------------------------------------------------------------
1 |
2 |
3 | //
4 | // AFNWebServiceViewController.m
5 | // NetworkRequest
6 | //
7 | // Created by chenyufeng on 15/11/26.
8 | // Copyright © 2015年 chenyufengweb. All rights reserved.
9 | //
10 |
11 | #import "AFNHttp1ViewController.h"
12 | #import
13 |
14 | @interface AFNHttp1ViewController ()
15 |
16 | @end
17 |
18 | @implementation AFNHttp1ViewController
19 |
20 | - (void)viewDidLoad {
21 |
22 | [super viewDidLoad];
23 | AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
24 | manager.responseSerializer = [AFHTTPResponseSerializer serializer];
25 | //这里改成POST,就可以进行POST请求;
26 | //把要传递的参数直接放到URL中;而不是放到字典中;
27 | [manager GET:@"http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx/getMobileCodeInfo?mobileCode=18888888888&userId="
28 | parameters:nil
29 | success:^(AFHTTPRequestOperation *operation,id responseObject){
30 |
31 | NSString *string = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
32 | NSLog(@"成功: %@", string);
33 | }
34 | failure:^(AFHTTPRequestOperation *operation,NSError *error){
35 |
36 | NSLog(@"失败: %@", error);
37 | }];
38 | }
39 | @end
--------------------------------------------------------------------------------
/NetworkRequest/AFNHttp2ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // AFNHttp2ViewController.h
3 | // NetworkRequest
4 | //
5 | // Created by chenyufeng on 15/11/27.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AFNHttp2ViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/NetworkRequest/AFNHttp2ViewController.m:
--------------------------------------------------------------------------------
1 |
2 | //
3 | // AFNHttp2ViewController.m
4 | // NetworkRequest
5 | //
6 | // Created by chenyufeng on 15/11/27.
7 | // Copyright © 2015年 chenyufengweb. All rights reserved.
8 | //
9 |
10 | #import "AFNHttp2ViewController.h"
11 | #import
12 |
13 | @interface AFNHttp2ViewController ()
14 |
15 | @end
16 |
17 | @implementation AFNHttp2ViewController
18 |
19 | - (void)viewDidLoad {
20 |
21 | [super viewDidLoad];
22 | AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
23 | manager.responseSerializer = [AFHTTPResponseSerializer serializer];
24 | NSDictionary *dic = @{@"mobileCode":@"18888888888",
25 | @"userID":@""};
26 | //这里改成POST,就可以进行POST请求;
27 | [manager GET:@"http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx/getMobileCodeInfo"
28 | parameters:dic
29 | success:^(AFHTTPRequestOperation *operation,id responseObject){
30 |
31 | NSString *string = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
32 | NSLog(@"成功: %@", string);
33 | }
34 | failure:^(AFHTTPRequestOperation *operation,NSError *error){
35 |
36 | NSLog(@"失败: %@", error);
37 | }];
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/NetworkRequest/AFNHttp3ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // AFNHttp3ViewController.h
3 | // NetworkRequest
4 | //
5 | // Created by chenyufeng on 15/11/27.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AFNHttp3ViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/NetworkRequest/AFNHttp3ViewController.m:
--------------------------------------------------------------------------------
1 |
2 | //
3 | // AFNHttp3ViewController.m
4 | // NetworkRequest
5 | //
6 | // Created by chenyufeng on 15/11/27.
7 | // Copyright © 2015年 chenyufengweb. All rights reserved.
8 | //
9 |
10 | #import "AFNHttp3ViewController.h"
11 | #import
12 |
13 | @interface AFNHttp3ViewController ()
14 |
15 | @end
16 |
17 | @implementation AFNHttp3ViewController
18 |
19 | - (void)viewDidLoad {
20 |
21 | [super viewDidLoad];
22 | NSURL *url = [NSURL URLWithString: @"http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx/getMobileCodeInfo?mobileCode=18888888888&userId="];
23 | NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
24 | [req setHTTPMethod:@"GET"];
25 | AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:req];
26 | operation.responseSerializer = [AFHTTPResponseSerializer serializer];
27 | [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation * _Nonnull operation, id _Nonnull responseObject) {
28 |
29 | NSString *result = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
30 | NSLog(@"成功:%@",result);
31 | } failure:^(AFHTTPRequestOperation * _Nonnull operation, NSError * _Nonnull error) {
32 |
33 | NSLog(@"失败:%@",error);
34 | }];
35 | [operation start];
36 | }
37 | @end
--------------------------------------------------------------------------------
/NetworkRequest/AFNXMLHttpViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // AFNXMLHttpViewController.h
3 | // NetworkRequest
4 | //
5 | // Created by chenyufeng on 15/11/28.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AFNXMLHttpViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/NetworkRequest/AFNXMLHttpViewController.m:
--------------------------------------------------------------------------------
1 |
2 | //
3 | // AFNXMLHttpViewController.m
4 | // NetworkRequest
5 | //
6 | // Created by chenyufeng on 15/11/28.
7 | // Copyright © 2015年 chenyufengweb. All rights reserved.
8 | //
9 |
10 | #import "AFNXMLHttpViewController.h"
11 | #import
12 |
13 | @interface AFNXMLHttpViewController ()
14 |
15 | @end
16 |
17 | @implementation AFNXMLHttpViewController
18 |
19 | - (void)viewDidLoad {
20 |
21 | [super viewDidLoad];
22 | /*
23 | 这里需要进行如下的安全性设置;
24 | 使用AFNetworking发送XML,如果不进行如下的设置,将会报错:
25 | Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}
26 | */
27 | AFSecurityPolicy *securityPolicy = [[AFSecurityPolicy alloc] init];
28 | [securityPolicy setAllowInvalidCertificates:YES];
29 |
30 | AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
31 | [manager setSecurityPolicy:securityPolicy];
32 | manager.responseSerializer = [AFHTTPResponseSerializer serializer];
33 | NSString *str = @"这里存放需要发送的XML";
34 | NSDictionary *parameters = @{@"test" : str};
35 | [manager POST:@"需要发送的链接"
36 | parameters:parameters
37 | success:^(AFHTTPRequestOperation *operation,id responseObject){
38 |
39 | NSString *string = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
40 | NSLog(@"成功: %@", string);
41 | }
42 | failure:^(AFHTTPRequestOperation *operation,NSError *error){
43 |
44 | NSLog(@"失败: %@", error);
45 | }];
46 | }
47 | @end
--------------------------------------------------------------------------------
/NetworkRequest/AFNsoapViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // AFNsoapViewController.h
3 | // NetworkRequest
4 | //
5 | // Created by chenyufeng on 15/11/27.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AFNsoapViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/NetworkRequest/AFNsoapViewController.m:
--------------------------------------------------------------------------------
1 |
2 |
3 | //
4 | // AFNsoapViewController.m
5 | // NetworkRequest
6 | //
7 | // Created by chenyufeng on 15/11/27.
8 | // Copyright © 2015年 chenyufengweb. All rights reserved.
9 | //
10 |
11 | #import "AFNsoapViewController.h"
12 | #import
13 |
14 | @interface AFNsoapViewController ()
15 |
16 | @end
17 |
18 | @implementation AFNsoapViewController
19 |
20 | - (void)viewDidLoad {
21 |
22 | [super viewDidLoad];
23 | // 创建SOAP消息,内容格式就是网站上提示的请求报文的主体实体部分 这里使用了SOAP1.2;
24 | NSString *soapMsg = [NSString stringWithFormat:
25 | @""
26 | ""
30 | ""
31 | ""
32 | "%@"
33 | "%@"
34 | ""
35 | ""
36 | "", @"18888888888", @""];
37 |
38 | NSURL *url = [NSURL URLWithString: @"http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx"];
39 | NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
40 | NSString *msgLength = [NSString stringWithFormat:@"%lu", (unsigned long)[soapMsg length]];
41 | [req addValue:@"application/soap+xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
42 | [req addValue:msgLength forHTTPHeaderField:@"Content-Length"];
43 | [req setHTTPMethod:@"POST"];
44 | [req setHTTPBody: [soapMsg dataUsingEncoding:NSUTF8StringEncoding]];
45 |
46 | AFHTTPRequestOperation *operate = [[AFHTTPRequestOperation alloc] initWithRequest:req];
47 | operate.responseSerializer = [AFHTTPResponseSerializer serializer];
48 |
49 | if ([[NSFileManager defaultManager] fileExistsAtPath:@"Library/Caches/12"]) {
50 | //从本地读缓存文件
51 | NSData *data = [NSData dataWithContentsOfFile:@"Library/Caches/12"];
52 | //这个data就可以使用了;
53 | NSString *result = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
54 | NSLog(@"缓存结果:%@",result);
55 | }else{
56 | //缓存不存在,就可以继续进行网络请求;
57 | }
58 |
59 | [operate setCompletionBlockWithSuccess:^(AFHTTPRequestOperation * _Nonnull operation, id _Nonnull responseObject) {
60 | //在AFNETWorking中,并没有提供现成的缓存方案,我们可以通过写文件的方式,自行做缓存。
61 | //写缓存:我这里存储NSData,此时缓存的内容必定是最新的内容;
62 | //Library/Caches:存放缓存文件,iTunes不会备份此目录,此目录下文件不会在应用退出删除
63 | /**
64 | * 1:Documents:应用中用户数据可以放在这里,iTunes备份和恢复的时候会包括此目录
65 | 2:tmp:存放临时文件,iTunes不会备份和恢复此目录,此目录下文件可能会在应用退出后删除
66 | 3:Library/Caches:存放缓存文件,iTunes不会备份此目录,此目录下文件不会在应用退出删除
67 | */
68 | [responseObject writeToFile:@"Library/Caches/12" options:NSDataWritingWithoutOverwriting error:nil];
69 | NSString *result = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
70 | NSLog(@"成功:%@",result);
71 | } failure:^(AFHTTPRequestOperation * _Nonnull operation, NSError * _Nonnull error) {
72 |
73 | NSLog(@"失败:%@",error);
74 | }];
75 | [operate start];
76 | }
77 |
78 | @end
79 |
--------------------------------------------------------------------------------
/NetworkRequest/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // NetworkRequest
4 | //
5 | // Created by chenyufeng on 15/11/26.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 | @end
16 |
17 |
--------------------------------------------------------------------------------
/NetworkRequest/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // NetworkRequest
4 | //
5 | // Created by chenyufeng on 15/11/26.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
18 |
19 | // NSLog(@"沙盒路径:%@",NSHomeDirectory());
20 | return YES;
21 | }
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/NetworkRequest/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "ipad",
35 | "size" : "29x29",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "ipad",
40 | "size" : "29x29",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "40x40",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "40x40",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "76x76",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "76x76",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
--------------------------------------------------------------------------------
/NetworkRequest/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/NetworkRequest/HttpGet1ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // HttpGetViewController.h
3 | // NetworkRequest
4 | //
5 | // Created by chenyufeng on 15/11/26.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface HttpGet1ViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/NetworkRequest/HttpGet1ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // HttpGetViewController.m
3 | // NetworkRequest
4 | //
5 | // Created by chenyufeng on 15/11/26.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import "HttpGet1ViewController.h"
10 |
11 | @interface HttpGet1ViewController ()
12 |
13 | @end
14 |
15 | @implementation HttpGet1ViewController
16 |
17 | - (void)viewDidLoad {
18 |
19 | [super viewDidLoad];
20 | /*
21 | 为什么要执行如下方法?
22 | 因为有的服务端要求把中文进行utf8编码,而我们的代码默认是unicode编码。必须要进行一下的转码,否则返回的可能为空,或者是其他编码格式的乱码了!
23 | 注意可以对整个url直接进行转码,而没必要对出现的每一个中文字符进行编码;
24 | */
25 | //以下方法已经不推荐使用;
26 | // NSString *urlStr = [@"http://v.juhe.cn/weather/index?format=2&cityname=北京&key=88e194ce72b455563c3bed01d5f967c5"stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
27 |
28 | //建议使用这个方法stringByAddingPercentEncodingWithAllowedCharacters,不推荐使用stringByAddingPercentEscapesUsingEncoding;
29 | NSString *urlStr2 = [@"http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx/getMobileCodeInfo?mobileCode=18888888888&userId=" stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
30 | [self asynHttpGet:urlStr2];
31 | }
32 |
33 | - (NSString *)asynHttpGet:(NSString *)urlAsString{
34 |
35 | NSURL *url = [NSURL URLWithString:urlAsString];
36 | __block NSString *resault=@"";
37 | NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:url];
38 | [urlRequest setTimeoutInterval:30];
39 | [urlRequest setHTTPMethod:@"GET"];
40 | //以下方法已经被弃用;
41 | [NSURLConnection
42 | sendAsynchronousRequest:urlRequest
43 | queue:[[NSOperationQueue alloc] init]
44 | completionHandler:^(NSURLResponse *response,NSData *data,NSError *error) {
45 | if (!error) {
46 |
47 | NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
48 | NSLog(@"返回成功:%@",string);
49 | }else{
50 |
51 | NSLog(@"发生错误:%@",error);
52 | }
53 | }];
54 | return resault;
55 | }
56 |
57 | @end
--------------------------------------------------------------------------------
/NetworkRequest/HttpGet2ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // HttpGet2ViewController.h
3 | // NetworkRequest
4 | //
5 | // Created by chenyufeng on 15/11/27.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface HttpGet2ViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/NetworkRequest/HttpGet2ViewController.m:
--------------------------------------------------------------------------------
1 |
2 | //
3 | // HttpGet2ViewController.m
4 | // NetworkRequest
5 | //
6 | // Created by chenyufeng on 15/11/27.
7 | // Copyright © 2015年 chenyufengweb. All rights reserved.
8 | //
9 |
10 | #import "HttpGet2ViewController.h"
11 |
12 | @interface HttpGet2ViewController ()
13 |
14 | @end
15 |
16 | @implementation HttpGet2ViewController
17 |
18 | - (void)viewDidLoad {
19 |
20 | [super viewDidLoad];
21 | /*
22 | 为什么要执行如下方法?
23 | 因为有的服务端要求把中文进行utf8编码,而我们的代码默认是unicode编码。必须要进行一下的转码,否则返回的可能为空,或者是其他编码格式的乱码了!
24 | 注意可以对整个url直接进行转码,而没必要对出现的每一个中文字符进行编码;
25 | */
26 | //以下方法已经不推荐使用;
27 | // NSString *urlStr = [@"http://v.juhe.cn/weather/index?format=2&cityname=北京&key=88e194ce72b455563c3bed01d5f967c5"stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
28 |
29 | //建议使用这个方法stringByAddingPercentEncodingWithAllowedCharacters,不推荐使用stringByAddingPercentEscapesUsingEncoding;
30 | NSString *urlStr2 = [@"http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx/getMobileCodeInfo?mobileCode=18888888888&userId=" stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
31 | [self asynHttpGet:urlStr2];
32 | }
33 |
34 | - (NSString *)asynHttpGet:(NSString *)urlAsString{
35 |
36 | NSURL *url = [NSURL URLWithString:urlAsString];
37 | // __block NSString *resault=@"";
38 | NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:url];
39 | [urlRequest setTimeoutInterval:30];
40 | [urlRequest setHTTPMethod:@"GET"];
41 |
42 | //推荐使用这种请求方法;
43 | NSURLSession *session = [NSURLSession sharedSession];
44 | __block NSString *result = @"";
45 | NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:urlRequest completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
46 | if (!error) {
47 | //没有错误,返回正确;
48 | result = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
49 | NSLog(@"返回正确:%@",result);
50 | }else{
51 | //出现错误;
52 | NSLog(@"错误信息:%@",error);
53 | }
54 | }];
55 | [dataTask resume];
56 | return result;
57 | }
58 |
59 | @end
--------------------------------------------------------------------------------
/NetworkRequest/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NSAppTransportSecurity
6 |
7 | NSAllowsArbitraryLoads
8 |
9 |
10 | CFBundleDevelopmentRegion
11 | en
12 | CFBundleExecutable
13 | $(EXECUTABLE_NAME)
14 | CFBundleIdentifier
15 | $(PRODUCT_BUNDLE_IDENTIFIER)
16 | CFBundleInfoDictionaryVersion
17 | 6.0
18 | CFBundleName
19 | $(PRODUCT_NAME)
20 | CFBundlePackageType
21 | APPL
22 | CFBundleShortVersionString
23 | 1.0
24 | CFBundleSignature
25 | ????
26 | CFBundleVersion
27 | 1
28 | LSRequiresIPhoneOS
29 |
30 | UILaunchStoryboardName
31 | LaunchScreen
32 | UIMainStoryboardFile
33 | Main
34 | UIRequiredDeviceCapabilities
35 |
36 | armv7
37 |
38 | UISupportedInterfaceOrientations
39 |
40 | UIInterfaceOrientationPortrait
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 | UISupportedInterfaceOrientations~ipad
45 |
46 | UIInterfaceOrientationPortrait
47 | UIInterfaceOrientationPortraitUpsideDown
48 | UIInterfaceOrientationLandscapeLeft
49 | UIInterfaceOrientationLandscapeRight
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/NetworkRequest/MainTableViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // MainTableViewController.h
3 | // NetworkRequest
4 | //
5 | // Created by chenyufeng on 15/11/26.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface MainTableViewController : UITableViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/NetworkRequest/MainTableViewController.m:
--------------------------------------------------------------------------------
1 |
2 |
3 | //
4 | // MainTableViewController.m
5 | // NetworkRequest
6 | //
7 | // Created by chenyufeng on 15/11/26.
8 | // Copyright © 2015年 chenyufengweb. All rights reserved.
9 | //
10 |
11 | #import "MainTableViewController.h"
12 |
13 | @interface MainTableViewController ()
14 |
15 | @end
16 |
17 | @implementation MainTableViewController
18 |
19 | - (void)viewDidLoad {
20 |
21 | [super viewDidLoad];
22 | }
23 | @end
--------------------------------------------------------------------------------
/NetworkRequest/SOAP1ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // WebServiceViewController.h
3 | // NetworkRequest
4 | //
5 | // Created by chenyufeng on 15/11/26.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface SOAP1ViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/NetworkRequest/SOAP1ViewController.m:
--------------------------------------------------------------------------------
1 |
2 | //
3 | // WebServiceViewController.m
4 | // NetworkRequest
5 | //
6 | // Created by chenyufeng on 15/11/26.
7 | // Copyright © 2015年 chenyufengweb. All rights reserved.
8 | //
9 |
10 | #import "SOAP1ViewController.h"
11 |
12 | /**
13 | * SOAP采用的协议是HTTP和XML协议;
14 | WebService只采用HTTP POST传输数据,不使用GET;
15 | 目前WebService的协议主要有SOAP1.1和1.2,两者主要是命名空间不同;还有就是Content-Type不同;
16 |
17 | text/xml 这是基于soap1.1协议。
18 | application/soap+xml 这是基于soap1.2协议。
19 |
20 |
21 | WebService从数据传输格式上作了限定,WebService所使用的数据都是基于XML格式的。目前标准的WebService在数据格式上主要采用SOAP协议。
22 | SOAP协议实际上就是一种基于XML编程规范的文本协议,是运行在HTTP协议基础上的协议。其实就在HTTP协议传输XML文件,就变成了SOAP协议。
23 |
24 |
25 | Soap1.1的命名空间:
26 | xmlns:soap=“http://schemas.xmlsoap.org/soap/envelope/ “
27 |
28 | Soap1.2 命名空间:
29 | xmlns:soap="http://www.w3.org/2003/05/soap-envelope“
30 |
31 |
32 | SOAP包括四部分:
33 | (1)SOAP封装(envelop):封装定义了一个描述消息中的内容是什么,是谁发送的,谁应当接受并处理它以及如何处理它们的框架;
34 | (2)SOAP编码规则(encoding rules):用于表示应用程序需要使用的数据类型的实例;
35 | (3)SOAP RPC表示(RPC representation):表示远程过程调用和应答的协定;
36 | (4)SOAP绑定(binding):使用底层协议交换信息。
37 |
38 | SOAP=RPC+HTTP+XML:SOAP使用HTTP传送XML,
39 | 采用HTTP作为底层通讯协议;
40 | RPC作为一致性的调用途径;
41 | XML作为数据传送的格式;
42 |
43 | 客户端发送请求时,不管客户端是什么平台的,首先把请求转换成XML格式,SOAP网关可自动执行这个转换。
44 |
45 | SOAP1.2没有SOAPAction且类型为soap+xml;
46 |
47 | SOAP11客户端可以请求SOAP11和SOAP12服务器;
48 | SOAP12客户端只能请求SOAP12服务器;
49 |
50 |
51 | RPC:远程过程调用协议。
52 | */
53 | @interface SOAP1ViewController ()
54 |
55 | @property (strong, nonatomic) NSMutableData *webData;
56 | @property (strong, nonatomic) NSURLConnection *conn;
57 |
58 | @end
59 |
60 | @implementation SOAP1ViewController
61 |
62 | - (void)viewDidLoad {
63 |
64 | [super viewDidLoad];
65 | [self query:@"18888888888"];
66 | }
67 |
68 | -(void)query:(NSString*)phoneNumber{
69 | // 创建SOAP消息,内容格式就是网站上提示的请求报文的主体实体部分 这里使用了SOAP1.2;
70 | NSString *soapMsg = [NSString stringWithFormat:
71 | @""
72 | ""
76 | ""
77 | ""
78 | "%@"
79 | "%@"
80 | ""
81 | ""
82 | "", phoneNumber, @""];
83 |
84 | NSURL *url = [NSURL URLWithString: @"http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx"];
85 | NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
86 | NSString *msgLength = [NSString stringWithFormat:@"%lu", (unsigned long)[soapMsg length]];
87 | [req addValue:@"application/soap+xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
88 | [req addValue:msgLength forHTTPHeaderField:@"Content-Length"];
89 | [req setHTTPMethod:@"POST"];
90 | [req setHTTPBody: [soapMsg dataUsingEncoding:NSUTF8StringEncoding]];
91 | self.conn = [[NSURLConnection alloc] initWithRequest:req delegate:self];
92 | self.webData = [[NSMutableData alloc] init];
93 | }
94 |
95 | // 刚开始接受响应时调用,所有接收的数据通过NSMutableData来接收;
96 | -(void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *) response{
97 |
98 | [self.webData setLength: 0];
99 | }
100 |
101 | // 每接收到一部分数据就追加到webData中
102 | -(void) connection:(NSURLConnection *)connection didReceiveData:(NSData *) data {
103 |
104 | if(data != nil){
105 | [self.webData appendData:data];
106 | }
107 | }
108 |
109 | // 出现错误时,全部置空;
110 | -(void) connection:(NSURLConnection *)connection didFailWithError:(NSError *) error {
111 |
112 | self.conn = nil;
113 | self.webData = nil;
114 | }
115 |
116 | // 完成接收数据时调用
117 | -(void) connectionDidFinishLoading:(NSURLConnection *) connection {
118 |
119 | NSString *xml = [[NSString alloc] initWithData:self.webData encoding:NSUTF8StringEncoding];
120 | // 打印出得到的XML
121 | NSLog(@"返回的数据:%@", xml);
122 | }
123 | @end
--------------------------------------------------------------------------------
/NetworkRequest/SOAP2ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // SOAP2ViewController.h
3 | // NetworkRequest
4 | //
5 | // Created by chenyufeng on 15/11/27.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface SOAP2ViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/NetworkRequest/SOAP2ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // SOAP2ViewController.m
3 | // NetworkRequest
4 | //
5 | // Created by chenyufeng on 15/11/27.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import "SOAP2ViewController.h"
10 |
11 | @interface SOAP2ViewController ()
12 |
13 | @property (strong, nonatomic) NSMutableData *webData;
14 | @property (strong, nonatomic) NSURLConnection *conn;
15 |
16 | @end
17 |
18 | @implementation SOAP2ViewController
19 |
20 | - (void)viewDidLoad {
21 |
22 | [super viewDidLoad];
23 | [self query:@"18888888888"];
24 | }
25 |
26 | -(void)query:(NSString*)phoneNumber{
27 | // 设置我们之后解析XML时用的关键字,与响应报文中Body标签之间的getMobileCodeInfoResult标签对应
28 | // 创建SOAP消息,内容格式就是网站上提示的请求报文的主体实体部分 这里使用了SOAP1.2;
29 | NSString *soapMsg = [NSString stringWithFormat:
30 | @""
31 | ""
35 | ""
36 | ""
37 | "%@"
38 | "%@"
39 | ""
40 | ""
41 | "", phoneNumber, @""];
42 | // 创建URL,内容是前面的请求报文报文中第二行主机地址加上第一行URL字段
43 | NSURL *url = [NSURL URLWithString: @"http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx"];
44 | NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
45 | NSString *msgLength = [NSString stringWithFormat:@"%lu", (unsigned long)[soapMsg length]];
46 | [req addValue:@"application/soap+xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
47 | [req addValue:msgLength forHTTPHeaderField:@"Content-Length"];
48 | [req setHTTPMethod:@"POST"];
49 | [req setHTTPBody: [soapMsg dataUsingEncoding:NSUTF8StringEncoding]];
50 | /**
51 | 这里区别于第一种方法,使用的是block的方式;
52 | - returns: <#return value description#>
53 | */
54 | [NSURLConnection sendAsynchronousRequest:req queue:[[NSOperationQueue alloc] init] completionHandler:^(NSURLResponse * _Nullable response, NSData * _Nullable data, NSError * _Nullable connectionError) {
55 | if (!connectionError) {
56 |
57 | NSString *result = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
58 | NSLog(@"成功:%@",result);
59 | }else{
60 |
61 | NSLog(@"失败:%@",connectionError);
62 | }
63 | }];
64 | }
65 |
66 | @end
67 |
--------------------------------------------------------------------------------
/NetworkRequest/SOAP3ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // SOAP3ViewController.h
3 | // NetworkRequest
4 | //
5 | // Created by chenyufeng on 15/11/27.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface SOAP3ViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/NetworkRequest/SOAP3ViewController.m:
--------------------------------------------------------------------------------
1 |
2 | //
3 | // SOAP3ViewController.m
4 | // NetworkRequest
5 | //
6 | // Created by chenyufeng on 15/11/27.
7 | // Copyright © 2015年 chenyufengweb. All rights reserved.
8 | //
9 |
10 | #import "SOAP3ViewController.h"
11 |
12 | @interface SOAP3ViewController ()
13 |
14 | @property (strong, nonatomic) NSMutableData *webData;
15 | @property (strong, nonatomic) NSURLConnection *conn;
16 |
17 | @end
18 |
19 | @implementation SOAP3ViewController
20 |
21 | - (void)viewDidLoad {
22 |
23 | [super viewDidLoad];
24 | [self query:@"18888888888"];
25 | }
26 |
27 | -(void)query:(NSString*)phoneNumber{
28 | // 设置我们之后解析XML时用的关键字,与响应报文中Body标签之间的getMobileCodeInfoResult标签对应
29 | // 创建SOAP消息,内容格式就是网站上提示的请求报文的主体实体部分 这里使用了SOAP1.2;
30 | NSString *soapMsg = [NSString stringWithFormat:
31 | @""
32 | ""
36 | ""
37 | ""
38 | "%@"
39 | "%@"
40 | ""
41 | ""
42 | "", phoneNumber, @""];
43 | NSURL *url = [NSURL URLWithString: @"http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx"];
44 | NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
45 | NSString *msgLength = [NSString stringWithFormat:@"%lu", (unsigned long)[soapMsg length]];
46 | [req addValue:@"application/soap+xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
47 | [req addValue:msgLength forHTTPHeaderField:@"Content-Length"];
48 | [req setHTTPMethod:@"POST"];
49 | [req setHTTPBody: [soapMsg dataUsingEncoding:NSUTF8StringEncoding]];
50 |
51 | NSURLSession *session = [NSURLSession sharedSession];
52 | NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:req completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
53 | if (!error) {
54 |
55 | NSString *result = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
56 | NSLog(@"成功:%@",result);
57 | }else{
58 |
59 | NSLog(@"失败 : %@",error);
60 | }
61 | }];
62 | [dataTask resume];
63 | }
64 |
65 | @end
66 |
--------------------------------------------------------------------------------
/NetworkRequest/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // NetworkRequest
4 | //
5 | // Created by chenyufeng on 15/11/26.
6 | // Copyright © 2015年 chenyufengweb. 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 |
--------------------------------------------------------------------------------
/NetworkRequestTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/NetworkRequestTests/NetworkRequestTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // NetworkRequestTests.m
3 | // NetworkRequestTests
4 | //
5 | // Created by chenyufeng on 15/11/26.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NetworkRequestTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation NetworkRequestTests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 | // Put setup code here. This method is called before the invocation of each test method in the class.
20 | }
21 |
22 | - (void)tearDown {
23 | // Put teardown code here. This method is called after the invocation of each test method in the class.
24 | [super tearDown];
25 | }
26 |
27 | - (void)testExample {
28 | // This is an example of a functional test case.
29 | // Use XCTAssert and related functions to verify your tests produce the correct results.
30 | }
31 |
32 | - (void)testPerformanceExample {
33 | // This is an example of a performance test case.
34 | [self measureBlock:^{
35 | // Put the code you want to measure the time of here.
36 | }];
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/NetworkRequestUITests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/NetworkRequestUITests/NetworkRequestUITests.m:
--------------------------------------------------------------------------------
1 | //
2 | // NetworkRequestUITests.m
3 | // NetworkRequestUITests
4 | //
5 | // Created by chenyufeng on 15/11/26.
6 | // Copyright © 2015年 chenyufengweb. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NetworkRequestUITests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation NetworkRequestUITests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 |
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 |
22 | // In UI tests it is usually best to stop immediately when a failure occurs.
23 | self.continueAfterFailure = NO;
24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
25 | [[[XCUIApplication alloc] init] launch];
26 |
27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
28 | }
29 |
30 | - (void)tearDown {
31 | // Put teardown code here. This method is called after the invocation of each test method in the class.
32 | [super tearDown];
33 | }
34 |
35 | - (void)testExample {
36 | // Use recording to get started writing UI tests.
37 | // Use XCTAssert and related functions to verify your tests produce the correct results.
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/Podfile:
--------------------------------------------------------------------------------
1 | platform :ios,'8.0'
2 | pod 'AFNetworking','~> 2.6.3'
3 |
--------------------------------------------------------------------------------
/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - AFNetworking (2.6.3):
3 | - AFNetworking/NSURLConnection (= 2.6.3)
4 | - AFNetworking/NSURLSession (= 2.6.3)
5 | - AFNetworking/Reachability (= 2.6.3)
6 | - AFNetworking/Security (= 2.6.3)
7 | - AFNetworking/Serialization (= 2.6.3)
8 | - AFNetworking/UIKit (= 2.6.3)
9 | - AFNetworking/NSURLConnection (2.6.3):
10 | - AFNetworking/Reachability
11 | - AFNetworking/Security
12 | - AFNetworking/Serialization
13 | - AFNetworking/NSURLSession (2.6.3):
14 | - AFNetworking/Reachability
15 | - AFNetworking/Security
16 | - AFNetworking/Serialization
17 | - AFNetworking/Reachability (2.6.3)
18 | - AFNetworking/Security (2.6.3)
19 | - AFNetworking/Serialization (2.6.3)
20 | - AFNetworking/UIKit (2.6.3):
21 | - AFNetworking/NSURLConnection
22 | - AFNetworking/NSURLSession
23 |
24 | DEPENDENCIES:
25 | - AFNetworking (~> 2.6.3)
26 |
27 | SPEC CHECKSUMS:
28 | AFNetworking: cb8d14a848e831097108418f5d49217339d4eb60
29 |
30 | COCOAPODS: 0.39.0
31 |
--------------------------------------------------------------------------------
/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.h:
--------------------------------------------------------------------------------
1 | // AFHTTPRequestOperation.h
2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 | #import "AFURLConnectionOperation.h"
24 |
25 | NS_ASSUME_NONNULL_BEGIN
26 |
27 | /**
28 | `AFHTTPRequestOperation` is a subclass of `AFURLConnectionOperation` for requests using the HTTP or HTTPS protocols. It encapsulates the concept of acceptable status codes and content types, which determine the success or failure of a request.
29 | */
30 | @interface AFHTTPRequestOperation : AFURLConnectionOperation
31 |
32 | ///------------------------------------------------
33 | /// @name Getting HTTP URL Connection Information
34 | ///------------------------------------------------
35 |
36 | /**
37 | The last HTTP response received by the operation's connection.
38 | */
39 | @property (readonly, nonatomic, strong, nullable) NSHTTPURLResponse *response;
40 |
41 | /**
42 | Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an AFHTTPResponse serializer, which uses the raw data as its response object. The serializer validates the status code to be in the `2XX` range, denoting success. If the response serializer generates an error in `-responseObjectForResponse:data:error:`, the `failure` callback of the session task or request operation will be executed; otherwise, the `success` callback will be executed.
43 |
44 | @warning `responseSerializer` must not be `nil`. Setting a response serializer will clear out any cached value
45 | */
46 | @property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer;
47 |
48 | /**
49 | An object constructed by the `responseSerializer` from the response and response data. Returns `nil` unless the operation `isFinished`, has a `response`, and has `responseData` with non-zero content length. If an error occurs during serialization, `nil` will be returned, and the `error` property will be populated with the serialization error.
50 | */
51 | @property (readonly, nonatomic, strong, nullable) id responseObject;
52 |
53 | ///-----------------------------------------------------------
54 | /// @name Setting Completion Block Success / Failure Callbacks
55 | ///-----------------------------------------------------------
56 |
57 | /**
58 | Sets the `completionBlock` property with a block that executes either the specified success or failure block, depending on the state of the request on completion. If `error` returns a value, which can be caused by an unacceptable status code or content type, then `failure` is executed. Otherwise, `success` is executed.
59 |
60 | This method should be overridden in subclasses in order to specify the response object passed into the success block.
61 |
62 | @param success The block to be executed on the completion of a successful request. This block has no return value and takes two arguments: the receiver operation and the object constructed from the response data of the request.
63 | @param failure The block to be executed on the completion of an unsuccessful request. This block has no return value and takes two arguments: the receiver operation and the error that occurred during the request.
64 | */
65 | - (void)setCompletionBlockWithSuccess:(nullable void (^)(AFHTTPRequestOperation *operation, id responseObject))success
66 | failure:(nullable void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
67 |
68 | @end
69 |
70 | NS_ASSUME_NONNULL_END
71 |
--------------------------------------------------------------------------------
/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.m:
--------------------------------------------------------------------------------
1 | // AFHTTPRequestOperation.m
2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import "AFHTTPRequestOperation.h"
23 |
24 | static dispatch_queue_t http_request_operation_processing_queue() {
25 | static dispatch_queue_t af_http_request_operation_processing_queue;
26 | static dispatch_once_t onceToken;
27 | dispatch_once(&onceToken, ^{
28 | af_http_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.http-request.processing", DISPATCH_QUEUE_CONCURRENT);
29 | });
30 |
31 | return af_http_request_operation_processing_queue;
32 | }
33 |
34 | static dispatch_group_t http_request_operation_completion_group() {
35 | static dispatch_group_t af_http_request_operation_completion_group;
36 | static dispatch_once_t onceToken;
37 | dispatch_once(&onceToken, ^{
38 | af_http_request_operation_completion_group = dispatch_group_create();
39 | });
40 |
41 | return af_http_request_operation_completion_group;
42 | }
43 |
44 | #pragma mark -
45 |
46 | @interface AFURLConnectionOperation ()
47 | @property (readwrite, nonatomic, strong) NSURLRequest *request;
48 | @property (readwrite, nonatomic, strong) NSURLResponse *response;
49 | @end
50 |
51 | @interface AFHTTPRequestOperation ()
52 | @property (readwrite, nonatomic, strong) NSHTTPURLResponse *response;
53 | @property (readwrite, nonatomic, strong) id responseObject;
54 | @property (readwrite, nonatomic, strong) NSError *responseSerializationError;
55 | @property (readwrite, nonatomic, strong) NSRecursiveLock *lock;
56 | @end
57 |
58 | @implementation AFHTTPRequestOperation
59 | @dynamic response;
60 | @dynamic lock;
61 |
62 | - (instancetype)initWithRequest:(NSURLRequest *)urlRequest {
63 | self = [super initWithRequest:urlRequest];
64 | if (!self) {
65 | return nil;
66 | }
67 |
68 | self.responseSerializer = [AFHTTPResponseSerializer serializer];
69 |
70 | return self;
71 | }
72 |
73 | - (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer {
74 | NSParameterAssert(responseSerializer);
75 |
76 | [self.lock lock];
77 | _responseSerializer = responseSerializer;
78 | self.responseObject = nil;
79 | self.responseSerializationError = nil;
80 | [self.lock unlock];
81 | }
82 |
83 | - (id)responseObject {
84 | [self.lock lock];
85 | if (!_responseObject && [self isFinished] && !self.error) {
86 | NSError *error = nil;
87 | self.responseObject = [self.responseSerializer responseObjectForResponse:self.response data:self.responseData error:&error];
88 | if (error) {
89 | self.responseSerializationError = error;
90 | }
91 | }
92 | [self.lock unlock];
93 |
94 | return _responseObject;
95 | }
96 |
97 | - (NSError *)error {
98 | if (_responseSerializationError) {
99 | return _responseSerializationError;
100 | } else {
101 | return [super error];
102 | }
103 | }
104 |
105 | #pragma mark - AFHTTPRequestOperation
106 |
107 | - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
108 | failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
109 | {
110 | // completionBlock is manually nilled out in AFURLConnectionOperation to break the retain cycle.
111 | #pragma clang diagnostic push
112 | #pragma clang diagnostic ignored "-Warc-retain-cycles"
113 | #pragma clang diagnostic ignored "-Wgnu"
114 | self.completionBlock = ^{
115 | if (self.completionGroup) {
116 | dispatch_group_enter(self.completionGroup);
117 | }
118 |
119 | dispatch_async(http_request_operation_processing_queue(), ^{
120 | if (self.error) {
121 | if (failure) {
122 | dispatch_group_async(self.completionGroup ?: http_request_operation_completion_group(), self.completionQueue ?: dispatch_get_main_queue(), ^{
123 | failure(self, self.error);
124 | });
125 | }
126 | } else {
127 | id responseObject = self.responseObject;
128 | if (self.error) {
129 | if (failure) {
130 | dispatch_group_async(self.completionGroup ?: http_request_operation_completion_group(), self.completionQueue ?: dispatch_get_main_queue(), ^{
131 | failure(self, self.error);
132 | });
133 | }
134 | } else {
135 | if (success) {
136 | dispatch_group_async(self.completionGroup ?: http_request_operation_completion_group(), self.completionQueue ?: dispatch_get_main_queue(), ^{
137 | success(self, responseObject);
138 | });
139 | }
140 | }
141 | }
142 |
143 | if (self.completionGroup) {
144 | dispatch_group_leave(self.completionGroup);
145 | }
146 | });
147 | };
148 | #pragma clang diagnostic pop
149 | }
150 |
151 | #pragma mark - AFURLRequestOperation
152 |
153 | - (void)pause {
154 | [super pause];
155 |
156 | u_int64_t offset = 0;
157 | if ([self.outputStream propertyForKey:NSStreamFileCurrentOffsetKey]) {
158 | offset = [(NSNumber *)[self.outputStream propertyForKey:NSStreamFileCurrentOffsetKey] unsignedLongLongValue];
159 | } else {
160 | offset = [(NSData *)[self.outputStream propertyForKey:NSStreamDataWrittenToMemoryStreamKey] length];
161 | }
162 |
163 | NSMutableURLRequest *mutableURLRequest = [self.request mutableCopy];
164 | if ([self.response respondsToSelector:@selector(allHeaderFields)] && [[self.response allHeaderFields] valueForKey:@"ETag"]) {
165 | [mutableURLRequest setValue:[[self.response allHeaderFields] valueForKey:@"ETag"] forHTTPHeaderField:@"If-Range"];
166 | }
167 | [mutableURLRequest setValue:[NSString stringWithFormat:@"bytes=%llu-", offset] forHTTPHeaderField:@"Range"];
168 | self.request = mutableURLRequest;
169 | }
170 |
171 | #pragma mark - NSSecureCoding
172 |
173 | + (BOOL)supportsSecureCoding {
174 | return YES;
175 | }
176 |
177 | - (id)initWithCoder:(NSCoder *)decoder {
178 | self = [super initWithCoder:decoder];
179 | if (!self) {
180 | return nil;
181 | }
182 |
183 | self.responseSerializer = [decoder decodeObjectOfClass:[AFHTTPResponseSerializer class] forKey:NSStringFromSelector(@selector(responseSerializer))];
184 |
185 | return self;
186 | }
187 |
188 | - (void)encodeWithCoder:(NSCoder *)coder {
189 | [super encodeWithCoder:coder];
190 |
191 | [coder encodeObject:self.responseSerializer forKey:NSStringFromSelector(@selector(responseSerializer))];
192 | }
193 |
194 | #pragma mark - NSCopying
195 |
196 | - (id)copyWithZone:(NSZone *)zone {
197 | AFHTTPRequestOperation *operation = [super copyWithZone:zone];
198 |
199 | operation.responseSerializer = [self.responseSerializer copyWithZone:zone];
200 | operation.completionQueue = self.completionQueue;
201 | operation.completionGroup = self.completionGroup;
202 |
203 | return operation;
204 | }
205 |
206 | @end
207 |
--------------------------------------------------------------------------------
/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.h:
--------------------------------------------------------------------------------
1 | // AFNetworkReachabilityManager.h
2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 |
24 | #if !TARGET_OS_WATCH
25 | #import
26 |
27 | #ifndef NS_DESIGNATED_INITIALIZER
28 | #if __has_attribute(objc_designated_initializer)
29 | #define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
30 | #else
31 | #define NS_DESIGNATED_INITIALIZER
32 | #endif
33 | #endif
34 |
35 | typedef NS_ENUM(NSInteger, AFNetworkReachabilityStatus) {
36 | AFNetworkReachabilityStatusUnknown = -1,
37 | AFNetworkReachabilityStatusNotReachable = 0,
38 | AFNetworkReachabilityStatusReachableViaWWAN = 1,
39 | AFNetworkReachabilityStatusReachableViaWiFi = 2,
40 | };
41 |
42 | NS_ASSUME_NONNULL_BEGIN
43 |
44 | /**
45 | `AFNetworkReachabilityManager` monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces.
46 |
47 | Reachability can be used to determine background information about why a network operation failed, or to trigger a network operation retrying when a connection is established. It should not be used to prevent a user from initiating a network request, as it's possible that an initial request may be required to establish reachability.
48 |
49 | See Apple's Reachability Sample Code (https://developer.apple.com/library/ios/samplecode/reachability/)
50 |
51 | @warning Instances of `AFNetworkReachabilityManager` must be started with `-startMonitoring` before reachability status can be determined.
52 | */
53 | @interface AFNetworkReachabilityManager : NSObject
54 |
55 | /**
56 | The current network reachability status.
57 | */
58 | @property (readonly, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus;
59 |
60 | /**
61 | Whether or not the network is currently reachable.
62 | */
63 | @property (readonly, nonatomic, assign, getter = isReachable) BOOL reachable;
64 |
65 | /**
66 | Whether or not the network is currently reachable via WWAN.
67 | */
68 | @property (readonly, nonatomic, assign, getter = isReachableViaWWAN) BOOL reachableViaWWAN;
69 |
70 | /**
71 | Whether or not the network is currently reachable via WiFi.
72 | */
73 | @property (readonly, nonatomic, assign, getter = isReachableViaWiFi) BOOL reachableViaWiFi;
74 |
75 | ///---------------------
76 | /// @name Initialization
77 | ///---------------------
78 |
79 | /**
80 | Returns the shared network reachability manager.
81 | */
82 | + (instancetype)sharedManager;
83 |
84 | /**
85 | Creates and returns a network reachability manager for the specified domain.
86 |
87 | @param domain The domain used to evaluate network reachability.
88 |
89 | @return An initialized network reachability manager, actively monitoring the specified domain.
90 | */
91 | + (instancetype)managerForDomain:(NSString *)domain;
92 |
93 | /**
94 | Creates and returns a network reachability manager for the socket address.
95 |
96 | @param address The socket address (`sockaddr_in`) used to evaluate network reachability.
97 |
98 | @return An initialized network reachability manager, actively monitoring the specified socket address.
99 | */
100 | + (instancetype)managerForAddress:(const void *)address;
101 |
102 | /**
103 | Initializes an instance of a network reachability manager from the specified reachability object.
104 |
105 | @param reachability The reachability object to monitor.
106 |
107 | @return An initialized network reachability manager, actively monitoring the specified reachability.
108 | */
109 | - (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability NS_DESIGNATED_INITIALIZER;
110 |
111 | ///--------------------------------------------------
112 | /// @name Starting & Stopping Reachability Monitoring
113 | ///--------------------------------------------------
114 |
115 | /**
116 | Starts monitoring for changes in network reachability status.
117 | */
118 | - (void)startMonitoring;
119 |
120 | /**
121 | Stops monitoring for changes in network reachability status.
122 | */
123 | - (void)stopMonitoring;
124 |
125 | ///-------------------------------------------------
126 | /// @name Getting Localized Reachability Description
127 | ///-------------------------------------------------
128 |
129 | /**
130 | Returns a localized string representation of the current network reachability status.
131 | */
132 | - (NSString *)localizedNetworkReachabilityStatusString;
133 |
134 | ///---------------------------------------------------
135 | /// @name Setting Network Reachability Change Callback
136 | ///---------------------------------------------------
137 |
138 | /**
139 | Sets a callback to be executed when the network availability of the `baseURL` host changes.
140 |
141 | @param block A block object to be executed when the network availability of the `baseURL` host changes.. This block has no return value and takes a single argument which represents the various reachability states from the device to the `baseURL`.
142 | */
143 | - (void)setReachabilityStatusChangeBlock:(nullable void (^)(AFNetworkReachabilityStatus status))block;
144 |
145 | @end
146 |
147 | ///----------------
148 | /// @name Constants
149 | ///----------------
150 |
151 | /**
152 | ## Network Reachability
153 |
154 | The following constants are provided by `AFNetworkReachabilityManager` as possible network reachability statuses.
155 |
156 | enum {
157 | AFNetworkReachabilityStatusUnknown,
158 | AFNetworkReachabilityStatusNotReachable,
159 | AFNetworkReachabilityStatusReachableViaWWAN,
160 | AFNetworkReachabilityStatusReachableViaWiFi,
161 | }
162 |
163 | `AFNetworkReachabilityStatusUnknown`
164 | The `baseURL` host reachability is not known.
165 |
166 | `AFNetworkReachabilityStatusNotReachable`
167 | The `baseURL` host cannot be reached.
168 |
169 | `AFNetworkReachabilityStatusReachableViaWWAN`
170 | The `baseURL` host can be reached via a cellular connection, such as EDGE or GPRS.
171 |
172 | `AFNetworkReachabilityStatusReachableViaWiFi`
173 | The `baseURL` host can be reached via a Wi-Fi connection.
174 |
175 | ### Keys for Notification UserInfo Dictionary
176 |
177 | Strings that are used as keys in a `userInfo` dictionary in a network reachability status change notification.
178 |
179 | `AFNetworkingReachabilityNotificationStatusItem`
180 | A key in the userInfo dictionary in a `AFNetworkingReachabilityDidChangeNotification` notification.
181 | The corresponding value is an `NSNumber` object representing the `AFNetworkReachabilityStatus` value for the current reachability status.
182 | */
183 |
184 | ///--------------------
185 | /// @name Notifications
186 | ///--------------------
187 |
188 | /**
189 | Posted when network reachability changes.
190 | This notification assigns no notification object. The `userInfo` dictionary contains an `NSNumber` object under the `AFNetworkingReachabilityNotificationStatusItem` key, representing the `AFNetworkReachabilityStatus` value for the current network reachability.
191 |
192 | @warning In order for network reachability to be monitored, include the `SystemConfiguration` framework in the active target's "Link Binary With Library" build phase, and add `#import ` to the header prefix of the project (`Prefix.pch`).
193 | */
194 | FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityDidChangeNotification;
195 | FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityNotificationStatusItem;
196 |
197 | ///--------------------
198 | /// @name Functions
199 | ///--------------------
200 |
201 | /**
202 | Returns a localized string representation of an `AFNetworkReachabilityStatus` value.
203 | */
204 | FOUNDATION_EXPORT NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status);
205 |
206 | NS_ASSUME_NONNULL_END
207 | #endif
208 |
--------------------------------------------------------------------------------
/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.m:
--------------------------------------------------------------------------------
1 | // AFNetworkReachabilityManager.m
2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import "AFNetworkReachabilityManager.h"
23 | #if !TARGET_OS_WATCH
24 |
25 | #import
26 | #import
27 | #import
28 | #import
29 | #import
30 |
31 | NSString * const AFNetworkingReachabilityDidChangeNotification = @"com.alamofire.networking.reachability.change";
32 | NSString * const AFNetworkingReachabilityNotificationStatusItem = @"AFNetworkingReachabilityNotificationStatusItem";
33 |
34 | typedef void (^AFNetworkReachabilityStatusBlock)(AFNetworkReachabilityStatus status);
35 |
36 | NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status) {
37 | switch (status) {
38 | case AFNetworkReachabilityStatusNotReachable:
39 | return NSLocalizedStringFromTable(@"Not Reachable", @"AFNetworking", nil);
40 | case AFNetworkReachabilityStatusReachableViaWWAN:
41 | return NSLocalizedStringFromTable(@"Reachable via WWAN", @"AFNetworking", nil);
42 | case AFNetworkReachabilityStatusReachableViaWiFi:
43 | return NSLocalizedStringFromTable(@"Reachable via WiFi", @"AFNetworking", nil);
44 | case AFNetworkReachabilityStatusUnknown:
45 | default:
46 | return NSLocalizedStringFromTable(@"Unknown", @"AFNetworking", nil);
47 | }
48 | }
49 |
50 | static AFNetworkReachabilityStatus AFNetworkReachabilityStatusForFlags(SCNetworkReachabilityFlags flags) {
51 | BOOL isReachable = ((flags & kSCNetworkReachabilityFlagsReachable) != 0);
52 | BOOL needsConnection = ((flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0);
53 | BOOL canConnectionAutomatically = (((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0) || ((flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0));
54 | BOOL canConnectWithoutUserInteraction = (canConnectionAutomatically && (flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0);
55 | BOOL isNetworkReachable = (isReachable && (!needsConnection || canConnectWithoutUserInteraction));
56 |
57 | AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusUnknown;
58 | if (isNetworkReachable == NO) {
59 | status = AFNetworkReachabilityStatusNotReachable;
60 | }
61 | #if TARGET_OS_IPHONE
62 | else if ((flags & kSCNetworkReachabilityFlagsIsWWAN) != 0) {
63 | status = AFNetworkReachabilityStatusReachableViaWWAN;
64 | }
65 | #endif
66 | else {
67 | status = AFNetworkReachabilityStatusReachableViaWiFi;
68 | }
69 |
70 | return status;
71 | }
72 |
73 | /**
74 | * Queue a status change notification for the main thread.
75 | *
76 | * This is done to ensure that the notifications are received in the same order
77 | * as they are sent. If notifications are sent directly, it is possible that
78 | * a queued notification (for an earlier status condition) is processed after
79 | * the later update, resulting in the listener being left in the wrong state.
80 | */
81 | static void AFPostReachabilityStatusChange(SCNetworkReachabilityFlags flags, AFNetworkReachabilityStatusBlock block) {
82 | AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusForFlags(flags);
83 | dispatch_async(dispatch_get_main_queue(), ^{
84 | if (block) {
85 | block(status);
86 | }
87 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
88 | NSDictionary *userInfo = @{ AFNetworkingReachabilityNotificationStatusItem: @(status) };
89 | [notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:userInfo];
90 | });
91 | }
92 |
93 | static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNetworkReachabilityFlags flags, void *info) {
94 | AFPostReachabilityStatusChange(flags, (__bridge AFNetworkReachabilityStatusBlock)info);
95 | }
96 |
97 | static const void * AFNetworkReachabilityRetainCallback(const void *info) {
98 | return Block_copy(info);
99 | }
100 |
101 | static void AFNetworkReachabilityReleaseCallback(const void *info) {
102 | if (info) {
103 | Block_release(info);
104 | }
105 | }
106 |
107 | @interface AFNetworkReachabilityManager ()
108 | @property (readwrite, nonatomic, strong) id networkReachability;
109 | @property (readwrite, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus;
110 | @property (readwrite, nonatomic, copy) AFNetworkReachabilityStatusBlock networkReachabilityStatusBlock;
111 | @end
112 |
113 | @implementation AFNetworkReachabilityManager
114 |
115 | + (instancetype)sharedManager {
116 | static AFNetworkReachabilityManager *_sharedManager = nil;
117 | static dispatch_once_t onceToken;
118 | dispatch_once(&onceToken, ^{
119 | struct sockaddr_in address;
120 | bzero(&address, sizeof(address));
121 | address.sin_len = sizeof(address);
122 | address.sin_family = AF_INET;
123 |
124 | _sharedManager = [self managerForAddress:&address];
125 | });
126 |
127 | return _sharedManager;
128 | }
129 |
130 | #ifndef __clang_analyzer__
131 | + (instancetype)managerForDomain:(NSString *)domain {
132 | SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, [domain UTF8String]);
133 |
134 | AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability];
135 |
136 | return manager;
137 | }
138 | #endif
139 |
140 | #ifndef __clang_analyzer__
141 | + (instancetype)managerForAddress:(const void *)address {
142 | SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr *)address);
143 | AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability];
144 |
145 | return manager;
146 | }
147 | #endif
148 |
149 | - (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability {
150 | self = [super init];
151 | if (!self) {
152 | return nil;
153 | }
154 |
155 | self.networkReachability = CFBridgingRelease(reachability);
156 | self.networkReachabilityStatus = AFNetworkReachabilityStatusUnknown;
157 |
158 | return self;
159 | }
160 |
161 | - (instancetype)init NS_UNAVAILABLE
162 | {
163 | return nil;
164 | }
165 |
166 | - (void)dealloc {
167 | [self stopMonitoring];
168 | }
169 |
170 | #pragma mark -
171 |
172 | - (BOOL)isReachable {
173 | return [self isReachableViaWWAN] || [self isReachableViaWiFi];
174 | }
175 |
176 | - (BOOL)isReachableViaWWAN {
177 | return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWWAN;
178 | }
179 |
180 | - (BOOL)isReachableViaWiFi {
181 | return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWiFi;
182 | }
183 |
184 | #pragma mark -
185 |
186 | - (void)startMonitoring {
187 | [self stopMonitoring];
188 |
189 | if (!self.networkReachability) {
190 | return;
191 | }
192 |
193 | __weak __typeof(self)weakSelf = self;
194 | AFNetworkReachabilityStatusBlock callback = ^(AFNetworkReachabilityStatus status) {
195 | __strong __typeof(weakSelf)strongSelf = weakSelf;
196 |
197 | strongSelf.networkReachabilityStatus = status;
198 | if (strongSelf.networkReachabilityStatusBlock) {
199 | strongSelf.networkReachabilityStatusBlock(status);
200 | }
201 |
202 | };
203 |
204 | id networkReachability = self.networkReachability;
205 | SCNetworkReachabilityContext context = {0, (__bridge void *)callback, AFNetworkReachabilityRetainCallback, AFNetworkReachabilityReleaseCallback, NULL};
206 | SCNetworkReachabilitySetCallback((__bridge SCNetworkReachabilityRef)networkReachability, AFNetworkReachabilityCallback, &context);
207 | SCNetworkReachabilityScheduleWithRunLoop((__bridge SCNetworkReachabilityRef)networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes);
208 |
209 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0),^{
210 | SCNetworkReachabilityFlags flags;
211 | if (SCNetworkReachabilityGetFlags((__bridge SCNetworkReachabilityRef)networkReachability, &flags)) {
212 | AFPostReachabilityStatusChange(flags, callback);
213 | }
214 | });
215 | }
216 |
217 | - (void)stopMonitoring {
218 | if (!self.networkReachability) {
219 | return;
220 | }
221 |
222 | SCNetworkReachabilityUnscheduleFromRunLoop((__bridge SCNetworkReachabilityRef)self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes);
223 | }
224 |
225 | #pragma mark -
226 |
227 | - (NSString *)localizedNetworkReachabilityStatusString {
228 | return AFStringFromNetworkReachabilityStatus(self.networkReachabilityStatus);
229 | }
230 |
231 | #pragma mark -
232 |
233 | - (void)setReachabilityStatusChangeBlock:(void (^)(AFNetworkReachabilityStatus status))block {
234 | self.networkReachabilityStatusBlock = block;
235 | }
236 |
237 | #pragma mark - NSKeyValueObserving
238 |
239 | + (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key {
240 | if ([key isEqualToString:@"reachable"] || [key isEqualToString:@"reachableViaWWAN"] || [key isEqualToString:@"reachableViaWiFi"]) {
241 | return [NSSet setWithObject:@"networkReachabilityStatus"];
242 | }
243 |
244 | return [super keyPathsForValuesAffectingValueForKey:key];
245 | }
246 |
247 | @end
248 | #endif
249 |
--------------------------------------------------------------------------------
/Pods/AFNetworking/AFNetworking/AFNetworking.h:
--------------------------------------------------------------------------------
1 | // AFNetworking.h
2 | //
3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.com/)
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import
24 | #import
25 |
26 | #ifndef _AFNETWORKING_
27 | #define _AFNETWORKING_
28 |
29 | #import "AFURLRequestSerialization.h"
30 | #import "AFURLResponseSerialization.h"
31 | #import "AFSecurityPolicy.h"
32 | #if !TARGET_OS_WATCH
33 | #import "AFNetworkReachabilityManager.h"
34 | #import "AFURLConnectionOperation.h"
35 | #import "AFHTTPRequestOperation.h"
36 | #import "AFHTTPRequestOperationManager.h"
37 | #endif
38 |
39 | #if ( ( defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) || \
40 | ( defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 ) || \
41 | TARGET_OS_WATCH )
42 | #import "AFURLSessionManager.h"
43 | #import "AFHTTPSessionManager.h"
44 | #endif
45 |
46 | #endif /* _AFNETWORKING_ */
47 |
--------------------------------------------------------------------------------
/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.h:
--------------------------------------------------------------------------------
1 | // AFSecurityPolicy.h
2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 | #import
24 |
25 | typedef NS_ENUM(NSUInteger, AFSSLPinningMode) {
26 | AFSSLPinningModeNone,
27 | AFSSLPinningModePublicKey,
28 | AFSSLPinningModeCertificate,
29 | };
30 |
31 | /**
32 | `AFSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections.
33 |
34 | Adding pinned SSL certificates to your app helps prevent man-in-the-middle attacks and other vulnerabilities. Applications dealing with sensitive customer data or financial information are strongly encouraged to route all communication over an HTTPS connection with SSL pinning configured and enabled.
35 | */
36 |
37 | NS_ASSUME_NONNULL_BEGIN
38 |
39 | @interface AFSecurityPolicy : NSObject
40 |
41 | /**
42 | The criteria by which server trust should be evaluated against the pinned SSL certificates. Defaults to `AFSSLPinningModeNone`.
43 | */
44 | @property (readonly, nonatomic, assign) AFSSLPinningMode SSLPinningMode;
45 |
46 | /**
47 | The certificates used to evaluate server trust according to the SSL pinning mode. By default, this property is set to any (`.cer`) certificates included in the app bundle. Note that if you create an array with duplicate certificates, the duplicate certificates will be removed. Note that if pinning is enabled, `evaluateServerTrust:forDomain:` will return true if any pinned certificate matches.
48 | */
49 | @property (nonatomic, strong, nullable) NSArray *pinnedCertificates;
50 |
51 | /**
52 | Whether or not to trust servers with an invalid or expired SSL certificates. Defaults to `NO`.
53 | */
54 | @property (nonatomic, assign) BOOL allowInvalidCertificates;
55 |
56 | /**
57 | Whether or not to validate the domain name in the certificate's CN field. Defaults to `YES`.
58 | */
59 | @property (nonatomic, assign) BOOL validatesDomainName;
60 |
61 | ///-----------------------------------------
62 | /// @name Getting Specific Security Policies
63 | ///-----------------------------------------
64 |
65 | /**
66 | Returns the shared default security policy, which does not allow invalid certificates, validates domain name, and does not validate against pinned certificates or public keys.
67 |
68 | @return The default security policy.
69 | */
70 | + (instancetype)defaultPolicy;
71 |
72 | ///---------------------
73 | /// @name Initialization
74 | ///---------------------
75 |
76 | /**
77 | Creates and returns a security policy with the specified pinning mode.
78 |
79 | @param pinningMode The SSL pinning mode.
80 |
81 | @return A new security policy.
82 | */
83 | + (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode;
84 |
85 | ///------------------------------
86 | /// @name Evaluating Server Trust
87 | ///------------------------------
88 |
89 | /**
90 | Whether or not the specified server trust should be accepted, based on the security policy.
91 |
92 | This method should be used when responding to an authentication challenge from a server.
93 |
94 | @param serverTrust The X.509 certificate trust of the server.
95 |
96 | @return Whether or not to trust the server.
97 |
98 | @warning This method has been deprecated in favor of `-evaluateServerTrust:forDomain:`.
99 | */
100 | - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust DEPRECATED_ATTRIBUTE;
101 |
102 | /**
103 | Whether or not the specified server trust should be accepted, based on the security policy.
104 |
105 | This method should be used when responding to an authentication challenge from a server.
106 |
107 | @param serverTrust The X.509 certificate trust of the server.
108 | @param domain The domain of serverTrust. If `nil`, the domain will not be validated.
109 |
110 | @return Whether or not to trust the server.
111 | */
112 | - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust
113 | forDomain:(nullable NSString *)domain;
114 |
115 | @end
116 |
117 | NS_ASSUME_NONNULL_END
118 |
119 | ///----------------
120 | /// @name Constants
121 | ///----------------
122 |
123 | /**
124 | ## SSL Pinning Modes
125 |
126 | The following constants are provided by `AFSSLPinningMode` as possible SSL pinning modes.
127 |
128 | enum {
129 | AFSSLPinningModeNone,
130 | AFSSLPinningModePublicKey,
131 | AFSSLPinningModeCertificate,
132 | }
133 |
134 | `AFSSLPinningModeNone`
135 | Do not used pinned certificates to validate servers.
136 |
137 | `AFSSLPinningModePublicKey`
138 | Validate host certificates against public keys of pinned certificates.
139 |
140 | `AFSSLPinningModeCertificate`
141 | Validate host certificates against pinned certificates.
142 | */
143 |
--------------------------------------------------------------------------------
/Pods/AFNetworking/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h:
--------------------------------------------------------------------------------
1 | // AFNetworkActivityIndicatorManager.h
2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 |
24 | #import
25 |
26 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
27 |
28 | #import
29 |
30 | NS_ASSUME_NONNULL_BEGIN
31 |
32 | /**
33 | `AFNetworkActivityIndicatorManager` manages the state of the network activity indicator in the status bar. When enabled, it will listen for notifications indicating that a network request operation has started or finished, and start or stop animating the indicator accordingly. The number of active requests is incremented and decremented much like a stack or a semaphore, and the activity indicator will animate so long as that number is greater than zero.
34 |
35 | You should enable the shared instance of `AFNetworkActivityIndicatorManager` when your application finishes launching. In `AppDelegate application:didFinishLaunchingWithOptions:` you can do so with the following code:
36 |
37 | [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES];
38 |
39 | By setting `enabled` to `YES` for `sharedManager`, the network activity indicator will show and hide automatically as requests start and finish. You should not ever need to call `incrementActivityCount` or `decrementActivityCount` yourself.
40 |
41 | See the Apple Human Interface Guidelines section about the Network Activity Indicator for more information:
42 | http://developer.apple.com/library/iOS/#documentation/UserExperience/Conceptual/MobileHIG/UIElementGuidelines/UIElementGuidelines.html#//apple_ref/doc/uid/TP40006556-CH13-SW44
43 | */
44 | NS_EXTENSION_UNAVAILABLE_IOS("Use view controller based solutions where appropriate instead.")
45 | @interface AFNetworkActivityIndicatorManager : NSObject
46 |
47 | /**
48 | A Boolean value indicating whether the manager is enabled.
49 |
50 | If YES, the manager will change status bar network activity indicator according to network operation notifications it receives. The default value is NO.
51 | */
52 | @property (nonatomic, assign, getter = isEnabled) BOOL enabled;
53 |
54 | /**
55 | A Boolean value indicating whether the network activity indicator is currently displayed in the status bar.
56 | */
57 | @property (readonly, nonatomic, assign) BOOL isNetworkActivityIndicatorVisible;
58 |
59 | /**
60 | Returns the shared network activity indicator manager object for the system.
61 |
62 | @return The systemwide network activity indicator manager.
63 | */
64 | + (instancetype)sharedManager;
65 |
66 | /**
67 | Increments the number of active network requests. If this number was zero before incrementing, this will start animating the status bar network activity indicator.
68 | */
69 | - (void)incrementActivityCount;
70 |
71 | /**
72 | Decrements the number of active network requests. If this number becomes zero after decrementing, this will stop animating the status bar network activity indicator.
73 | */
74 | - (void)decrementActivityCount;
75 |
76 | @end
77 |
78 | NS_ASSUME_NONNULL_END
79 |
80 | #endif
81 |
--------------------------------------------------------------------------------
/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m:
--------------------------------------------------------------------------------
1 | // AFNetworkActivityIndicatorManager.m
2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import "AFNetworkActivityIndicatorManager.h"
23 |
24 | #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED)
25 |
26 | #import "AFHTTPRequestOperation.h"
27 |
28 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000
29 | #import "AFURLSessionManager.h"
30 | #endif
31 |
32 | static NSTimeInterval const kAFNetworkActivityIndicatorInvisibilityDelay = 0.17;
33 |
34 | static NSURLRequest * AFNetworkRequestFromNotification(NSNotification *notification) {
35 | if ([[notification object] isKindOfClass:[AFURLConnectionOperation class]]) {
36 | return [(AFURLConnectionOperation *)[notification object] request];
37 | }
38 |
39 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000
40 | if ([[notification object] respondsToSelector:@selector(originalRequest)]) {
41 | return [(NSURLSessionTask *)[notification object] originalRequest];
42 | }
43 | #endif
44 |
45 | return nil;
46 | }
47 |
48 | @interface AFNetworkActivityIndicatorManager ()
49 | @property (readwrite, nonatomic, assign) NSInteger activityCount;
50 | @property (readwrite, nonatomic, strong) NSTimer *activityIndicatorVisibilityTimer;
51 | @property (readonly, nonatomic, getter = isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible;
52 |
53 | - (void)updateNetworkActivityIndicatorVisibility;
54 | - (void)updateNetworkActivityIndicatorVisibilityDelayed;
55 | @end
56 |
57 | @implementation AFNetworkActivityIndicatorManager
58 | @dynamic networkActivityIndicatorVisible;
59 |
60 | + (instancetype)sharedManager {
61 | static AFNetworkActivityIndicatorManager *_sharedManager = nil;
62 | static dispatch_once_t oncePredicate;
63 | dispatch_once(&oncePredicate, ^{
64 | _sharedManager = [[self alloc] init];
65 | });
66 |
67 | return _sharedManager;
68 | }
69 |
70 | + (NSSet *)keyPathsForValuesAffectingIsNetworkActivityIndicatorVisible {
71 | return [NSSet setWithObject:@"activityCount"];
72 | }
73 |
74 | - (id)init {
75 | self = [super init];
76 | if (!self) {
77 | return nil;
78 | }
79 |
80 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidStart:) name:AFNetworkingOperationDidStartNotification object:nil];
81 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingOperationDidFinishNotification object:nil];
82 |
83 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000
84 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidStart:) name:AFNetworkingTaskDidResumeNotification object:nil];
85 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingTaskDidSuspendNotification object:nil];
86 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingTaskDidCompleteNotification object:nil];
87 | #endif
88 |
89 | return self;
90 | }
91 |
92 | - (void)dealloc {
93 | [[NSNotificationCenter defaultCenter] removeObserver:self];
94 |
95 | [_activityIndicatorVisibilityTimer invalidate];
96 | }
97 |
98 | - (void)updateNetworkActivityIndicatorVisibilityDelayed {
99 | if (self.enabled) {
100 | // Delay hiding of activity indicator for a short interval, to avoid flickering
101 | if (![self isNetworkActivityIndicatorVisible]) {
102 | [self.activityIndicatorVisibilityTimer invalidate];
103 | self.activityIndicatorVisibilityTimer = [NSTimer timerWithTimeInterval:kAFNetworkActivityIndicatorInvisibilityDelay target:self selector:@selector(updateNetworkActivityIndicatorVisibility) userInfo:nil repeats:NO];
104 | [[NSRunLoop mainRunLoop] addTimer:self.activityIndicatorVisibilityTimer forMode:NSRunLoopCommonModes];
105 | } else {
106 | [self performSelectorOnMainThread:@selector(updateNetworkActivityIndicatorVisibility) withObject:nil waitUntilDone:NO modes:@[NSRunLoopCommonModes]];
107 | }
108 | }
109 | }
110 |
111 | - (BOOL)isNetworkActivityIndicatorVisible {
112 | return self.activityCount > 0;
113 | }
114 |
115 | - (void)updateNetworkActivityIndicatorVisibility {
116 | [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:[self isNetworkActivityIndicatorVisible]];
117 | }
118 |
119 | - (void)setActivityCount:(NSInteger)activityCount {
120 | @synchronized(self) {
121 | _activityCount = activityCount;
122 | }
123 |
124 | dispatch_async(dispatch_get_main_queue(), ^{
125 | [self updateNetworkActivityIndicatorVisibilityDelayed];
126 | });
127 | }
128 |
129 | - (void)incrementActivityCount {
130 | [self willChangeValueForKey:@"activityCount"];
131 | @synchronized(self) {
132 | _activityCount++;
133 | }
134 | [self didChangeValueForKey:@"activityCount"];
135 |
136 | dispatch_async(dispatch_get_main_queue(), ^{
137 | [self updateNetworkActivityIndicatorVisibilityDelayed];
138 | });
139 | }
140 |
141 | - (void)decrementActivityCount {
142 | [self willChangeValueForKey:@"activityCount"];
143 | @synchronized(self) {
144 | #pragma clang diagnostic push
145 | #pragma clang diagnostic ignored "-Wgnu"
146 | _activityCount = MAX(_activityCount - 1, 0);
147 | #pragma clang diagnostic pop
148 | }
149 | [self didChangeValueForKey:@"activityCount"];
150 |
151 | dispatch_async(dispatch_get_main_queue(), ^{
152 | [self updateNetworkActivityIndicatorVisibilityDelayed];
153 | });
154 | }
155 |
156 | - (void)networkRequestDidStart:(NSNotification *)notification {
157 | if ([AFNetworkRequestFromNotification(notification) URL]) {
158 | [self incrementActivityCount];
159 | }
160 | }
161 |
162 | - (void)networkRequestDidFinish:(NSNotification *)notification {
163 | if ([AFNetworkRequestFromNotification(notification) URL]) {
164 | [self decrementActivityCount];
165 | }
166 | }
167 |
168 | @end
169 |
170 | #endif
171 |
--------------------------------------------------------------------------------
/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | // UIActivityIndicatorView+AFNetworking.h
2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 |
24 | #import
25 |
26 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
27 |
28 | #import
29 |
30 | @class AFURLConnectionOperation;
31 |
32 | /**
33 | This category adds methods to the UIKit framework's `UIActivityIndicatorView` class. The methods in this category provide support for automatically starting and stopping animation depending on the loading state of a request operation or session task.
34 | */
35 | @interface UIActivityIndicatorView (AFNetworking)
36 |
37 | ///----------------------------------
38 | /// @name Animating for Session Tasks
39 | ///----------------------------------
40 |
41 | /**
42 | Binds the animating state to the state of the specified task.
43 |
44 | @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled.
45 | */
46 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
47 | - (void)setAnimatingWithStateOfTask:(nullable NSURLSessionTask *)task;
48 | #endif
49 |
50 | ///---------------------------------------
51 | /// @name Animating for Request Operations
52 | ///---------------------------------------
53 |
54 | /**
55 | Binds the animating state to the execution state of the specified operation.
56 |
57 | @param operation The operation. If `nil`, automatic updating from any previously specified operation will be disabled.
58 | */
59 | - (void)setAnimatingWithStateOfOperation:(nullable AFURLConnectionOperation *)operation;
60 |
61 | @end
62 |
63 | #endif
64 |
--------------------------------------------------------------------------------
/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m:
--------------------------------------------------------------------------------
1 | // UIActivityIndicatorView+AFNetworking.m
2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import "UIActivityIndicatorView+AFNetworking.h"
23 | #import
24 |
25 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
26 |
27 | #import "AFHTTPRequestOperation.h"
28 |
29 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
30 | #import "AFURLSessionManager.h"
31 | #endif
32 |
33 | @interface AFActivityIndicatorViewNotificationObserver : NSObject
34 | @property (readonly, nonatomic, weak) UIActivityIndicatorView *activityIndicatorView;
35 | - (instancetype)initWithActivityIndicatorView:(UIActivityIndicatorView *)activityIndicatorView;
36 |
37 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
38 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task;
39 | #endif
40 | - (void)setAnimatingWithStateOfOperation:(AFURLConnectionOperation *)operation;
41 |
42 | @end
43 |
44 | @implementation UIActivityIndicatorView (AFNetworking)
45 |
46 | - (AFActivityIndicatorViewNotificationObserver *)af_notificationObserver {
47 | AFActivityIndicatorViewNotificationObserver *notificationObserver = objc_getAssociatedObject(self, @selector(af_notificationObserver));
48 | if (notificationObserver == nil) {
49 | notificationObserver = [[AFActivityIndicatorViewNotificationObserver alloc] initWithActivityIndicatorView:self];
50 | objc_setAssociatedObject(self, @selector(af_notificationObserver), notificationObserver, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
51 | }
52 | return notificationObserver;
53 | }
54 |
55 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
56 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task {
57 | [[self af_notificationObserver] setAnimatingWithStateOfTask:task];
58 | }
59 | #endif
60 |
61 | - (void)setAnimatingWithStateOfOperation:(AFURLConnectionOperation *)operation {
62 | [[self af_notificationObserver] setAnimatingWithStateOfOperation:operation];
63 | }
64 |
65 | @end
66 |
67 | @implementation AFActivityIndicatorViewNotificationObserver
68 |
69 | - (instancetype)initWithActivityIndicatorView:(UIActivityIndicatorView *)activityIndicatorView
70 | {
71 | self = [super init];
72 | if (self) {
73 | _activityIndicatorView = activityIndicatorView;
74 | }
75 | return self;
76 | }
77 |
78 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
79 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task {
80 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
81 |
82 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil];
83 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil];
84 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil];
85 |
86 | if (task) {
87 | if (task.state != NSURLSessionTaskStateCompleted) {
88 |
89 | #pragma clang diagnostic push
90 | #pragma clang diagnostic ignored "-Wreceiver-is-weak"
91 | #pragma clang diagnostic ignored "-Warc-repeated-use-of-weak"
92 | if (task.state == NSURLSessionTaskStateRunning) {
93 | [self.activityIndicatorView startAnimating];
94 | } else {
95 | [self.activityIndicatorView stopAnimating];
96 | }
97 | #pragma clang diagnostic pop
98 |
99 | [notificationCenter addObserver:self selector:@selector(af_startAnimating) name:AFNetworkingTaskDidResumeNotification object:task];
100 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidCompleteNotification object:task];
101 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidSuspendNotification object:task];
102 | }
103 | }
104 | }
105 | #endif
106 |
107 | #pragma mark -
108 |
109 | - (void)setAnimatingWithStateOfOperation:(AFURLConnectionOperation *)operation {
110 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
111 |
112 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidStartNotification object:nil];
113 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidFinishNotification object:nil];
114 |
115 | if (operation) {
116 | if (![operation isFinished]) {
117 |
118 | #pragma clang diagnostic push
119 | #pragma clang diagnostic ignored "-Wreceiver-is-weak"
120 | #pragma clang diagnostic ignored "-Warc-repeated-use-of-weak"
121 | if ([operation isExecuting]) {
122 | [self.activityIndicatorView startAnimating];
123 | } else {
124 | [self.activityIndicatorView stopAnimating];
125 | }
126 | #pragma clang diagnostic pop
127 |
128 | [notificationCenter addObserver:self selector:@selector(af_startAnimating) name:AFNetworkingOperationDidStartNotification object:operation];
129 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingOperationDidFinishNotification object:operation];
130 | }
131 | }
132 | }
133 |
134 | #pragma mark -
135 |
136 | - (void)af_startAnimating {
137 | dispatch_async(dispatch_get_main_queue(), ^{
138 | #pragma clang diagnostic push
139 | #pragma clang diagnostic ignored "-Wreceiver-is-weak"
140 | [self.activityIndicatorView startAnimating];
141 | #pragma clang diagnostic pop
142 | });
143 | }
144 |
145 | - (void)af_stopAnimating {
146 | dispatch_async(dispatch_get_main_queue(), ^{
147 | #pragma clang diagnostic push
148 | #pragma clang diagnostic ignored "-Wreceiver-is-weak"
149 | [self.activityIndicatorView stopAnimating];
150 | #pragma clang diagnostic pop
151 | });
152 | }
153 |
154 | #pragma mark -
155 |
156 | - (void)dealloc {
157 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
158 |
159 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
160 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil];
161 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil];
162 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil];
163 | #endif
164 |
165 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidStartNotification object:nil];
166 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidFinishNotification object:nil];
167 | }
168 |
169 | @end
170 |
171 | #endif
172 |
--------------------------------------------------------------------------------
/Pods/AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | // UIAlertView+AFNetworking.h
2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 |
24 | #import
25 |
26 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
27 |
28 | #import
29 |
30 | NS_ASSUME_NONNULL_BEGIN
31 |
32 | @class AFURLConnectionOperation;
33 |
34 | /**
35 | This category adds methods to the UIKit framework's `UIAlertView` class. The methods in this category provide support for automatically showing an alert if a session task or request operation finishes with an error. Alert title and message are filled from the corresponding `localizedDescription` & `localizedRecoverySuggestion` or `localizedFailureReason` of the error.
36 | */
37 | @interface UIAlertView (AFNetworking)
38 |
39 | ///-------------------------------------
40 | /// @name Showing Alert for Session Task
41 | ///-------------------------------------
42 |
43 | /**
44 | Shows an alert view with the error of the specified session task, if any.
45 |
46 | @param task The session task.
47 | @param delegate The alert view delegate.
48 | */
49 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
50 | + (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task
51 | delegate:(nullable id)delegate NS_EXTENSION_UNAVAILABLE_IOS("Not available in app extensions.");
52 | #endif
53 |
54 | /**
55 | Shows an alert view with the error of the specified session task, if any, with a custom cancel button title and other button titles.
56 |
57 | @param task The session task.
58 | @param delegate The alert view delegate.
59 | @param cancelButtonTitle The title of the cancel button or nil if there is no cancel button. Using this argument is equivalent to setting the cancel button index to the value returned by invoking addButtonWithTitle: specifying this title.
60 | @param otherButtonTitles The title of another button. Using this argument is equivalent to invoking addButtonWithTitle: with this title to add more buttons. Too many buttons can cause the alert view to scroll. For guidelines on the best ways to use an alert in an app, see "Temporary Views". Titles of additional buttons to add to the receiver, terminated with `nil`.
61 | */
62 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
63 | + (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task
64 | delegate:(nullable id)delegate
65 | cancelButtonTitle:(nullable NSString *)cancelButtonTitle
66 | otherButtonTitles:(nullable NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION NS_EXTENSION_UNAVAILABLE_IOS("Not available in app extensions.");
67 | #endif
68 |
69 | ///------------------------------------------
70 | /// @name Showing Alert for Request Operation
71 | ///------------------------------------------
72 |
73 | /**
74 | Shows an alert view with the error of the specified request operation, if any.
75 |
76 | @param operation The request operation.
77 | @param delegate The alert view delegate.
78 | */
79 | + (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation
80 | delegate:(nullable id)delegate NS_EXTENSION_UNAVAILABLE_IOS("Not available in app extensions.");
81 |
82 | /**
83 | Shows an alert view with the error of the specified request operation, if any, with a custom cancel button title and other button titles.
84 |
85 | @param operation The request operation.
86 | @param delegate The alert view delegate.
87 | @param cancelButtonTitle The title of the cancel button or nil if there is no cancel button. Using this argument is equivalent to setting the cancel button index to the value returned by invoking addButtonWithTitle: specifying this title.
88 | @param otherButtonTitles The title of another button. Using this argument is equivalent to invoking addButtonWithTitle: with this title to add more buttons. Too many buttons can cause the alert view to scroll. For guidelines on the best ways to use an alert in an app, see "Temporary Views". Titles of additional buttons to add to the receiver, terminated with `nil`.
89 | */
90 | + (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation
91 | delegate:(nullable id)delegate
92 | cancelButtonTitle:(nullable NSString *)cancelButtonTitle
93 | otherButtonTitles:(nullable NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION NS_EXTENSION_UNAVAILABLE_IOS("Not available in app extensions.");
94 |
95 | @end
96 |
97 | NS_ASSUME_NONNULL_END
98 |
99 | #endif
100 |
--------------------------------------------------------------------------------
/Pods/AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.m:
--------------------------------------------------------------------------------
1 | // UIAlertView+AFNetworking.m
2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import "UIAlertView+AFNetworking.h"
23 |
24 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
25 |
26 | #import "AFURLConnectionOperation.h"
27 |
28 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
29 | #import "AFURLSessionManager.h"
30 | #endif
31 |
32 | static void AFGetAlertViewTitleAndMessageFromError(NSError *error, NSString * __autoreleasing *title, NSString * __autoreleasing *message) {
33 | if (error.localizedDescription && (error.localizedRecoverySuggestion || error.localizedFailureReason)) {
34 | *title = error.localizedDescription;
35 |
36 | if (error.localizedRecoverySuggestion) {
37 | *message = error.localizedRecoverySuggestion;
38 | } else {
39 | *message = error.localizedFailureReason;
40 | }
41 | } else if (error.localizedDescription) {
42 | *title = NSLocalizedStringFromTable(@"Error", @"AFNetworking", @"Fallback Error Description");
43 | *message = error.localizedDescription;
44 | } else {
45 | *title = NSLocalizedStringFromTable(@"Error", @"AFNetworking", @"Fallback Error Description");
46 | *message = [NSString stringWithFormat:NSLocalizedStringFromTable(@"%@ Error: %ld", @"AFNetworking", @"Fallback Error Failure Reason Format"), error.domain, (long)error.code];
47 | }
48 | }
49 |
50 | @implementation UIAlertView (AFNetworking)
51 |
52 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
53 | + (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task
54 | delegate:(id)delegate
55 | {
56 | [self showAlertViewForTaskWithErrorOnCompletion:task delegate:delegate cancelButtonTitle:NSLocalizedStringFromTable(@"Dismiss", @"AFNetworking", @"UIAlertView Cancel Button Title") otherButtonTitles:nil, nil];
57 | }
58 |
59 | + (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task
60 | delegate:(id)delegate
61 | cancelButtonTitle:(NSString *)cancelButtonTitle
62 | otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION
63 | {
64 | NSMutableArray *mutableOtherTitles = [NSMutableArray array];
65 | va_list otherButtonTitleList;
66 | va_start(otherButtonTitleList, otherButtonTitles);
67 | {
68 | for (NSString *otherButtonTitle = otherButtonTitles; otherButtonTitle != nil; otherButtonTitle = va_arg(otherButtonTitleList, NSString *)) {
69 | [mutableOtherTitles addObject:otherButtonTitle];
70 | }
71 | }
72 | va_end(otherButtonTitleList);
73 |
74 | __block __weak id observer = [[NSNotificationCenter defaultCenter] addObserverForName:AFNetworkingTaskDidCompleteNotification object:task queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) {
75 | NSError *error = notification.userInfo[AFNetworkingTaskDidCompleteErrorKey];
76 | if (error) {
77 | NSString *title, *message;
78 | AFGetAlertViewTitleAndMessageFromError(error, &title, &message);
79 |
80 | UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:delegate cancelButtonTitle:cancelButtonTitle otherButtonTitles:nil, nil];
81 | for (NSString *otherButtonTitle in mutableOtherTitles) {
82 | [alertView addButtonWithTitle:otherButtonTitle];
83 | }
84 | [alertView setTitle:title];
85 | [alertView setMessage:message];
86 | [alertView show];
87 | }
88 |
89 | [[NSNotificationCenter defaultCenter] removeObserver:observer];
90 | }];
91 | }
92 | #endif
93 |
94 | #pragma mark -
95 |
96 | + (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation
97 | delegate:(id)delegate
98 | {
99 | [self showAlertViewForRequestOperationWithErrorOnCompletion:operation delegate:delegate cancelButtonTitle:NSLocalizedStringFromTable(@"Dismiss", @"AFNetworking", @"UIAlertView Cancel Button Title") otherButtonTitles:nil, nil];
100 | }
101 |
102 | + (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation
103 | delegate:(id)delegate
104 | cancelButtonTitle:(NSString *)cancelButtonTitle
105 | otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION
106 | {
107 | NSMutableArray *mutableOtherTitles = [NSMutableArray array];
108 | va_list otherButtonTitleList;
109 | va_start(otherButtonTitleList, otherButtonTitles);
110 | {
111 | for (NSString *otherButtonTitle = otherButtonTitles; otherButtonTitle != nil; otherButtonTitle = va_arg(otherButtonTitleList, NSString *)) {
112 | [mutableOtherTitles addObject:otherButtonTitle];
113 | }
114 | }
115 | va_end(otherButtonTitleList);
116 |
117 | __block __weak id observer = [[NSNotificationCenter defaultCenter] addObserverForName:AFNetworkingOperationDidFinishNotification object:operation queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) {
118 |
119 | if (notification.object && [notification.object isKindOfClass:[AFURLConnectionOperation class]]) {
120 | NSError *error = [(AFURLConnectionOperation *)notification.object error];
121 | if (error) {
122 | NSString *title, *message;
123 | AFGetAlertViewTitleAndMessageFromError(error, &title, &message);
124 |
125 | UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:delegate cancelButtonTitle:cancelButtonTitle otherButtonTitles:nil, nil];
126 | for (NSString *otherButtonTitle in mutableOtherTitles) {
127 | [alertView addButtonWithTitle:otherButtonTitle];
128 | }
129 | [alertView setTitle:title];
130 | [alertView setMessage:message];
131 | [alertView show];
132 | }
133 | }
134 |
135 | [[NSNotificationCenter defaultCenter] removeObserver:observer];
136 | }];
137 | }
138 |
139 | @end
140 |
141 | #endif
142 |
--------------------------------------------------------------------------------
/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h:
--------------------------------------------------------------------------------
1 | // UIButton+AFNetworking.h
2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 |
24 | #import
25 |
26 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
27 |
28 | #import
29 |
30 | NS_ASSUME_NONNULL_BEGIN
31 |
32 | @protocol AFURLResponseSerialization, AFImageCache;
33 |
34 | /**
35 | This category adds methods to the UIKit framework's `UIButton` class. The methods in this category provide support for loading remote images and background images asynchronously from a URL.
36 |
37 | @warning Compound values for control `state` (such as `UIControlStateHighlighted | UIControlStateDisabled`) are unsupported.
38 | */
39 | @interface UIButton (AFNetworking)
40 |
41 | ///----------------------------
42 | /// @name Accessing Image Cache
43 | ///----------------------------
44 |
45 | /**
46 | The image cache used to improve image loading performance on scroll views. By default, `UIButton` will use the `sharedImageCache` of `UIImageView`.
47 | */
48 | + (id )sharedImageCache;
49 |
50 | /**
51 | Set the cache used for image loading.
52 |
53 | @param imageCache The image cache.
54 | */
55 | + (void)setSharedImageCache:(__nullable id )imageCache;
56 |
57 | ///------------------------------------
58 | /// @name Accessing Response Serializer
59 | ///------------------------------------
60 |
61 | /**
62 | The response serializer used to create an image representation from the server response and response data. By default, this is an instance of `AFImageResponseSerializer`.
63 |
64 | @discussion Subclasses of `AFImageResponseSerializer` could be used to perform post-processing, such as color correction, face detection, or other effects. See https://github.com/AFNetworking/AFCoreImageSerializer
65 | */
66 | @property (nonatomic, strong) id imageResponseSerializer;
67 |
68 | ///--------------------
69 | /// @name Setting Image
70 | ///--------------------
71 |
72 | /**
73 | Asynchronously downloads an image from the specified URL, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled.
74 |
75 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
76 |
77 | @param state The control state.
78 | @param url The URL used for the image request.
79 | */
80 | - (void)setImageForState:(UIControlState)state
81 | withURL:(NSURL *)url;
82 |
83 | /**
84 | Asynchronously downloads an image from the specified URL, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled.
85 |
86 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
87 |
88 | @param state The control state.
89 | @param url The URL used for the image request.
90 | @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the button will not change its image until the image request finishes.
91 | */
92 | - (void)setImageForState:(UIControlState)state
93 | withURL:(NSURL *)url
94 | placeholderImage:(nullable UIImage *)placeholderImage;
95 |
96 | /**
97 | Asynchronously downloads an image from the specified URL request, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled.
98 |
99 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
100 |
101 | If a success block is specified, it is the responsibility of the block to set the image of the button before returning. If no success block is specified, the default behavior of setting the image with `setImage:forState:` is applied.
102 |
103 | @param state The control state.
104 | @param urlRequest The URL request used for the image request.
105 | @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the button will not change its image until the image request finishes.
106 | @param success A block to be executed when the image request operation finishes successfully. This block has no return value and takes two arguments: the server response and the image. If the image was returned from cache, the response parameter will be `nil`.
107 | @param failure A block object to be executed when the image request operation finishes unsuccessfully, or that finishes successfully. This block has no return value and takes a single argument: the error that occurred.
108 | */
109 | - (void)setImageForState:(UIControlState)state
110 | withURLRequest:(NSURLRequest *)urlRequest
111 | placeholderImage:(nullable UIImage *)placeholderImage
112 | success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * __nullable response, UIImage *image))success
113 | failure:(nullable void (^)(NSError *error))failure;
114 |
115 |
116 | ///-------------------------------
117 | /// @name Setting Background Image
118 | ///-------------------------------
119 |
120 | /**
121 | Asynchronously downloads an image from the specified URL, and sets it as the background image for the specified state once the request is finished. Any previous background image request for the receiver will be cancelled.
122 |
123 | If the background image is cached locally, the background image is set immediately, otherwise the specified placeholder background image will be set immediately, and then the remote background image will be set once the request is finished.
124 |
125 | @param state The control state.
126 | @param url The URL used for the background image request.
127 | */
128 | - (void)setBackgroundImageForState:(UIControlState)state
129 | withURL:(NSURL *)url;
130 |
131 | /**
132 | Asynchronously downloads an image from the specified URL, and sets it as the background image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled.
133 |
134 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
135 |
136 | @param state The control state.
137 | @param url The URL used for the background image request.
138 | @param placeholderImage The background image to be set initially, until the background image request finishes. If `nil`, the button will not change its background image until the background image request finishes.
139 | */
140 | - (void)setBackgroundImageForState:(UIControlState)state
141 | withURL:(NSURL *)url
142 | placeholderImage:(nullable UIImage *)placeholderImage;
143 |
144 | /**
145 | Asynchronously downloads an image from the specified URL request, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled.
146 |
147 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
148 |
149 | If a success block is specified, it is the responsibility of the block to set the image of the button before returning. If no success block is specified, the default behavior of setting the image with `setBackgroundImage:forState:` is applied.
150 |
151 | @param state The control state.
152 | @param urlRequest The URL request used for the image request.
153 | @param placeholderImage The background image to be set initially, until the background image request finishes. If `nil`, the button will not change its background image until the background image request finishes.
154 | @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 response parameter will be `nil`.
155 | @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.
156 | */
157 | - (void)setBackgroundImageForState:(UIControlState)state
158 | withURLRequest:(NSURLRequest *)urlRequest
159 | placeholderImage:(nullable UIImage *)placeholderImage
160 | success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * __nullable response, UIImage *image))success
161 | failure:(nullable void (^)(NSError *error))failure;
162 |
163 |
164 | ///------------------------------
165 | /// @name Canceling Image Loading
166 | ///------------------------------
167 |
168 | /**
169 | Cancels any executing image operation for the specified control state of the receiver, if one exists.
170 |
171 | @param state The control state.
172 | */
173 | - (void)cancelImageRequestOperationForState:(UIControlState)state;
174 |
175 | /**
176 | Cancels any executing background image operation for the specified control state of the receiver, if one exists.
177 |
178 | @param state The control state.
179 | */
180 | - (void)cancelBackgroundImageRequestOperationForState:(UIControlState)state;
181 |
182 | @end
183 |
184 | NS_ASSUME_NONNULL_END
185 |
186 | #endif
187 |
--------------------------------------------------------------------------------
/Pods/AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIImage+AFNetworking.h
3 | //
4 | //
5 | // Created by Paulo Ferreira on 08/07/15.
6 | //
7 | // Permission is hereby granted, free of charge, to any person obtaining a copy
8 | // of this software and associated documentation files (the "Software"), to deal
9 | // in the Software without restriction, including without limitation the rights
10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | // copies of the Software, and to permit persons to whom the Software is
12 | // furnished to do so, subject to the following conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be included in
15 | // all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | // THE SOFTWARE.
24 |
25 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
26 |
27 | #import
28 |
29 | @interface UIImage (AFNetworking)
30 |
31 | + (UIImage*) safeImageWithData:(NSData*)data;
32 |
33 | @end
34 |
35 | #endif
36 |
--------------------------------------------------------------------------------
/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | // UIImageView+AFNetworking.h
2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 |
24 | #import
25 |
26 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
27 |
28 | #import
29 |
30 | NS_ASSUME_NONNULL_BEGIN
31 |
32 | @protocol AFURLResponseSerialization, AFImageCache;
33 |
34 | /**
35 | This category adds methods to the UIKit framework's `UIImageView` class. The methods in this category provide support for loading remote images asynchronously from a URL.
36 | */
37 | @interface UIImageView (AFNetworking)
38 |
39 | ///----------------------------
40 | /// @name Accessing Image Cache
41 | ///----------------------------
42 |
43 | /**
44 | The image cache used to improve image loading performance on scroll views. By default, this is an `NSCache` subclass conforming to the `AFImageCache` protocol, which listens for notification warnings and evicts objects accordingly.
45 | */
46 | + (id )sharedImageCache;
47 |
48 | /**
49 | Set the cache used for image loading.
50 |
51 | @param imageCache The image cache.
52 | */
53 | + (void)setSharedImageCache:(__nullable id )imageCache;
54 |
55 | ///------------------------------------
56 | /// @name Accessing Response Serializer
57 | ///------------------------------------
58 |
59 | /**
60 | The response serializer used to create an image representation from the server response and response data. By default, this is an instance of `AFImageResponseSerializer`.
61 |
62 | @discussion Subclasses of `AFImageResponseSerializer` could be used to perform post-processing, such as color correction, face detection, or other effects. See https://github.com/AFNetworking/AFCoreImageSerializer
63 | */
64 | @property (nonatomic, strong) id imageResponseSerializer;
65 |
66 | ///--------------------
67 | /// @name Setting Image
68 | ///--------------------
69 |
70 | /**
71 | Asynchronously downloads an image from the specified URL, and sets it once the request is finished. Any previous image request for the receiver will be cancelled.
72 |
73 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
74 |
75 | By default, URL requests have a `Accept` header field value of "image / *", a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:`
76 |
77 | @param url The URL used for the image request.
78 | */
79 | - (void)setImageWithURL:(NSURL *)url;
80 |
81 | /**
82 | Asynchronously downloads an image from the specified URL, and sets it once the request is finished. Any previous image request for the receiver will be cancelled.
83 |
84 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
85 |
86 | By default, URL requests have a `Accept` header field value of "image / *", a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:`
87 |
88 | @param url The URL used for the image request.
89 | @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes.
90 | */
91 | - (void)setImageWithURL:(NSURL *)url
92 | placeholderImage:(nullable UIImage *)placeholderImage;
93 |
94 | /**
95 | Asynchronously downloads an image from the specified URL request, and sets it once the request is finished. Any previous image request for the receiver will be cancelled.
96 |
97 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
98 |
99 | If a success block is specified, it is the responsibility of the block to set the image of the image view before returning. If no success block is specified, the default behavior of setting the image with `self.image = image` is applied.
100 |
101 | @param urlRequest The URL request used for the image request.
102 | @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes.
103 | @param success A block to be executed when the image request operation finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`.
104 | @param failure A block object to be executed when the image request operation finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred.
105 | */
106 | - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest
107 | placeholderImage:(nullable UIImage *)placeholderImage
108 | success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * __nullable response, UIImage *image))success
109 | failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * __nullable response, NSError *error))failure;
110 |
111 | /**
112 | Cancels any executing image operation for the receiver, if one exists.
113 | */
114 | - (void)cancelImageRequestOperation;
115 |
116 | @end
117 |
118 | #pragma mark -
119 |
120 | /**
121 | The `AFImageCache` protocol is adopted by an object used to cache images loaded by the AFNetworking category on `UIImageView`.
122 | */
123 | @protocol AFImageCache
124 |
125 | /**
126 | Returns a cached image for the specified request, if available.
127 |
128 | @param request The image request.
129 |
130 | @return The cached image.
131 | */
132 | - (nullable UIImage *)cachedImageForRequest:(NSURLRequest *)request;
133 |
134 | /**
135 | Caches a particular image for the specified request.
136 |
137 | @param image The image to cache.
138 | @param request The request to be used as a cache key.
139 | */
140 | - (void)cacheImage:(UIImage *)image
141 | forRequest:(NSURLRequest *)request;
142 | @end
143 |
144 | NS_ASSUME_NONNULL_END
145 |
146 | #endif
147 |
--------------------------------------------------------------------------------
/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.m:
--------------------------------------------------------------------------------
1 | // UIImageView+AFNetworking.m
2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import "UIImageView+AFNetworking.h"
23 |
24 | #import
25 |
26 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
27 |
28 | #import "AFHTTPRequestOperation.h"
29 |
30 | @interface AFImageCache : NSCache
31 | @end
32 |
33 | #pragma mark -
34 |
35 | @interface UIImageView (_AFNetworking)
36 | @property (readwrite, nonatomic, strong, setter = af_setImageRequestOperation:) AFHTTPRequestOperation *af_imageRequestOperation;
37 | @end
38 |
39 | @implementation UIImageView (_AFNetworking)
40 |
41 | + (NSOperationQueue *)af_sharedImageRequestOperationQueue {
42 | static NSOperationQueue *_af_sharedImageRequestOperationQueue = nil;
43 | static dispatch_once_t onceToken;
44 | dispatch_once(&onceToken, ^{
45 | _af_sharedImageRequestOperationQueue = [[NSOperationQueue alloc] init];
46 | _af_sharedImageRequestOperationQueue.maxConcurrentOperationCount = NSOperationQueueDefaultMaxConcurrentOperationCount;
47 | });
48 |
49 | return _af_sharedImageRequestOperationQueue;
50 | }
51 |
52 | - (AFHTTPRequestOperation *)af_imageRequestOperation {
53 | return (AFHTTPRequestOperation *)objc_getAssociatedObject(self, @selector(af_imageRequestOperation));
54 | }
55 |
56 | - (void)af_setImageRequestOperation:(AFHTTPRequestOperation *)imageRequestOperation {
57 | objc_setAssociatedObject(self, @selector(af_imageRequestOperation), imageRequestOperation, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
58 | }
59 |
60 | @end
61 |
62 | #pragma mark -
63 |
64 | @implementation UIImageView (AFNetworking)
65 | @dynamic imageResponseSerializer;
66 |
67 | + (id )sharedImageCache {
68 | static AFImageCache *_af_defaultImageCache = nil;
69 | static dispatch_once_t oncePredicate;
70 | dispatch_once(&oncePredicate, ^{
71 | _af_defaultImageCache = [[AFImageCache alloc] init];
72 |
73 | [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidReceiveMemoryWarningNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * __unused notification) {
74 | [_af_defaultImageCache removeAllObjects];
75 | }];
76 | });
77 |
78 | #pragma clang diagnostic push
79 | #pragma clang diagnostic ignored "-Wgnu"
80 | return objc_getAssociatedObject(self, @selector(sharedImageCache)) ?: _af_defaultImageCache;
81 | #pragma clang diagnostic pop
82 | }
83 |
84 | + (void)setSharedImageCache:(__nullable 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 * __nullable response, UIImage *image))success
125 | failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse * __nullable response, NSError *error))failure
126 | {
127 | [self cancelImageRequestOperation];
128 |
129 | UIImage *cachedImage = [[[self class] sharedImageCache] cachedImageForRequest:urlRequest];
130 | if (cachedImage) {
131 | if (success) {
132 | success(urlRequest, nil, cachedImage);
133 | } else {
134 | self.image = cachedImage;
135 | }
136 |
137 | self.af_imageRequestOperation = nil;
138 | } else {
139 | if (placeholderImage) {
140 | self.image = placeholderImage;
141 | }
142 |
143 | __weak __typeof(self)weakSelf = self;
144 | self.af_imageRequestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:urlRequest];
145 | self.af_imageRequestOperation.responseSerializer = self.imageResponseSerializer;
146 | [self.af_imageRequestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
147 | __strong __typeof(weakSelf)strongSelf = weakSelf;
148 | if ([[urlRequest URL] isEqual:[strongSelf.af_imageRequestOperation.request URL]]) {
149 | if (success) {
150 | success(urlRequest, operation.response, responseObject);
151 | } else if (responseObject) {
152 | strongSelf.image = responseObject;
153 | }
154 |
155 | if (operation == strongSelf.af_imageRequestOperation){
156 | strongSelf.af_imageRequestOperation = nil;
157 | }
158 | }
159 |
160 | [[[strongSelf class] sharedImageCache] cacheImage:responseObject forRequest:urlRequest];
161 | } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
162 | __strong __typeof(weakSelf)strongSelf = weakSelf;
163 | if ([[urlRequest URL] isEqual:[strongSelf.af_imageRequestOperation.request URL]]) {
164 | if (failure) {
165 | failure(urlRequest, operation.response, error);
166 | }
167 |
168 | if (operation == strongSelf.af_imageRequestOperation){
169 | strongSelf.af_imageRequestOperation = nil;
170 | }
171 | }
172 | }];
173 |
174 | [[[self class] af_sharedImageRequestOperationQueue] addOperation:self.af_imageRequestOperation];
175 | }
176 | }
177 |
178 | - (void)cancelImageRequestOperation {
179 | [self.af_imageRequestOperation cancel];
180 | self.af_imageRequestOperation = nil;
181 | }
182 |
183 | @end
184 |
185 | #pragma mark -
186 |
187 | static inline NSString * AFImageCacheKeyFromURLRequest(NSURLRequest *request) {
188 | return [[request URL] absoluteString];
189 | }
190 |
191 | @implementation AFImageCache
192 |
193 | - (UIImage *)cachedImageForRequest:(NSURLRequest *)request {
194 | switch ([request cachePolicy]) {
195 | case NSURLRequestReloadIgnoringCacheData:
196 | case NSURLRequestReloadIgnoringLocalAndRemoteCacheData:
197 | return nil;
198 | default:
199 | break;
200 | }
201 |
202 | return [self objectForKey:AFImageCacheKeyFromURLRequest(request)];
203 | }
204 |
205 | - (void)cacheImage:(UIImage *)image
206 | forRequest:(NSURLRequest *)request
207 | {
208 | if (image && request) {
209 | [self setObject:image forKey:AFImageCacheKeyFromURLRequest(request)];
210 | }
211 | }
212 |
213 | @end
214 |
215 | #endif
216 |
--------------------------------------------------------------------------------
/Pods/AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h:
--------------------------------------------------------------------------------
1 | // UIKit+AFNetworking.h
2 | //
3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.com/)
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #if TARGET_OS_IOS
24 | #import
25 |
26 | #ifndef _UIKIT_AFNETWORKING_
27 | #define _UIKIT_AFNETWORKING_
28 |
29 | #import "AFNetworkActivityIndicatorManager.h"
30 |
31 | #import "UIActivityIndicatorView+AFNetworking.h"
32 | #import "UIAlertView+AFNetworking.h"
33 | #import "UIButton+AFNetworking.h"
34 | #import "UIImageView+AFNetworking.h"
35 | #import "UIProgressView+AFNetworking.h"
36 | #import "UIRefreshControl+AFNetworking.h"
37 | #import "UIWebView+AFNetworking.h"
38 | #endif /* _UIKIT_AFNETWORKING_ */
39 | #endif
40 |
--------------------------------------------------------------------------------
/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | // UIProgressView+AFNetworking.h
2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 |
24 | #import
25 |
26 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
27 |
28 | #import
29 |
30 | NS_ASSUME_NONNULL_BEGIN
31 |
32 | @class AFURLConnectionOperation;
33 |
34 | /**
35 | This category adds methods to the UIKit framework's `UIProgressView` class. The methods in this category provide support for binding the progress to the upload and download progress of a session task or request operation.
36 | */
37 | @interface UIProgressView (AFNetworking)
38 |
39 | ///------------------------------------
40 | /// @name Setting Session Task Progress
41 | ///------------------------------------
42 |
43 | /**
44 | Binds the progress to the upload progress of the specified session task.
45 |
46 | @param task The session task.
47 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately.
48 | */
49 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
50 | - (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task
51 | animated:(BOOL)animated;
52 | #endif
53 |
54 | /**
55 | Binds the progress to the download progress of the specified session task.
56 |
57 | @param task The session task.
58 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately.
59 | */
60 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
61 | - (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task
62 | animated:(BOOL)animated;
63 | #endif
64 |
65 | ///------------------------------------
66 | /// @name Setting Session Task Progress
67 | ///------------------------------------
68 |
69 | /**
70 | Binds the progress to the upload progress of the specified request operation.
71 |
72 | @param operation The request operation.
73 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately.
74 | */
75 | - (void)setProgressWithUploadProgressOfOperation:(AFURLConnectionOperation *)operation
76 | animated:(BOOL)animated;
77 |
78 | /**
79 | Binds the progress to the download progress of the specified request operation.
80 |
81 | @param operation The request operation.
82 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately.
83 | */
84 | - (void)setProgressWithDownloadProgressOfOperation:(AFURLConnectionOperation *)operation
85 | animated:(BOOL)animated;
86 |
87 | @end
88 |
89 | NS_ASSUME_NONNULL_END
90 |
91 | #endif
92 |
--------------------------------------------------------------------------------
/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.m:
--------------------------------------------------------------------------------
1 | // UIProgressView+AFNetworking.m
2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import "UIProgressView+AFNetworking.h"
23 |
24 | #import
25 |
26 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
27 |
28 | #import "AFURLConnectionOperation.h"
29 |
30 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
31 | #import "AFURLSessionManager.h"
32 | #endif
33 |
34 | static void * AFTaskCountOfBytesSentContext = &AFTaskCountOfBytesSentContext;
35 | static void * AFTaskCountOfBytesReceivedContext = &AFTaskCountOfBytesReceivedContext;
36 |
37 | @interface AFURLConnectionOperation (_UIProgressView)
38 | @property (readwrite, nonatomic, copy) void (^uploadProgress)(NSUInteger bytes, long long totalBytes, long long totalBytesExpected);
39 | @property (readwrite, nonatomic, assign, setter = af_setUploadProgressAnimated:) BOOL af_uploadProgressAnimated;
40 |
41 | @property (readwrite, nonatomic, copy) void (^downloadProgress)(NSUInteger bytes, long long totalBytes, long long totalBytesExpected);
42 | @property (readwrite, nonatomic, assign, setter = af_setDownloadProgressAnimated:) BOOL af_downloadProgressAnimated;
43 | @end
44 |
45 | @implementation AFURLConnectionOperation (_UIProgressView)
46 | @dynamic uploadProgress; // Implemented in AFURLConnectionOperation
47 | @dynamic af_uploadProgressAnimated;
48 |
49 | @dynamic downloadProgress; // Implemented in AFURLConnectionOperation
50 | @dynamic af_downloadProgressAnimated;
51 | @end
52 |
53 | #pragma mark -
54 |
55 | @implementation UIProgressView (AFNetworking)
56 |
57 | - (BOOL)af_uploadProgressAnimated {
58 | return [(NSNumber *)objc_getAssociatedObject(self, @selector(af_uploadProgressAnimated)) boolValue];
59 | }
60 |
61 | - (void)af_setUploadProgressAnimated:(BOOL)animated {
62 | objc_setAssociatedObject(self, @selector(af_uploadProgressAnimated), @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
63 | }
64 |
65 | - (BOOL)af_downloadProgressAnimated {
66 | return [(NSNumber *)objc_getAssociatedObject(self, @selector(af_downloadProgressAnimated)) boolValue];
67 | }
68 |
69 | - (void)af_setDownloadProgressAnimated:(BOOL)animated {
70 | objc_setAssociatedObject(self, @selector(af_downloadProgressAnimated), @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
71 | }
72 |
73 | #pragma mark -
74 |
75 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
76 | - (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task
77 | animated:(BOOL)animated
78 | {
79 | [task addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesSentContext];
80 | [task addObserver:self forKeyPath:@"countOfBytesSent" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesSentContext];
81 |
82 | [self af_setUploadProgressAnimated:animated];
83 | }
84 |
85 | - (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task
86 | animated:(BOOL)animated
87 | {
88 | [task addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesReceivedContext];
89 | [task addObserver:self forKeyPath:@"countOfBytesReceived" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesReceivedContext];
90 |
91 | [self af_setDownloadProgressAnimated:animated];
92 | }
93 | #endif
94 |
95 | #pragma mark -
96 |
97 | - (void)setProgressWithUploadProgressOfOperation:(AFURLConnectionOperation *)operation
98 | animated:(BOOL)animated
99 | {
100 | __weak __typeof(self)weakSelf = self;
101 | void (^original)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) = [operation.uploadProgress copy];
102 | [operation setUploadProgressBlock:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) {
103 | if (original) {
104 | original(bytesWritten, totalBytesWritten, totalBytesExpectedToWrite);
105 | }
106 |
107 | dispatch_async(dispatch_get_main_queue(), ^{
108 | if (totalBytesExpectedToWrite > 0) {
109 | __strong __typeof(weakSelf)strongSelf = weakSelf;
110 | [strongSelf setProgress:(totalBytesWritten / (totalBytesExpectedToWrite * 1.0f)) animated:animated];
111 | }
112 | });
113 | }];
114 | }
115 |
116 | - (void)setProgressWithDownloadProgressOfOperation:(AFURLConnectionOperation *)operation
117 | animated:(BOOL)animated
118 | {
119 | __weak __typeof(self)weakSelf = self;
120 | void (^original)(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) = [operation.downloadProgress copy];
121 | [operation setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) {
122 | if (original) {
123 | original(bytesRead, totalBytesRead, totalBytesExpectedToRead);
124 | }
125 |
126 | dispatch_async(dispatch_get_main_queue(), ^{
127 | if (totalBytesExpectedToRead > 0) {
128 | __strong __typeof(weakSelf)strongSelf = weakSelf;
129 | [strongSelf setProgress:(totalBytesRead / (totalBytesExpectedToRead * 1.0f)) animated:animated];
130 | }
131 | });
132 | }];
133 | }
134 |
135 | #pragma mark - NSKeyValueObserving
136 |
137 | - (void)observeValueForKeyPath:(NSString *)keyPath
138 | ofObject:(id)object
139 | change:(__unused NSDictionary *)change
140 | context:(void *)context
141 | {
142 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
143 | if (context == AFTaskCountOfBytesSentContext || context == AFTaskCountOfBytesReceivedContext) {
144 | if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesSent))]) {
145 | if ([object countOfBytesExpectedToSend] > 0) {
146 | dispatch_async(dispatch_get_main_queue(), ^{
147 | [self setProgress:[object countOfBytesSent] / ([object countOfBytesExpectedToSend] * 1.0f) animated:self.af_uploadProgressAnimated];
148 | });
149 | }
150 | }
151 |
152 | if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesReceived))]) {
153 | if ([object countOfBytesExpectedToReceive] > 0) {
154 | dispatch_async(dispatch_get_main_queue(), ^{
155 | [self setProgress:[object countOfBytesReceived] / ([object countOfBytesExpectedToReceive] * 1.0f) animated:self.af_downloadProgressAnimated];
156 | });
157 | }
158 | }
159 |
160 | if ([keyPath isEqualToString:NSStringFromSelector(@selector(state))]) {
161 | if ([(NSURLSessionTask *)object state] == NSURLSessionTaskStateCompleted) {
162 | @try {
163 | [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(state))];
164 |
165 | if (context == AFTaskCountOfBytesSentContext) {
166 | [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesSent))];
167 | }
168 |
169 | if (context == AFTaskCountOfBytesReceivedContext) {
170 | [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesReceived))];
171 | }
172 | }
173 | @catch (NSException * __unused exception) {}
174 | }
175 | }
176 | }
177 | #endif
178 | }
179 |
180 | @end
181 |
182 | #endif
183 |
--------------------------------------------------------------------------------
/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h:
--------------------------------------------------------------------------------
1 | // UIRefreshControl+AFNetworking.m
2 | //
3 | // Copyright (c) 2014 AFNetworking (http://afnetworking.com)
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import
24 |
25 | #import
26 |
27 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
28 |
29 | #import
30 |
31 | NS_ASSUME_NONNULL_BEGIN
32 |
33 | @class AFURLConnectionOperation;
34 |
35 | /**
36 | This category adds methods to the UIKit framework's `UIRefreshControl` class. The methods in this category provide support for automatically beginning and ending refreshing depending on the loading state of a request operation or session task.
37 | */
38 | @interface UIRefreshControl (AFNetworking)
39 |
40 | ///-----------------------------------
41 | /// @name Refreshing for Session Tasks
42 | ///-----------------------------------
43 |
44 | /**
45 | Binds the refreshing state to the state of the specified task.
46 |
47 | @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled.
48 | */
49 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
50 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task;
51 | #endif
52 |
53 | ///----------------------------------------
54 | /// @name Refreshing for Request Operations
55 | ///----------------------------------------
56 |
57 | /**
58 | Binds the refreshing state to the execution state of the specified operation.
59 |
60 | @param operation The operation. If `nil`, automatic updating from any previously specified operation will be disabled.
61 | */
62 | - (void)setRefreshingWithStateOfOperation:(AFURLConnectionOperation *)operation;
63 |
64 | @end
65 |
66 | NS_ASSUME_NONNULL_END
67 |
68 | #endif
69 |
--------------------------------------------------------------------------------
/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m:
--------------------------------------------------------------------------------
1 | // UIRefreshControl+AFNetworking.m
2 | //
3 | // Copyright (c) 2014 AFNetworking (http://afnetworking.com)
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import "UIRefreshControl+AFNetworking.h"
24 | #import
25 |
26 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
27 |
28 | #import "AFHTTPRequestOperation.h"
29 |
30 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
31 | #import "AFURLSessionManager.h"
32 | #endif
33 |
34 | @interface AFRefreshControlNotificationObserver : NSObject
35 | @property (readonly, nonatomic, weak) UIRefreshControl *refreshControl;
36 | - (instancetype)initWithActivityRefreshControl:(UIRefreshControl *)refreshControl;
37 |
38 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
39 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task;
40 | #endif
41 | - (void)setRefreshingWithStateOfOperation:(AFURLConnectionOperation *)operation;
42 |
43 | @end
44 |
45 | @implementation UIRefreshControl (AFNetworking)
46 |
47 | - (AFRefreshControlNotificationObserver *)af_notificationObserver {
48 | AFRefreshControlNotificationObserver *notificationObserver = objc_getAssociatedObject(self, @selector(af_notificationObserver));
49 | if (notificationObserver == nil) {
50 | notificationObserver = [[AFRefreshControlNotificationObserver alloc] initWithActivityRefreshControl:self];
51 | objc_setAssociatedObject(self, @selector(af_notificationObserver), notificationObserver, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
52 | }
53 | return notificationObserver;
54 | }
55 |
56 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
57 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task {
58 | [[self af_notificationObserver] setRefreshingWithStateOfTask:task];
59 | }
60 | #endif
61 |
62 | - (void)setRefreshingWithStateOfOperation:(AFURLConnectionOperation *)operation {
63 | [[self af_notificationObserver] setRefreshingWithStateOfOperation:operation];
64 | }
65 |
66 | @end
67 |
68 | @implementation AFRefreshControlNotificationObserver
69 |
70 | - (instancetype)initWithActivityRefreshControl:(UIRefreshControl *)refreshControl
71 | {
72 | self = [super init];
73 | if (self) {
74 | _refreshControl = refreshControl;
75 | }
76 | return self;
77 | }
78 |
79 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
80 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task {
81 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
82 |
83 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil];
84 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil];
85 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil];
86 |
87 | if (task) {
88 | #pragma clang diagnostic push
89 | #pragma clang diagnostic ignored "-Wreceiver-is-weak"
90 | #pragma clang diagnostic ignored "-Warc-repeated-use-of-weak"
91 | if (task.state == NSURLSessionTaskStateRunning) {
92 | [self.refreshControl beginRefreshing];
93 |
94 | [notificationCenter addObserver:self selector:@selector(af_beginRefreshing) name:AFNetworkingTaskDidResumeNotification object:task];
95 | [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidCompleteNotification object:task];
96 | [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidSuspendNotification object:task];
97 | } else {
98 | [self.refreshControl endRefreshing];
99 | }
100 | #pragma clang diagnostic pop
101 | }
102 | }
103 | #endif
104 |
105 | - (void)setRefreshingWithStateOfOperation:(AFURLConnectionOperation *)operation {
106 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
107 |
108 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidStartNotification object:nil];
109 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidFinishNotification object:nil];
110 |
111 | if (operation) {
112 | #pragma clang diagnostic push
113 | #pragma clang diagnostic ignored "-Wreceiver-is-weak"
114 | #pragma clang diagnostic ignored "-Warc-repeated-use-of-weak"
115 | if (![operation isFinished]) {
116 | if ([operation isExecuting]) {
117 | [self.refreshControl beginRefreshing];
118 | } else {
119 | [self.refreshControl endRefreshing];
120 | }
121 |
122 | [notificationCenter addObserver:self selector:@selector(af_beginRefreshing) name:AFNetworkingOperationDidStartNotification object:operation];
123 | [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingOperationDidFinishNotification object:operation];
124 | }
125 | #pragma clang diagnostic pop
126 | }
127 | }
128 |
129 | #pragma mark -
130 |
131 | - (void)af_beginRefreshing {
132 | dispatch_async(dispatch_get_main_queue(), ^{
133 | #pragma clang diagnostic push
134 | #pragma clang diagnostic ignored "-Wreceiver-is-weak"
135 | [self.refreshControl beginRefreshing];
136 | #pragma clang diagnostic pop
137 | });
138 | }
139 |
140 | - (void)af_endRefreshing {
141 | dispatch_async(dispatch_get_main_queue(), ^{
142 | #pragma clang diagnostic push
143 | #pragma clang diagnostic ignored "-Wreceiver-is-weak"
144 | [self.refreshControl endRefreshing];
145 | #pragma clang diagnostic pop
146 | });
147 | }
148 |
149 | #pragma mark -
150 |
151 | - (void)dealloc {
152 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
153 |
154 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
155 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil];
156 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil];
157 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil];
158 | #endif
159 |
160 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidStartNotification object:nil];
161 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidFinishNotification object:nil];
162 | }
163 |
164 | @end
165 |
166 | #endif
167 |
--------------------------------------------------------------------------------
/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | // UIWebView+AFNetworking.h
2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 |
24 | #import
25 |
26 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
27 |
28 | #import
29 |
30 | NS_ASSUME_NONNULL_BEGIN
31 |
32 | @class AFHTTPRequestSerializer, AFHTTPResponseSerializer;
33 | @protocol AFURLRequestSerialization, AFURLResponseSerialization;
34 |
35 | /**
36 | This category adds methods to the UIKit framework's `UIWebView` class. The methods in this category provide increased control over the request cycle, including progress monitoring and success / failure handling.
37 |
38 | @discussion When using these category methods, make sure to assign `delegate` for the web view, which implements `–webView:shouldStartLoadWithRequest:navigationType:` appropriately. This allows for tapped links to be loaded through AFNetworking, and can ensure that `canGoBack` & `canGoForward` update their values correctly.
39 | */
40 | @interface UIWebView (AFNetworking)
41 |
42 | /**
43 | The request serializer used to serialize requests made with the `-loadRequest:...` category methods. By default, this is an instance of `AFHTTPRequestSerializer`.
44 | */
45 | @property (nonatomic, strong) AFHTTPRequestSerializer * requestSerializer;
46 |
47 | /**
48 | The response serializer used to serialize responses made with the `-loadRequest:...` category methods. By default, this is an instance of `AFHTTPResponseSerializer`.
49 | */
50 | @property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer;
51 |
52 | /**
53 | Asynchronously loads the specified request.
54 |
55 | @param request A URL request identifying the location of the content to load. This must not be `nil`.
56 | @param progress A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the number of bytes read since the last time the download progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times, and will execute on the main thread.
57 | @param success A block object to be executed when the request finishes loading successfully. This block returns the HTML string to be loaded by the web view, and takes two arguments: the response, and the response string.
58 | @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred.
59 | */
60 | - (void)loadRequest:(NSURLRequest *)request
61 | progress:(nullable void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress
62 | success:(nullable NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success
63 | failure:(nullable void (^)(NSError *error))failure;
64 |
65 | /**
66 | Asynchronously loads the data associated with a particular request with a specified MIME type and text encoding.
67 |
68 | @param request A URL request identifying the location of the content to load. This must not be `nil`.
69 | @param MIMEType The MIME type of the content. Defaults to the content type of the response if not specified.
70 | @param textEncodingName The IANA encoding name, as in `utf-8` or `utf-16`. Defaults to the response text encoding if not specified.
71 | @param progress A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the number of bytes read since the last time the download progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times, and will execute on the main thread.
72 | @param success A block object to be executed when the request finishes loading successfully. This block returns the data to be loaded by the web view and takes two arguments: the response, and the downloaded data.
73 | @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred.
74 | */
75 | - (void)loadRequest:(NSURLRequest *)request
76 | MIMEType:(nullable NSString *)MIMEType
77 | textEncodingName:(nullable NSString *)textEncodingName
78 | progress:(nullable void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress
79 | success:(nullable NSData * (^)(NSHTTPURLResponse *response, NSData *data))success
80 | failure:(nullable void (^)(NSError *error))failure;
81 |
82 | @end
83 |
84 | NS_ASSUME_NONNULL_END
85 |
86 | #endif
87 |
--------------------------------------------------------------------------------
/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.m:
--------------------------------------------------------------------------------
1 | // UIWebView+AFNetworking.m
2 | // Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import "UIWebView+AFNetworking.h"
23 |
24 | #import
25 |
26 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
27 |
28 | #import "AFHTTPRequestOperation.h"
29 | #import "AFURLResponseSerialization.h"
30 | #import "AFURLRequestSerialization.h"
31 |
32 | @interface UIWebView (_AFNetworking)
33 | @property (readwrite, nonatomic, strong, setter = af_setHTTPRequestOperation:) AFHTTPRequestOperation *af_HTTPRequestOperation;
34 | @end
35 |
36 | @implementation UIWebView (_AFNetworking)
37 |
38 | - (AFHTTPRequestOperation *)af_HTTPRequestOperation {
39 | return (AFHTTPRequestOperation *)objc_getAssociatedObject(self, @selector(af_HTTPRequestOperation));
40 | }
41 |
42 | - (void)af_setHTTPRequestOperation:(AFHTTPRequestOperation *)operation {
43 | objc_setAssociatedObject(self, @selector(af_HTTPRequestOperation), operation, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
44 | }
45 |
46 | @end
47 |
48 | #pragma mark -
49 |
50 | @implementation UIWebView (AFNetworking)
51 |
52 | - (AFHTTPRequestSerializer *)requestSerializer {
53 | static AFHTTPRequestSerializer *_af_defaultRequestSerializer = nil;
54 | static dispatch_once_t onceToken;
55 | dispatch_once(&onceToken, ^{
56 | _af_defaultRequestSerializer = [AFHTTPRequestSerializer serializer];
57 | });
58 |
59 | #pragma clang diagnostic push
60 | #pragma clang diagnostic ignored "-Wgnu"
61 | return objc_getAssociatedObject(self, @selector(requestSerializer)) ?: _af_defaultRequestSerializer;
62 | #pragma clang diagnostic pop
63 | }
64 |
65 | - (void)setRequestSerializer:(AFHTTPRequestSerializer *)requestSerializer {
66 | objc_setAssociatedObject(self, @selector(requestSerializer), requestSerializer, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
67 | }
68 |
69 | - (AFHTTPResponseSerializer *)responseSerializer {
70 | static AFHTTPResponseSerializer *_af_defaultResponseSerializer = nil;
71 | static dispatch_once_t onceToken;
72 | dispatch_once(&onceToken, ^{
73 | _af_defaultResponseSerializer = [AFHTTPResponseSerializer serializer];
74 | });
75 |
76 | #pragma clang diagnostic push
77 | #pragma clang diagnostic ignored "-Wgnu"
78 | return objc_getAssociatedObject(self, @selector(responseSerializer)) ?: _af_defaultResponseSerializer;
79 | #pragma clang diagnostic pop
80 | }
81 |
82 | - (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer {
83 | objc_setAssociatedObject(self, @selector(responseSerializer), responseSerializer, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
84 | }
85 |
86 | #pragma mark -
87 |
88 | - (void)loadRequest:(NSURLRequest *)request
89 | progress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress
90 | success:(NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success
91 | failure:(void (^)(NSError *error))failure
92 | {
93 | [self loadRequest:request MIMEType:nil textEncodingName:nil progress:progress success:^NSData *(NSHTTPURLResponse *response, NSData *data) {
94 | NSStringEncoding stringEncoding = NSUTF8StringEncoding;
95 | if (response.textEncodingName) {
96 | CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)response.textEncodingName);
97 | if (encoding != kCFStringEncodingInvalidId) {
98 | stringEncoding = CFStringConvertEncodingToNSStringEncoding(encoding);
99 | }
100 | }
101 |
102 | NSString *string = [[NSString alloc] initWithData:data encoding:stringEncoding];
103 | if (success) {
104 | string = success(response, string);
105 | }
106 |
107 | return [string dataUsingEncoding:stringEncoding];
108 | } failure:failure];
109 | }
110 |
111 | - (void)loadRequest:(NSURLRequest *)request
112 | MIMEType:(NSString *)MIMEType
113 | textEncodingName:(NSString *)textEncodingName
114 | progress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress
115 | success:(NSData * (^)(NSHTTPURLResponse *response, NSData *data))success
116 | failure:(void (^)(NSError *error))failure
117 | {
118 | NSParameterAssert(request);
119 |
120 | if (self.af_HTTPRequestOperation) {
121 | [self.af_HTTPRequestOperation cancel];
122 | }
123 |
124 | request = [self.requestSerializer requestBySerializingRequest:request withParameters:nil error:nil];
125 |
126 | self.af_HTTPRequestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
127 | self.af_HTTPRequestOperation.responseSerializer = self.responseSerializer;
128 |
129 | __weak __typeof(self)weakSelf = self;
130 | [self.af_HTTPRequestOperation setDownloadProgressBlock:progress];
131 | [self.af_HTTPRequestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id __unused responseObject) {
132 | NSData *data = success ? success(operation.response, operation.responseData) : operation.responseData;
133 |
134 | #pragma clang diagnostic push
135 | #pragma clang diagnostic ignored "-Wgnu"
136 | __strong __typeof(weakSelf) strongSelf = weakSelf;
137 | [strongSelf loadData:data MIMEType:(MIMEType ?: [operation.response MIMEType]) textEncodingName:(textEncodingName ?: [operation.response textEncodingName]) baseURL:[operation.response URL]];
138 |
139 | if ([strongSelf.delegate respondsToSelector:@selector(webViewDidFinishLoad:)]) {
140 | [strongSelf.delegate webViewDidFinishLoad:strongSelf];
141 | }
142 |
143 | #pragma clang diagnostic pop
144 | } failure:^(AFHTTPRequestOperation * __unused operation, NSError *error) {
145 | if (failure) {
146 | failure(error);
147 | }
148 | }];
149 |
150 | [self.af_HTTPRequestOperation start];
151 |
152 | if ([self.delegate respondsToSelector:@selector(webViewDidStartLoad:)]) {
153 | [self.delegate webViewDidStartLoad:self];
154 | }
155 | }
156 |
157 | @end
158 |
159 | #endif
160 |
--------------------------------------------------------------------------------
/Pods/Headers/Private/AFNetworking/AFHTTPRequestOperation.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/AFNetworking/AFHTTPRequestOperation.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/AFNetworking/AFHTTPRequestOperationManager.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/AFNetworking/AFHTTPRequestOperationManager.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/AFNetworking/AFHTTPSessionManager.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/AFNetworking/AFHTTPSessionManager.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/AFNetworking/AFNetworkActivityIndicatorManager.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/AFNetworking/AFNetworkReachabilityManager.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/AFNetworking/AFNetworkReachabilityManager.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/AFNetworking/AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/AFNetworking/AFNetworking.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/AFNetworking/AFSecurityPolicy.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/AFNetworking/AFSecurityPolicy.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/AFNetworking/AFURLConnectionOperation.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/AFNetworking/AFURLConnectionOperation.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/AFNetworking/AFURLRequestSerialization.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/AFNetworking/AFURLRequestSerialization.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/AFNetworking/AFURLResponseSerialization.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/AFNetworking/AFURLResponseSerialization.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/AFNetworking/AFURLSessionManager.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/AFNetworking/AFURLSessionManager.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/AFNetworking/UIActivityIndicatorView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/AFNetworking/UIAlertView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/AFNetworking/UIButton+AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/AFNetworking/UIImage+AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/AFNetworking/UIImageView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/AFNetworking/UIKit+AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/AFNetworking/UIProgressView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/AFNetworking/UIRefreshControl+AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h
--------------------------------------------------------------------------------
/Pods/Headers/Private/AFNetworking/UIWebView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/AFNetworking/AFHTTPRequestOperation.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/AFNetworking/AFHTTPRequestOperation.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/AFNetworking/AFHTTPRequestOperationManager.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/AFNetworking/AFHTTPRequestOperationManager.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/AFNetworking/AFHTTPSessionManager.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/AFNetworking/AFHTTPSessionManager.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/AFNetworking/AFNetworkActivityIndicatorManager.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/AFNetworking/AFNetworkReachabilityManager.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/AFNetworking/AFNetworkReachabilityManager.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/AFNetworking/AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/AFNetworking/AFNetworking.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/AFNetworking/AFSecurityPolicy.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/AFNetworking/AFSecurityPolicy.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/AFNetworking/AFURLConnectionOperation.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/AFNetworking/AFURLConnectionOperation.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/AFNetworking/AFURLRequestSerialization.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/AFNetworking/AFURLRequestSerialization.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/AFNetworking/AFURLResponseSerialization.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/AFNetworking/AFURLResponseSerialization.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/AFNetworking/AFURLSessionManager.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/AFNetworking/AFURLSessionManager.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/AFNetworking/UIActivityIndicatorView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/AFNetworking/UIAlertView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/AFNetworking/UIButton+AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/AFNetworking/UIImage+AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/AFNetworking/UIImageView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/AFNetworking/UIKit+AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/AFNetworking/UIProgressView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/AFNetworking/UIRefreshControl+AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h
--------------------------------------------------------------------------------
/Pods/Headers/Public/AFNetworking/UIWebView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | ../../../AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h
--------------------------------------------------------------------------------
/Pods/Manifest.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - AFNetworking (2.6.3):
3 | - AFNetworking/NSURLConnection (= 2.6.3)
4 | - AFNetworking/NSURLSession (= 2.6.3)
5 | - AFNetworking/Reachability (= 2.6.3)
6 | - AFNetworking/Security (= 2.6.3)
7 | - AFNetworking/Serialization (= 2.6.3)
8 | - AFNetworking/UIKit (= 2.6.3)
9 | - AFNetworking/NSURLConnection (2.6.3):
10 | - AFNetworking/Reachability
11 | - AFNetworking/Security
12 | - AFNetworking/Serialization
13 | - AFNetworking/NSURLSession (2.6.3):
14 | - AFNetworking/Reachability
15 | - AFNetworking/Security
16 | - AFNetworking/Serialization
17 | - AFNetworking/Reachability (2.6.3)
18 | - AFNetworking/Security (2.6.3)
19 | - AFNetworking/Serialization (2.6.3)
20 | - AFNetworking/UIKit (2.6.3):
21 | - AFNetworking/NSURLConnection
22 | - AFNetworking/NSURLSession
23 |
24 | DEPENDENCIES:
25 | - AFNetworking (~> 2.6.3)
26 |
27 | SPEC CHECKSUMS:
28 | AFNetworking: cb8d14a848e831097108418f5d49217339d4eb60
29 |
30 | COCOAPODS: 0.39.0
31 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/AFNetworking/AFNetworking-dummy.m:
--------------------------------------------------------------------------------
1 | #import
2 | @interface PodsDummy_AFNetworking : NSObject
3 | @end
4 | @implementation PodsDummy_AFNetworking
5 | @end
6 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/AFNetworking/AFNetworking-prefix.pch:
--------------------------------------------------------------------------------
1 | #ifdef __OBJC__
2 | #import
3 | #endif
4 |
5 | #ifndef TARGET_OS_IOS
6 | #define TARGET_OS_IOS TARGET_OS_IPHONE
7 | #endif
8 |
9 | #ifndef TARGET_OS_WATCH
10 | #define TARGET_OS_WATCH 0
11 | #endif
12 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/AFNetworking/AFNetworking.xcconfig:
--------------------------------------------------------------------------------
1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
2 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/AFNetworking" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking"
3 | OTHER_LDFLAGS = -framework "CoreGraphics" -framework "MobileCoreServices" -framework "Security" -framework "SystemConfiguration"
4 | PODS_ROOT = ${SRCROOT}
5 | SKIP_INSTALL = YES
--------------------------------------------------------------------------------
/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-frameworks.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -e
3 |
4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
6 |
7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}"
8 |
9 | install_framework()
10 | {
11 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then
12 | local source="${BUILT_PRODUCTS_DIR}/$1"
13 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then
14 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")"
15 | elif [ -r "$1" ]; then
16 | local source="$1"
17 | fi
18 |
19 | local destination="${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
20 |
21 | if [ -L "${source}" ]; then
22 | echo "Symlinked..."
23 | source="$(readlink "${source}")"
24 | fi
25 |
26 | # use filter instead of exclude so missing patterns dont' throw errors
27 | echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\""
28 | rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}"
29 |
30 | local basename
31 | basename="$(basename -s .framework "$1")"
32 | binary="${destination}/${basename}.framework/${basename}"
33 | if ! [ -r "$binary" ]; then
34 | binary="${destination}/${basename}"
35 | fi
36 |
37 | # Strip invalid architectures so "fat" simulator / device frameworks work on device
38 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then
39 | strip_invalid_archs "$binary"
40 | fi
41 |
42 | # Resign the code if required by the build settings to avoid unstable apps
43 | code_sign_if_enabled "${destination}/$(basename "$1")"
44 |
45 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7.
46 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then
47 | local swift_runtime_libs
48 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]})
49 | for lib in $swift_runtime_libs; do
50 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\""
51 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}"
52 | code_sign_if_enabled "${destination}/${lib}"
53 | done
54 | fi
55 | }
56 |
57 | # Signs a framework with the provided identity
58 | code_sign_if_enabled() {
59 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then
60 | # Use the current code_sign_identitiy
61 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}"
62 | echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements \"$1\""
63 | /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements "$1"
64 | fi
65 | }
66 |
67 | # Strip invalid architectures
68 | strip_invalid_archs() {
69 | binary="$1"
70 | # Get architectures for current file
71 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)"
72 | stripped=""
73 | for arch in $archs; do
74 | if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then
75 | # Strip non-valid architectures in-place
76 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1
77 | stripped="$stripped $arch"
78 | fi
79 | done
80 | if [[ "$stripped" ]]; then
81 | echo "Stripped $binary of architectures:$stripped"
82 | fi
83 | }
84 |
85 |
--------------------------------------------------------------------------------
/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 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
62 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
63 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then
64 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
65 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
66 | fi
67 | rm -f "$RESOURCES_TO_COPY"
68 |
69 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ]
70 | then
71 | case "${TARGETED_DEVICE_FAMILY}" in
72 | 1,2)
73 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone"
74 | ;;
75 | 1)
76 | TARGET_DEVICE_ARGS="--target-device iphone"
77 | ;;
78 | 2)
79 | TARGET_DEVICE_ARGS="--target-device ipad"
80 | ;;
81 | *)
82 | TARGET_DEVICE_ARGS="--target-device mac"
83 | ;;
84 | esac
85 |
86 | # Find all other xcassets (this unfortunately includes those of path pods and other targets).
87 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d)
88 | while read line; do
89 | if [[ $line != "`realpath $PODS_ROOT`*" ]]; then
90 | XCASSET_FILES+=("$line")
91 | fi
92 | done <<<"$OTHER_XCASSETS"
93 |
94 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${IPHONEOS_DEPLOYMENT_TARGET}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
95 | fi
96 |
--------------------------------------------------------------------------------
/Pods/Target Support Files/Pods/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"AFNetworking" -framework "CoreGraphics" -framework "MobileCoreServices" -framework "Security" -framework "SystemConfiguration"
5 | 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"AFNetworking" -framework "CoreGraphics" -framework "MobileCoreServices" -framework "Security" -framework "SystemConfiguration"
5 | PODS_ROOT = ${SRCROOT}/Pods
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # iOS-NetworkRequest
2 | iOS进行网络请求的示例代码
3 |
--------------------------------------------------------------------------------