├── .gitignore
├── AwesomeTips.xcodeproj
├── project.pbxproj
└── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ └── IDEWorkspaceChecks.plist
├── AwesomeTips
├── AppDelegate.h
├── AppDelegate.m
├── Assets.xcassets
│ ├── AppIcon.appiconset
│ │ ├── AppIcon-1024.png
│ │ ├── AppIcon-20@2x.png
│ │ ├── AppIcon-20@3x.png
│ │ ├── AppIcon-29@2x.png
│ │ ├── AppIcon-29@3x.png
│ │ ├── AppIcon-40@2x.png
│ │ ├── AppIcon-40@3x.png
│ │ ├── AppIcon-60@2x.png
│ │ ├── AppIcon-60@3x.png
│ │ └── Contents.json
│ └── Contents.json
├── Base.lproj
│ └── LaunchScreen.storyboard
├── Business
│ ├── Controllers
│ │ ├── ATMainViewController.h
│ │ ├── ATMainViewController.m
│ │ ├── ATSearchViewController.h
│ │ └── ATSearchViewController.m
│ ├── Models
│ │ ├── ATFeedItemModel.h
│ │ └── ATFeedItemModel.m
│ └── Views
│ │ ├── ATFeedTableViewCell.h
│ │ └── ATFeedTableViewCell.m
├── Common
│ ├── ATNetworkManager.h
│ └── ATNetworkManager.m
├── Info.plist
├── main.m
└── tips.kangzubin.com.cer
├── AwesomeTipsTests
├── AwesomeTipsTests.m
└── Info.plist
├── AwesomeTipsUITests
├── AwesomeTipsUITests.m
└── Info.plist
├── Cartfile
├── Cartfile.resolved
├── Carthage
└── Build
│ ├── .AFNetworking.version
│ ├── .XMNetworking.version
│ └── iOS
│ ├── 15D0C0EB-A438-358E-B0B7-6FBF2B8800CA.bcsymbolmap
│ ├── 1CB315E7-C983-3168-ABC7-BD03955A8D27.bcsymbolmap
│ ├── 8EC16674-A265-3703-BFD9-2DD6BB633724.bcsymbolmap
│ ├── AFNetworking.framework
│ ├── AFNetworking
│ ├── Headers
│ │ ├── AFAutoPurgingImageCache.h
│ │ ├── AFCompatibilityMacros.h
│ │ ├── AFHTTPSessionManager.h
│ │ ├── AFImageDownloader.h
│ │ ├── AFNetworkActivityIndicatorManager.h
│ │ ├── AFNetworkReachabilityManager.h
│ │ ├── AFNetworking.h
│ │ ├── AFSecurityPolicy.h
│ │ ├── AFURLRequestSerialization.h
│ │ ├── AFURLResponseSerialization.h
│ │ ├── AFURLSessionManager.h
│ │ ├── UIActivityIndicatorView+AFNetworking.h
│ │ ├── UIButton+AFNetworking.h
│ │ ├── UIImage+AFNetworking.h
│ │ ├── UIImageView+AFNetworking.h
│ │ ├── UIProgressView+AFNetworking.h
│ │ ├── UIRefreshControl+AFNetworking.h
│ │ └── UIWebView+AFNetworking.h
│ ├── Info.plist
│ └── Modules
│ │ └── module.modulemap
│ ├── DA94A0AD-AAE3-33C2-A165-29B6322F3C2C.bcsymbolmap
│ └── XMNetworking.framework
│ ├── Headers
│ ├── XMCenter.h
│ ├── XMConst.h
│ ├── XMEngine.h
│ ├── XMNetworking.h
│ └── XMRequest.h
│ ├── Info.plist
│ ├── Modules
│ └── module.modulemap
│ └── XMNetworking
├── LICENSE
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4 |
5 | ## Build generated
6 | build/
7 | DerivedData/
8 |
9 | ## Various settings
10 | *.pbxuser
11 | !default.pbxuser
12 | *.mode1v3
13 | !default.mode1v3
14 | *.mode2v3
15 | !default.mode2v3
16 | *.perspectivev3
17 | !default.perspectivev3
18 | xcuserdata/
19 |
20 | ## Other
21 | *.moved-aside
22 | *.xccheckout
23 | *.xcscmblueprint
24 |
25 | ## Obj-C/Swift specific
26 | *.hmap
27 | *.ipa
28 | *.dSYM.zip
29 | *.dSYM
30 |
31 | # CocoaPods
32 | #
33 | # We recommend against adding the Pods directory to your .gitignore. However
34 | # you should judge for yourself, the pros and cons are mentioned at:
35 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
36 | #
37 | # Pods/
38 |
39 | # Carthage
40 | #
41 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
42 |
43 | Carthage/Checkouts
44 | !Carthage/Build
45 |
46 | # fastlane
47 | #
48 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
49 | # screenshots whenever they are needed.
50 | # For more information about the recommended setup visit:
51 | # https://docs.fastlane.tools/best-practices/source-control/#source-control
52 |
53 | fastlane/report.xml
54 | fastlane/Preview.html
55 | fastlane/screenshots/**/*.png
56 | fastlane/test_output
57 |
58 | # Code Injection
59 | #
60 | # After new code Injection tools there's a generated folder /iOSInjectionProject
61 | # https://github.com/johnno1962/injectionforxcode
62 |
63 | iOSInjectionProject/
64 |
--------------------------------------------------------------------------------
/AwesomeTips.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/AwesomeTips.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/AwesomeTips/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // AwesomeTips
4 | //
5 | // Created by Zubin Kang on 2018/5/15.
6 | // Copyright © 2018 KANGZUBIN. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/AwesomeTips/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // AwesomeTips
4 | //
5 | // Created by Zubin Kang on 2018/5/15.
6 | // Copyright © 2018 KANGZUBIN. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 | #import "ATNetworkManager.h"
11 | #import "ATMainViewController.h"
12 |
13 | @interface AppDelegate ()
14 |
15 | @end
16 |
17 | @implementation AppDelegate
18 |
19 |
20 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
21 | // Override point for customization after application launch.
22 |
23 | [ATNetworkManager setup];
24 | ATMainViewController *mainViewController = [[ATMainViewController alloc] initWithStyle:UITableViewStylePlain];
25 | UINavigationController *rootNavigationController = [[UINavigationController alloc] initWithRootViewController:mainViewController];
26 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
27 | self.window.rootViewController = rootNavigationController;
28 | [self.window makeKeyAndVisible];
29 |
30 | return YES;
31 | }
32 |
33 |
34 | - (void)applicationWillResignActive:(UIApplication *)application {
35 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
36 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
37 | }
38 |
39 |
40 | - (void)applicationDidEnterBackground:(UIApplication *)application {
41 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
42 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
43 | }
44 |
45 |
46 | - (void)applicationWillEnterForeground:(UIApplication *)application {
47 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
48 | }
49 |
50 |
51 | - (void)applicationDidBecomeActive:(UIApplication *)application {
52 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
53 | }
54 |
55 |
56 | - (void)applicationWillTerminate:(UIApplication *)application {
57 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
58 | }
59 |
60 |
61 | @end
62 |
--------------------------------------------------------------------------------
/AwesomeTips/Assets.xcassets/AppIcon.appiconset/AppIcon-1024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awesome-tips/awesome-tips-ios-app/78eec7c0cb5b2c561f95b0016eb832e22f22b2ff/AwesomeTips/Assets.xcassets/AppIcon.appiconset/AppIcon-1024.png
--------------------------------------------------------------------------------
/AwesomeTips/Assets.xcassets/AppIcon.appiconset/AppIcon-20@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awesome-tips/awesome-tips-ios-app/78eec7c0cb5b2c561f95b0016eb832e22f22b2ff/AwesomeTips/Assets.xcassets/AppIcon.appiconset/AppIcon-20@2x.png
--------------------------------------------------------------------------------
/AwesomeTips/Assets.xcassets/AppIcon.appiconset/AppIcon-20@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awesome-tips/awesome-tips-ios-app/78eec7c0cb5b2c561f95b0016eb832e22f22b2ff/AwesomeTips/Assets.xcassets/AppIcon.appiconset/AppIcon-20@3x.png
--------------------------------------------------------------------------------
/AwesomeTips/Assets.xcassets/AppIcon.appiconset/AppIcon-29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awesome-tips/awesome-tips-ios-app/78eec7c0cb5b2c561f95b0016eb832e22f22b2ff/AwesomeTips/Assets.xcassets/AppIcon.appiconset/AppIcon-29@2x.png
--------------------------------------------------------------------------------
/AwesomeTips/Assets.xcassets/AppIcon.appiconset/AppIcon-29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awesome-tips/awesome-tips-ios-app/78eec7c0cb5b2c561f95b0016eb832e22f22b2ff/AwesomeTips/Assets.xcassets/AppIcon.appiconset/AppIcon-29@3x.png
--------------------------------------------------------------------------------
/AwesomeTips/Assets.xcassets/AppIcon.appiconset/AppIcon-40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awesome-tips/awesome-tips-ios-app/78eec7c0cb5b2c561f95b0016eb832e22f22b2ff/AwesomeTips/Assets.xcassets/AppIcon.appiconset/AppIcon-40@2x.png
--------------------------------------------------------------------------------
/AwesomeTips/Assets.xcassets/AppIcon.appiconset/AppIcon-40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awesome-tips/awesome-tips-ios-app/78eec7c0cb5b2c561f95b0016eb832e22f22b2ff/AwesomeTips/Assets.xcassets/AppIcon.appiconset/AppIcon-40@3x.png
--------------------------------------------------------------------------------
/AwesomeTips/Assets.xcassets/AppIcon.appiconset/AppIcon-60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awesome-tips/awesome-tips-ios-app/78eec7c0cb5b2c561f95b0016eb832e22f22b2ff/AwesomeTips/Assets.xcassets/AppIcon.appiconset/AppIcon-60@2x.png
--------------------------------------------------------------------------------
/AwesomeTips/Assets.xcassets/AppIcon.appiconset/AppIcon-60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awesome-tips/awesome-tips-ios-app/78eec7c0cb5b2c561f95b0016eb832e22f22b2ff/AwesomeTips/Assets.xcassets/AppIcon.appiconset/AppIcon-60@3x.png
--------------------------------------------------------------------------------
/AwesomeTips/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "20x20",
5 | "idiom" : "iphone",
6 | "filename" : "AppIcon-20@2x.png",
7 | "scale" : "2x"
8 | },
9 | {
10 | "size" : "20x20",
11 | "idiom" : "iphone",
12 | "filename" : "AppIcon-20@3x.png",
13 | "scale" : "3x"
14 | },
15 | {
16 | "size" : "29x29",
17 | "idiom" : "iphone",
18 | "filename" : "AppIcon-29@2x.png",
19 | "scale" : "2x"
20 | },
21 | {
22 | "size" : "29x29",
23 | "idiom" : "iphone",
24 | "filename" : "AppIcon-29@3x.png",
25 | "scale" : "3x"
26 | },
27 | {
28 | "size" : "40x40",
29 | "idiom" : "iphone",
30 | "filename" : "AppIcon-40@2x.png",
31 | "scale" : "2x"
32 | },
33 | {
34 | "size" : "40x40",
35 | "idiom" : "iphone",
36 | "filename" : "AppIcon-40@3x.png",
37 | "scale" : "3x"
38 | },
39 | {
40 | "size" : "60x60",
41 | "idiom" : "iphone",
42 | "filename" : "AppIcon-60@2x.png",
43 | "scale" : "2x"
44 | },
45 | {
46 | "size" : "60x60",
47 | "idiom" : "iphone",
48 | "filename" : "AppIcon-60@3x.png",
49 | "scale" : "3x"
50 | },
51 | {
52 | "size" : "1024x1024",
53 | "idiom" : "ios-marketing",
54 | "filename" : "AppIcon-1024.png",
55 | "scale" : "1x"
56 | }
57 | ],
58 | "info" : {
59 | "version" : 1,
60 | "author" : "xcode"
61 | }
62 | }
--------------------------------------------------------------------------------
/AwesomeTips/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/AwesomeTips/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 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/AwesomeTips/Business/Controllers/ATMainViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ATMainViewController.h
3 | // AwesomeTips
4 | //
5 | // Created by Zubin Kang on 2018/5/15.
6 | // Copyright © 2018 KANGZUBIN. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ATMainViewController : UITableViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/AwesomeTips/Business/Controllers/ATMainViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ATMainViewController.m
3 | // AwesomeTips
4 | //
5 | // Created by Zubin Kang on 2018/5/15.
6 | // Copyright © 2018 KANGZUBIN. All rights reserved.
7 | //
8 |
9 | #import "ATMainViewController.h"
10 | #import "ATSearchViewController.h"
11 | #import "ATFeedItemModel.h"
12 | #import "ATFeedTableViewCell.h"
13 | #import "ATNetworkManager.h"
14 | #import
15 |
16 | @interface ATMainViewController ()
17 |
18 | @property (nonatomic, strong) UIView *tableFooterView;
19 | @property (nonatomic, strong) UIActivityIndicatorView *loadingMoreIndicatorView;
20 | @property (nonatomic, strong) UISearchController *searchController;
21 |
22 | @property (nonatomic, assign) NSUInteger pageNum;
23 | @property (nonatomic, assign, getter=isHasMoreData) BOOL hasMoreData;
24 | @property (nonatomic, assign, getter=isLoadingData) BOOL loadingData;
25 | @property (nonatomic, strong) NSMutableArray *dataList;
26 |
27 | @end
28 |
29 | @implementation ATMainViewController
30 |
31 | - (void)viewDidLoad {
32 | [super viewDidLoad];
33 | [self at_setupViews];
34 | [self at_getFeedListFromNet];
35 | }
36 |
37 | #pragma mark - Layout
38 |
39 | - (void)at_setupViews {
40 | self.title = @"知识小集";
41 | self.definesPresentationContext = YES;
42 | self.view.backgroundColor = [UIColor whiteColor];
43 | self.refreshControl = [[UIRefreshControl alloc] init];
44 | if (@available(iOS 11.0, *)) {
45 | self.navigationController.navigationBar.prefersLargeTitles = YES;
46 | self.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeAutomatic;
47 | self.navigationItem.searchController = self.searchController;
48 | self.navigationItem.hidesSearchBarWhenScrolling = YES;
49 | } else {
50 | self.tableView.tableHeaderView = self.searchController.searchBar;
51 | }
52 | [self at_cleanTableViewFooter];
53 | [self.tableView setEstimatedRowHeight:[ATFeedTableViewCell cellHeight]];
54 | [self.tableView registerClass:[ATFeedTableViewCell class] forCellReuseIdentifier:[ATFeedTableViewCell reuseIdentifier]];
55 | [self.refreshControl addTarget:self action:@selector(at_shouldRefreshAction:) forControlEvents:UIControlEventValueChanged];
56 | }
57 |
58 | #pragma mark - UITableViewDelegate
59 |
60 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
61 | return [ATFeedTableViewCell cellHeight];
62 | }
63 |
64 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
65 | [tableView deselectRowAtIndexPath:indexPath animated:YES];
66 | SFSafariViewController *sfViewController = [self at_getDetailViewControllerAtIndexPath:indexPath];
67 | if (sfViewController) {
68 | [self presentViewController:sfViewController animated:YES completion:nil];
69 | }
70 | }
71 |
72 | #pragma mark - UITableViewDataSource
73 |
74 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
75 | return self.dataList.count;
76 | }
77 |
78 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
79 | if (indexPath.row < self.dataList.count) {
80 | ATFeedItemModel *model = self.dataList[indexPath.row];
81 | ATFeedTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[ATFeedTableViewCell reuseIdentifier] forIndexPath:indexPath];
82 | [cell layoutUIWithModel:model];
83 | // 为 Cell 添加 3D Touch 支持
84 | if (self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable) {
85 | [self registerForPreviewingWithDelegate:self sourceView:cell];
86 | }
87 | return cell;
88 | }
89 | return [UITableViewCell new];
90 | }
91 |
92 | #pragma mark - UIScrollViewDelegate
93 |
94 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
95 | CGFloat contentOffsetY = scrollView.contentOffset.y;
96 | CGFloat contentHeight = scrollView.contentSize.height;
97 | CGFloat delta = contentOffsetY + self.view.frame.size.height;
98 | if (self.view.frame.size.height == 812.0f) {
99 | // iPhone X 减去底部安全区域 34.0f
100 | delta -= 34.0f;
101 | }
102 | if (delta + 10.0f >= contentHeight && contentHeight > 0) {
103 | // 触发上拉加载更多
104 | if (self.isLoadingData || !self.hasMoreData) {
105 | return;
106 | }
107 | self.pageNum += 1;
108 | [self.loadingMoreIndicatorView startAnimating];
109 | [self at_getFeedListFromNet];
110 | }
111 | }
112 |
113 | #pragma mark - UIViewControllerPreviewingDelegate
114 |
115 | // 3D Touch 预览模式
116 | - (nullable UIViewController *)previewingContext:(id )previewingContext viewControllerForLocation:(CGPoint)location {
117 | NSIndexPath *indexPath = [self.tableView indexPathForCell:(UITableViewCell *)[previewingContext sourceView]];
118 | return [self at_getDetailViewControllerAtIndexPath:indexPath];
119 | }
120 |
121 | // 3D Touch 继续按压进入
122 | - (void)previewingContext:(id )previewingContext commitViewController:(UIViewController *)viewControllerToCommit {
123 | [self presentViewController:viewControllerToCommit animated:YES completion:nil];
124 | }
125 |
126 | #pragma mark - Private Methods
127 |
128 | - (SFSafariViewController *)at_getDetailViewControllerAtIndexPath:(NSIndexPath *)indexPath {
129 | if (indexPath.row < self.dataList.count) {
130 | ATFeedItemModel *model = self.dataList[indexPath.row];
131 | if (model.url.length > 0) {
132 | NSURL *url = [NSURL URLWithString:model.url];
133 | SFSafariViewController *sfViewController = [[SFSafariViewController alloc] initWithURL:url];
134 | if (@available(iOS 11.0, *)) {
135 | sfViewController.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeNever;
136 | sfViewController.dismissButtonStyle = SFSafariViewControllerDismissButtonStyleClose;
137 | }
138 | return sfViewController;
139 | }
140 | }
141 | return nil;
142 | }
143 |
144 | - (void)at_shouldRefreshAction:(UIRefreshControl *)sender {
145 | if (self.isLoadingData) {
146 | [self.refreshControl endRefreshing];
147 | return;
148 | }
149 | self.pageNum = 1;
150 | self.hasMoreData = NO;
151 | [self at_cleanTableViewFooter];
152 | [self at_getFeedListFromNet];
153 | }
154 |
155 | - (void)at_didEnRefreshing {
156 | self.loadingData = NO;
157 | // 延迟 1 秒关闭刷新 UI
158 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
159 | [self.refreshControl endRefreshing];
160 | if (self.loadingMoreIndicatorView.isAnimating) {
161 | [self.loadingMoreIndicatorView stopAnimating];
162 | }
163 | });
164 | }
165 |
166 | - (void)at_cleanTableViewFooter {
167 | [self.tableView setTableFooterView:[UIView new]];
168 | }
169 |
170 | - (void)at_showTableViewFooter {
171 | if (self.tableView.tableFooterView != self.tableFooterView) {
172 | self.tableView.tableFooterView = self.tableFooterView;
173 | }
174 | }
175 |
176 | #pragma mark - Network
177 |
178 | - (void)at_getFeedListFromNet {
179 | if (self.isLoadingData) {
180 | return;
181 | }
182 | self.loadingData = YES;
183 | if (self.pageNum <= 0) {
184 | self.pageNum = 1;
185 | }
186 | [XMCenter sendRequest:^(XMRequest * _Nonnull request) {
187 | request.api = @"feed/list";
188 | request.cached = YES;
189 | request.httpMethod = kXMHTTPMethodGET;
190 | request.parameters = @{@"page": @(self.pageNum)};
191 | } onSuccess:^(id _Nullable responseObject) {
192 | // 上层已经过滤过错误数据,这里 responseObject 一定是成功且有数据的
193 | if (self.pageNum == 1) {
194 | [self.dataList removeAllObjects];
195 | }
196 | NSArray *array = responseObject[@"feeds"];
197 | if ([array isKindOfClass:[NSArray class]] && [array count] > 0) {
198 | [array enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
199 | ATFeedItemModel *model = [ATFeedItemModel modelWithDictionary:obj];
200 | if (model) {
201 | [self.dataList addObject:model];
202 | }
203 | }];
204 | self.hasMoreData = YES;
205 | [self at_showTableViewFooter];
206 | } else {
207 | self.hasMoreData = NO;
208 | [self at_cleanTableViewFooter];
209 | }
210 | [self.tableView reloadData];
211 | } onFailure:^(NSError * _Nullable error) {
212 | NSLog(@"[Net Error]: %@", error.localizedDescription);
213 | } onFinished:^(id _Nullable responseObject, NSError * _Nullable error) {
214 | [self at_didEnRefreshing];
215 | }];
216 | }
217 |
218 | #pragma mark - Getters
219 |
220 | - (UISearchController *)searchController {
221 | if (!_searchController) {
222 | ATSearchViewController *searchViewController = [[ATSearchViewController alloc] init];
223 | _searchController = [[UISearchController alloc] initWithSearchResultsController:searchViewController];
224 | _searchController.searchBar.placeholder = @"搜索";
225 | _searchController.searchResultsUpdater = searchViewController;
226 | }
227 | return _searchController;
228 | }
229 |
230 | - (UIView *)tableFooterView {
231 | if (!_tableFooterView) {
232 | _tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 49.0f)];
233 | _tableFooterView.backgroundColor = [UIColor clearColor];
234 | [_tableFooterView addSubview:self.loadingMoreIndicatorView];
235 | self.loadingMoreIndicatorView.center = _tableFooterView.center;
236 | }
237 | return _tableFooterView;
238 | }
239 |
240 | - (UIActivityIndicatorView *)loadingMoreIndicatorView {
241 | if (!_loadingMoreIndicatorView) {
242 | _loadingMoreIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
243 | }
244 | return _loadingMoreIndicatorView;
245 | }
246 |
247 | - (NSMutableArray *)dataList {
248 | if (!_dataList) {
249 | _dataList = [NSMutableArray array];
250 | }
251 | return _dataList;
252 | }
253 |
254 | - (void)didReceiveMemoryWarning {
255 | [super didReceiveMemoryWarning];
256 | // Dispose of any resources that can be recreated.
257 | }
258 |
259 | @end
260 |
--------------------------------------------------------------------------------
/AwesomeTips/Business/Controllers/ATSearchViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ATSearchViewController.h
3 | // AwesomeTips
4 | //
5 | // Created by Zubin Kang on 2018/5/15.
6 | // Copyright © 2018 KANGZUBIN. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ATSearchViewController : UITableViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/AwesomeTips/Business/Controllers/ATSearchViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ATSearchViewController.m
3 | // AwesomeTips
4 | //
5 | // Created by Zubin Kang on 2018/5/15.
6 | // Copyright © 2018 KANGZUBIN. All rights reserved.
7 | //
8 |
9 | #import "ATSearchViewController.h"
10 | #import "ATFeedItemModel.h"
11 | #import "ATFeedTableViewCell.h"
12 | #import "ATNetworkManager.h"
13 | #import
14 |
15 | @interface ATSearchViewController ()
16 |
17 | @property (nonatomic, copy) NSString *searchKeyword;
18 | @property (nonatomic, assign, getter=isLoadingSearchData) BOOL loadingSearchData;
19 | @property (nonatomic, strong) NSMutableArray *searchDataList;
20 |
21 | @end
22 |
23 | @implementation ATSearchViewController
24 |
25 | - (void)viewDidLoad {
26 | [super viewDidLoad];
27 | [self xm_setupViews];
28 | }
29 |
30 | #pragma mark - Layout
31 |
32 | - (void)xm_setupViews {
33 | [self.tableView setTableFooterView:[UIView new]];
34 | [self.tableView setEstimatedRowHeight:[ATFeedTableViewCell cellHeight]];
35 | [self.tableView registerClass:[ATFeedTableViewCell class] forCellReuseIdentifier:[ATFeedTableViewCell reuseIdentifier]];
36 | }
37 |
38 | #pragma mark - UITableViewDelegate
39 |
40 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
41 | return [ATFeedTableViewCell cellHeight];
42 | }
43 |
44 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
45 | [tableView deselectRowAtIndexPath:indexPath animated:YES];
46 | SFSafariViewController *sfViewController = [self xm_getDetailViewControllerAtIndexPath:indexPath];
47 | if (sfViewController) {
48 | [self presentViewController:sfViewController animated:YES completion:nil];
49 | }
50 | }
51 |
52 | #pragma mark - UITableViewDataSource
53 |
54 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
55 | return self.searchDataList.count;
56 | }
57 |
58 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
59 | if (indexPath.row < self.searchDataList.count) {
60 | ATFeedItemModel *model = self.searchDataList[indexPath.row];
61 | ATFeedTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[ATFeedTableViewCell reuseIdentifier] forIndexPath:indexPath];
62 | [cell layoutUIWithModel:model];
63 | return cell;
64 | }
65 | return [UITableViewCell new];
66 | }
67 |
68 | #pragma mark - UISearchResultsUpdating
69 |
70 | - (void)updateSearchResultsForSearchController:(UISearchController *)searchController {
71 | NSString *newKeyword = [searchController.searchBar.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
72 | if ([self.searchKeyword isEqualToString:newKeyword]) {
73 | return;
74 | }
75 | self.searchKeyword = newKeyword;
76 | if (self.searchKeyword.length > 0) {
77 | [self xm_searchFeedListFromNet];
78 | }
79 | }
80 |
81 | #pragma mark - Private Methods
82 |
83 | - (SFSafariViewController *)xm_getDetailViewControllerAtIndexPath:(NSIndexPath *)indexPath {
84 | if (indexPath.row < self.searchDataList.count) {
85 | ATFeedItemModel *model = self.searchDataList[indexPath.row];
86 | if (model.url.length > 0) {
87 | NSURL *url = [NSURL URLWithString:model.url];
88 | SFSafariViewController *sfViewController = [[SFSafariViewController alloc] initWithURL:url];
89 | if (@available(iOS 11.0, *)) {
90 | sfViewController.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeNever;
91 | sfViewController.dismissButtonStyle = SFSafariViewControllerDismissButtonStyleClose;
92 | }
93 | return sfViewController;
94 | }
95 | }
96 | return nil;
97 | }
98 |
99 | #pragma mark - Network
100 |
101 | - (void)xm_searchFeedListFromNet {
102 | if (self.searchKeyword.length == 0) {
103 | return;
104 | }
105 | if (self.isLoadingSearchData) {
106 | return;
107 | }
108 | self.loadingSearchData = YES;
109 | [XMCenter sendRequest:^(XMRequest * _Nonnull request) {
110 | request.api = @"feed/search";
111 | request.httpMethod = kXMHTTPMethodGET;
112 | request.parameters = @{@"key": self.searchKeyword};
113 | } onSuccess:^(id _Nullable responseObject) {
114 | // 上层已经过滤过错误数据,这里 responseObject 一定是成功且有数据的
115 | [self.searchDataList removeAllObjects];
116 | NSArray *array = responseObject[@"feeds"];
117 | if ([array isKindOfClass:[NSArray class]] && [array count] > 0) {
118 | [array enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
119 | ATFeedItemModel *model = [ATFeedItemModel modelWithDictionary:obj];
120 | if (model) {
121 | [self.searchDataList addObject:model];
122 | }
123 | }];
124 | }
125 | [self.tableView reloadData];
126 | } onFailure:^(NSError * _Nullable error) {
127 | NSLog(@"[Net Error]: %@", error.localizedDescription);
128 | } onFinished:^(id _Nullable responseObject, NSError * _Nullable error) {
129 | self.loadingSearchData = NO;
130 | }];
131 | }
132 |
133 | #pragma mark - Getters
134 |
135 | - (NSMutableArray *)searchDataList {
136 | if (!_searchDataList) {
137 | _searchDataList = [NSMutableArray array];
138 | }
139 | return _searchDataList;
140 | }
141 |
142 | - (void)didReceiveMemoryWarning {
143 | [super didReceiveMemoryWarning];
144 | // Dispose of any resources that can be recreated.
145 | }
146 |
147 | @end
148 |
--------------------------------------------------------------------------------
/AwesomeTips/Business/Models/ATFeedItemModel.h:
--------------------------------------------------------------------------------
1 | //
2 | // ATFeedItemModel.h
3 | // AwesomeTips
4 | //
5 | // Created by Zubin Kang on 2018/5/15.
6 | // Copyright © 2018 KANGZUBIN. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ATFeedItemModel : NSObject
12 |
13 | @property (nonatomic, copy) NSString *fid;
14 | @property (nonatomic, copy) NSString *author;
15 | @property (nonatomic, copy) NSString *title;
16 | @property (nonatomic, copy) NSString *url;
17 | @property (nonatomic, copy) NSString *postdate;
18 | @property (nonatomic, assign) NSInteger platform;
19 | @property (nonatomic, copy, readonly) NSString *platformString;
20 |
21 | + (instancetype)modelWithDictionary:(NSDictionary *)dictionary;
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/AwesomeTips/Business/Models/ATFeedItemModel.m:
--------------------------------------------------------------------------------
1 | //
2 | // ATFeedItemModel.m
3 | // AwesomeTips
4 | //
5 | // Created by Zubin Kang on 2018/5/15.
6 | // Copyright © 2018 KANGZUBIN. All rights reserved.
7 | //
8 |
9 | #import "ATFeedItemModel.h"
10 |
11 | @implementation ATFeedItemModel
12 |
13 | + (instancetype)modelWithDictionary:(NSDictionary *)dictionary {
14 | if ([dictionary isKindOfClass:[NSDictionary class]] && [[dictionary allKeys] count] > 0) {
15 | ATFeedItemModel *model = [[ATFeedItemModel alloc] init];
16 | model.fid = [self at_asssignEmptyString:dictionary[@"fid"]];
17 | model.author = [self at_asssignEmptyString:dictionary[@"author"]];
18 | model.title = [self at_asssignEmptyString:dictionary[@"title"]];
19 | model.url = [self at_asssignEmptyString:dictionary[@"url"]];
20 | model.postdate = [self at_asssignEmptyString:dictionary[@"postdate"]];
21 | model.platform = [dictionary[@"platform"] integerValue];
22 | return model;
23 | }
24 | return nil;
25 | }
26 |
27 | + (NSString *)at_asssignEmptyString:(NSString *)string {
28 | if (string == nil) {
29 | return @"";
30 | }
31 |
32 | if ((NSNull *)string == [NSNull null]) {
33 | return @"";
34 | }
35 |
36 | if ([string isKindOfClass:[NSNumber class]]) {
37 | return [NSString stringWithFormat:@"%@", string];;
38 | }
39 |
40 | if (![string isKindOfClass:[NSString class]]) {
41 | return @"";
42 | }
43 |
44 | if ([string isEqualToString:@""]) {
45 | return @"";
46 | }
47 | if ([string isEqualToString:@"(null)"]) {
48 | return @"";
49 | }
50 | if ([string isEqualToString:@"null"]) {
51 | return @"";
52 | }
53 |
54 | return string;
55 | }
56 |
57 | - (NSString *)platformString {
58 | switch (self.platform) {
59 | case 0:
60 | return @"微博";
61 | case 1:
62 | return @"公众号";
63 | case 2:
64 | return @"GitHub";
65 | case 3:
66 | return @"Medium";
67 | default:
68 | return @"未知";
69 | }
70 | }
71 |
72 | @end
73 |
--------------------------------------------------------------------------------
/AwesomeTips/Business/Views/ATFeedTableViewCell.h:
--------------------------------------------------------------------------------
1 | //
2 | // ATFeedTableViewCell.h
3 | // AwesomeTips
4 | //
5 | // Created by Zubin Kang on 2018/5/15.
6 | // Copyright © 2018 KANGZUBIN. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class ATFeedItemModel;
12 |
13 | @interface ATFeedTableViewCell : UITableViewCell
14 |
15 | - (void)layoutUIWithModel:(ATFeedItemModel *)model;
16 |
17 | + (CGFloat)cellHeight;
18 | + (NSString *)reuseIdentifier;
19 |
20 | @end
21 |
--------------------------------------------------------------------------------
/AwesomeTips/Business/Views/ATFeedTableViewCell.m:
--------------------------------------------------------------------------------
1 | //
2 | // ATFeedTableViewCell.m
3 | // AwesomeTips
4 | //
5 | // Created by Zubin Kang on 2018/5/15.
6 | // Copyright © 2018 KANGZUBIN. All rights reserved.
7 | //
8 |
9 | #import "ATFeedTableViewCell.h"
10 | #import "ATFeedItemModel.h"
11 |
12 | @implementation ATFeedTableViewCell
13 |
14 | - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
15 | self = [super initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:reuseIdentifier];
16 | if (self) {
17 | self.textLabel.numberOfLines = 2;
18 | self.textLabel.textColor = [UIColor darkGrayColor];
19 | self.detailTextLabel.textColor = [UIColor lightGrayColor];
20 | }
21 | return self;
22 | }
23 |
24 | - (void)layoutUIWithModel:(ATFeedItemModel *)model {
25 | self.textLabel.text = model.title;
26 | self.detailTextLabel.text = [NSString stringWithFormat:@"%@ @%@ · %@", model.postdate, model.author, model.platformString];
27 | }
28 |
29 | - (void)awakeFromNib {
30 | [super awakeFromNib];
31 | // Initialization code
32 | }
33 |
34 | - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
35 | [super setSelected:selected animated:animated];
36 |
37 | // Configure the view for the selected state
38 | }
39 |
40 | + (CGFloat)cellHeight {
41 | return 80.0f;
42 | }
43 |
44 | + (NSString *)reuseIdentifier {
45 | return NSStringFromClass(self.class);
46 | }
47 |
48 | @end
49 |
--------------------------------------------------------------------------------
/AwesomeTips/Common/ATNetworkManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // ATNetworkManager.h
3 | // AwesomeTips
4 | //
5 | // Created by Zubin Kang on 2018/5/15.
6 | // Copyright © 2018 KANGZUBIN. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | typedef NS_ENUM(NSInteger, ATNetworkErrorCode) {
13 | kATSuccessCode = 0, //!< 接口请求成功
14 | kATErrorCode = 1, //!< 接口请求失败
15 | kATUnknownCode = -1, //!< 未知错误
16 | };
17 |
18 | @interface XMRequest (ATUtils)
19 | @property (nonatomic, assign, getter=isCached) BOOL cached; //!< 当前请求是否要缓存,默认为 NO
20 | @end
21 |
22 | #pragma mark -
23 |
24 | @interface ATNetworkManager : NSObject
25 |
26 | /**
27 | 初始化网络配置
28 | */
29 | + (void)setup;
30 |
31 | @end
32 |
--------------------------------------------------------------------------------
/AwesomeTips/Common/ATNetworkManager.m:
--------------------------------------------------------------------------------
1 | //
2 | // ATNetworkManager.m
3 | // AwesomeTips
4 | //
5 | // Created by Zubin Kang on 2018/5/15.
6 | // Copyright © 2018 KANGZUBIN. All rights reserved.
7 | //
8 |
9 | #import "ATNetworkManager.h"
10 | #import
11 |
12 | #define AWESOME_TIPS_API_HOST @"https://tips.kangzubin.com/api/"
13 |
14 | NSString * const ATNetworkErrorDomain = @"ATNetworkErrorDomain";
15 |
16 | static NSError * ATNetworkErrorGenerator(NSInteger code, NSString *msg) {
17 | NSDictionary *userInfo = @{NSLocalizedDescriptionKey: msg.length > 0 ? msg : @""};
18 | NSError * __autoreleasing error = [NSError errorWithDomain:ATNetworkErrorDomain code:code userInfo:userInfo];
19 | return error;
20 | }
21 |
22 | @implementation XMRequest (ATUtils)
23 |
24 | - (BOOL)isCached {
25 | NSNumber *num = objc_getAssociatedObject(self, _cmd);
26 | return [num boolValue]; // 默认为 NO
27 | }
28 |
29 | - (void)setCached:(BOOL)cached {
30 | NSNumber *boolValue = @(cached);
31 | objc_setAssociatedObject(self, @selector(version), boolValue, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
32 | }
33 |
34 | @end
35 |
36 | #pragma mark -
37 |
38 | @implementation ATNetworkManager
39 |
40 | + (void)setup {
41 | // 网络请求全局配置
42 | [XMCenter setupConfig:^(XMConfig *config) {
43 | config.generalServer = AWESOME_TIPS_API_HOST;
44 | config.callbackQueue = dispatch_get_main_queue();
45 | #ifdef DEBUG
46 | config.consoleLog = YES;
47 | #endif
48 | }];
49 |
50 | // 加载 tips.kangzubin.com 域名的证书
51 | NSBundle *bundle = [NSBundle mainBundle];
52 | NSString *path = [bundle pathForResource:@"tips.kangzubin.com" ofType:@"cer"];
53 | NSData *certificateData = [NSData dataWithContentsOfFile:path];
54 | if (certificateData) {
55 | [XMCenter addSSLPinningCert:certificateData];
56 | }
57 | // 对 tips.kangzubin.com 域名下的接口做 SSL Pinning 验证
58 | [XMCenter addSSLPinningURL:@"https://tips.kangzubin.com"];
59 |
60 | // 请求预处理插件
61 | [XMCenter setRequestProcessBlock:^(XMRequest *request) {
62 | // 在这里对所有的请求进行统一的预处理,如业务数据加密等
63 | NSMutableDictionary *headers = [[NSMutableDictionary alloc] initWithDictionary:request.headers];
64 | headers[@"from"] = @"ios-app";
65 | headers[@"version"] = [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"];
66 | request.headers = [headers copy];
67 | }];
68 |
69 | // 响应后处理插件
70 | // 如果 Block 的返回值不为空,则 responseObject 会被替换为 Block 的返回值
71 | [XMCenter setResponseProcessBlock:^id(XMRequest *request, id responseObject, NSError *__autoreleasing * error) {
72 | // 在这里对请求的响应结果进行统一处理,如业务数据解密等
73 | if (![request.server isEqualToString:AWESOME_TIPS_API_HOST]) {
74 | return nil;
75 | }
76 | if ([responseObject isKindOfClass:[NSDictionary class]] && [[responseObject allKeys] count] > 0) {
77 | NSInteger code = [responseObject[@"code"] integerValue];
78 | if (code != kATSuccessCode) {
79 | // 网络请求成功,但接口返回的 Code 表示失败,这里给 *error 赋值,后续走 failureBlock 回调
80 | *error = ATNetworkErrorGenerator(code, responseObject[@"msg"]);
81 | } else {
82 | // 返回的 Code 表示成功,对数据进行加工过滤,返回给上层业务
83 | NSDictionary *resultData = responseObject[@"data"];
84 |
85 | if (request.isCached) {
86 | // 缓存相关操作
87 | }
88 |
89 | return resultData;
90 | }
91 | }
92 | return nil;
93 | }];
94 |
95 | // 错误统一过滤处理
96 | [XMCenter setErrorProcessBlock:^(XMRequest *request, NSError *__autoreleasing * error) {
97 | // 比如对不同的错误码统一错误提示等
98 |
99 | }];
100 | }
101 |
102 | @end
103 |
--------------------------------------------------------------------------------
/AwesomeTips/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | zh_CN
7 | CFBundleDisplayName
8 | 知识小集
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/AwesomeTips/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // AwesomeTips
4 | //
5 | // Created by Zubin Kang on 2018/5/15.
6 | // Copyright © 2018 KANGZUBIN. 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 |
--------------------------------------------------------------------------------
/AwesomeTips/tips.kangzubin.com.cer:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awesome-tips/awesome-tips-ios-app/78eec7c0cb5b2c561f95b0016eb832e22f22b2ff/AwesomeTips/tips.kangzubin.com.cer
--------------------------------------------------------------------------------
/AwesomeTipsTests/AwesomeTipsTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // AwesomeTipsTests.m
3 | // AwesomeTipsTests
4 | //
5 | // Created by Zubin Kang on 2018/5/15.
6 | // Copyright © 2018 KANGZUBIN. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AwesomeTipsTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation AwesomeTipsTests
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 |
--------------------------------------------------------------------------------
/AwesomeTipsTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
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 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/AwesomeTipsUITests/AwesomeTipsUITests.m:
--------------------------------------------------------------------------------
1 | //
2 | // AwesomeTipsUITests.m
3 | // AwesomeTipsUITests
4 | //
5 | // Created by Zubin Kang on 2018/5/15.
6 | // Copyright © 2018 KANGZUBIN. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AwesomeTipsUITests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation AwesomeTipsUITests
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 |
--------------------------------------------------------------------------------
/AwesomeTipsUITests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
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 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Cartfile:
--------------------------------------------------------------------------------
1 | github "AFNetworking/AFNetworking" ~> 3.0
2 | github "kangzubin/XMNetworking" ~> 1.1.0
--------------------------------------------------------------------------------
/Cartfile.resolved:
--------------------------------------------------------------------------------
1 | github "AFNetworking/AFNetworking" "3.2.1"
2 | github "kangzubin/XMNetworking" "1.1.0"
3 |
--------------------------------------------------------------------------------
/Carthage/Build/.AFNetworking.version:
--------------------------------------------------------------------------------
1 | {
2 | "commitish" : "3.2.1",
3 | "iOS" : [
4 | {
5 | "name" : "AFNetworking",
6 | "hash" : "36cb997db1f2f7c025d0d348828596036cb621656c67fbeb7fac6a625c38c211"
7 | }
8 | ]
9 | }
--------------------------------------------------------------------------------
/Carthage/Build/.XMNetworking.version:
--------------------------------------------------------------------------------
1 | {
2 | "commitish" : "1.1.0",
3 | "iOS" : [
4 | {
5 | "name" : "XMNetworking",
6 | "hash" : "e9d409561b8c84bee834174a8dced10af8aa172d065c2eb2e3cf86f0696232aa"
7 | }
8 | ]
9 | }
--------------------------------------------------------------------------------
/Carthage/Build/iOS/AFNetworking.framework/AFNetworking:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awesome-tips/awesome-tips-ios-app/78eec7c0cb5b2c561f95b0016eb832e22f22b2ff/Carthage/Build/iOS/AFNetworking.framework/AFNetworking
--------------------------------------------------------------------------------
/Carthage/Build/iOS/AFNetworking.framework/Headers/AFAutoPurgingImageCache.h:
--------------------------------------------------------------------------------
1 | // AFAutoPurgingImageCache.h
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 | #import
24 |
25 | #if TARGET_OS_IOS || TARGET_OS_TV
26 | #import
27 |
28 | NS_ASSUME_NONNULL_BEGIN
29 |
30 | /**
31 | The `AFImageCache` protocol defines a set of APIs for adding, removing and fetching images from a cache synchronously.
32 | */
33 | @protocol AFImageCache
34 |
35 | /**
36 | Adds the image to the cache with the given identifier.
37 |
38 | @param image The image to cache.
39 | @param identifier The unique identifier for the image in the cache.
40 | */
41 | - (void)addImage:(UIImage *)image withIdentifier:(NSString *)identifier;
42 |
43 | /**
44 | Removes the image from the cache matching the given identifier.
45 |
46 | @param identifier The unique identifier for the image in the cache.
47 |
48 | @return A BOOL indicating whether or not the image was removed from the cache.
49 | */
50 | - (BOOL)removeImageWithIdentifier:(NSString *)identifier;
51 |
52 | /**
53 | Removes all images from the cache.
54 |
55 | @return A BOOL indicating whether or not all images were removed from the cache.
56 | */
57 | - (BOOL)removeAllImages;
58 |
59 | /**
60 | Returns the image in the cache associated with the given identifier.
61 |
62 | @param identifier The unique identifier for the image in the cache.
63 |
64 | @return An image for the matching identifier, or nil.
65 | */
66 | - (nullable UIImage *)imageWithIdentifier:(NSString *)identifier;
67 | @end
68 |
69 |
70 | /**
71 | The `ImageRequestCache` protocol extends the `ImageCache` protocol by adding methods for adding, removing and fetching images from a cache given an `NSURLRequest` and additional identifier.
72 | */
73 | @protocol AFImageRequestCache
74 |
75 | /**
76 | Asks if the image should be cached using an identifier created from the request and additional identifier.
77 |
78 | @param image The image to be cached.
79 | @param request The unique URL request identifing the image asset.
80 | @param identifier The additional identifier to apply to the URL request to identify the image.
81 |
82 | @return A BOOL indicating whether or not the image should be added to the cache. YES will cache, NO will prevent caching.
83 | */
84 | - (BOOL)shouldCacheImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier;
85 |
86 | /**
87 | Adds the image to the cache using an identifier created from the request and additional identifier.
88 |
89 | @param image The image to cache.
90 | @param request The unique URL request identifing the image asset.
91 | @param identifier The additional identifier to apply to the URL request to identify the image.
92 | */
93 | - (void)addImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier;
94 |
95 | /**
96 | Removes the image from the cache using an identifier created from the request and additional identifier.
97 |
98 | @param request The unique URL request identifing the image asset.
99 | @param identifier The additional identifier to apply to the URL request to identify the image.
100 |
101 | @return A BOOL indicating whether or not all images were removed from the cache.
102 | */
103 | - (BOOL)removeImageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier;
104 |
105 | /**
106 | Returns the image from the cache associated with an identifier created from the request and additional identifier.
107 |
108 | @param request The unique URL request identifing the image asset.
109 | @param identifier The additional identifier to apply to the URL request to identify the image.
110 |
111 | @return An image for the matching request and identifier, or nil.
112 | */
113 | - (nullable UIImage *)imageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier;
114 |
115 | @end
116 |
117 | /**
118 | The `AutoPurgingImageCache` in an in-memory image cache used to store images up to a given memory capacity. When the memory capacity is reached, the image cache is sorted by last access date, then the oldest image is continuously purged until the preferred memory usage after purge is met. Each time an image is accessed through the cache, the internal access date of the image is updated.
119 | */
120 | @interface AFAutoPurgingImageCache : NSObject
121 |
122 | /**
123 | The total memory capacity of the cache in bytes.
124 | */
125 | @property (nonatomic, assign) UInt64 memoryCapacity;
126 |
127 | /**
128 | The preferred memory usage after purge in bytes. During a purge, images will be purged until the memory capacity drops below this limit.
129 | */
130 | @property (nonatomic, assign) UInt64 preferredMemoryUsageAfterPurge;
131 |
132 | /**
133 | The current total memory usage in bytes of all images stored within the cache.
134 | */
135 | @property (nonatomic, assign, readonly) UInt64 memoryUsage;
136 |
137 | /**
138 | Initialies the `AutoPurgingImageCache` instance with default values for memory capacity and preferred memory usage after purge limit. `memoryCapcity` defaults to `100 MB`. `preferredMemoryUsageAfterPurge` defaults to `60 MB`.
139 |
140 | @return The new `AutoPurgingImageCache` instance.
141 | */
142 | - (instancetype)init;
143 |
144 | /**
145 | Initialies the `AutoPurgingImageCache` instance with the given memory capacity and preferred memory usage
146 | after purge limit.
147 |
148 | @param memoryCapacity The total memory capacity of the cache in bytes.
149 | @param preferredMemoryCapacity The preferred memory usage after purge in bytes.
150 |
151 | @return The new `AutoPurgingImageCache` instance.
152 | */
153 | - (instancetype)initWithMemoryCapacity:(UInt64)memoryCapacity preferredMemoryCapacity:(UInt64)preferredMemoryCapacity;
154 |
155 | @end
156 |
157 | NS_ASSUME_NONNULL_END
158 |
159 | #endif
160 |
161 |
--------------------------------------------------------------------------------
/Carthage/Build/iOS/AFNetworking.framework/Headers/AFCompatibilityMacros.h:
--------------------------------------------------------------------------------
1 | // AFCompatibilityMacros.h
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #ifndef AFCompatibilityMacros_h
23 | #define AFCompatibilityMacros_h
24 |
25 | #ifdef API_UNAVAILABLE
26 | #define AF_API_UNAVAILABLE(x) API_UNAVAILABLE(x)
27 | #else
28 | #define AF_API_UNAVAILABLE(x)
29 | #endif // API_UNAVAILABLE
30 |
31 | #if __has_warning("-Wunguarded-availability-new")
32 | #define AF_CAN_USE_AT_AVAILABLE 1
33 | #else
34 | #define AF_CAN_USE_AT_AVAILABLE 0
35 | #endif
36 |
37 | #endif /* AFCompatibilityMacros_h */
38 |
--------------------------------------------------------------------------------
/Carthage/Build/iOS/AFNetworking.framework/Headers/AFHTTPSessionManager.h:
--------------------------------------------------------------------------------
1 | // AFHTTPSessionManager.h
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 | #if !TARGET_OS_WATCH
24 | #import
25 | #endif
26 | #import
27 |
28 | #if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV
29 | #import
30 | #else
31 | #import
32 | #endif
33 |
34 | #import "AFURLSessionManager.h"
35 |
36 | /**
37 | `AFHTTPSessionManager` is a subclass of `AFURLSessionManager` with convenience methods for making HTTP requests. When a `baseURL` is provided, requests made with the `GET` / `POST` / et al. convenience methods can be made with relative paths.
38 |
39 | ## Subclassing Notes
40 |
41 | Developers targeting iOS 7 or Mac OS X 10.9 or later that deal extensively with a web service are encouraged to subclass `AFHTTPSessionManager`, providing a class method that returns a shared singleton object on which authentication and other configuration can be shared across the application.
42 |
43 | For developers targeting iOS 6 or Mac OS X 10.8 or earlier, `AFHTTPRequestOperationManager` may be used to similar effect.
44 |
45 | ## Methods to Override
46 |
47 | To change the behavior of all data task operation construction, which is also used in the `GET` / `POST` / et al. convenience methods, override `dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:`.
48 |
49 | ## Serialization
50 |
51 | Requests created by an HTTP client will contain default headers and encode parameters according to the `requestSerializer` property, which is an object conforming to ``.
52 |
53 | Responses received from the server are automatically validated and serialized by the `responseSerializers` property, which is an object conforming to ``
54 |
55 | ## URL Construction Using Relative Paths
56 |
57 | For HTTP convenience methods, the request serializer constructs URLs from the path relative to the `-baseURL`, using `NSURL +URLWithString:relativeToURL:`, when provided. If `baseURL` is `nil`, `path` needs to resolve to a valid `NSURL` object using `NSURL +URLWithString:`.
58 |
59 | Below are a few examples of how `baseURL` and relative paths interact:
60 |
61 | NSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"];
62 | [NSURL URLWithString:@"foo" relativeToURL:baseURL]; // http://example.com/v1/foo
63 | [NSURL URLWithString:@"foo?bar=baz" relativeToURL:baseURL]; // http://example.com/v1/foo?bar=baz
64 | [NSURL URLWithString:@"/foo" relativeToURL:baseURL]; // http://example.com/foo
65 | [NSURL URLWithString:@"foo/" relativeToURL:baseURL]; // http://example.com/v1/foo
66 | [NSURL URLWithString:@"/foo/" relativeToURL:baseURL]; // http://example.com/foo/
67 | [NSURL URLWithString:@"http://example2.com/" relativeToURL:baseURL]; // http://example2.com/
68 |
69 | Also important to note is that a trailing slash will be added to any `baseURL` without one. This would otherwise cause unexpected behavior when constructing URLs using paths without a leading slash.
70 |
71 | @warning Managers for background sessions must be owned for the duration of their use. This can be accomplished by creating an application-wide or shared singleton instance.
72 | */
73 |
74 | NS_ASSUME_NONNULL_BEGIN
75 |
76 | @interface AFHTTPSessionManager : AFURLSessionManager
77 |
78 | /**
79 | The URL used to construct requests from relative paths in methods like `requestWithMethod:URLString:parameters:`, and the `GET` / `POST` / et al. convenience methods.
80 | */
81 | @property (readonly, nonatomic, strong, nullable) NSURL *baseURL;
82 |
83 | /**
84 | Requests created with `requestWithMethod:URLString:parameters:` & `multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:` are constructed with a set of default headers using a parameter serialization specified by this property. By default, this is set to an instance of `AFHTTPRequestSerializer`, which serializes query string parameters for `GET`, `HEAD`, and `DELETE` requests, or otherwise URL-form-encodes HTTP message bodies.
85 |
86 | @warning `requestSerializer` must not be `nil`.
87 | */
88 | @property (nonatomic, strong) AFHTTPRequestSerializer * requestSerializer;
89 |
90 | /**
91 | Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an instance of `AFJSONResponseSerializer`.
92 |
93 | @warning `responseSerializer` must not be `nil`.
94 | */
95 | @property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer;
96 |
97 | ///-------------------------------
98 | /// @name Managing Security Policy
99 | ///-------------------------------
100 |
101 | /**
102 | The security policy used by created session to evaluate server trust for secure connections. `AFURLSessionManager` uses the `defaultPolicy` unless otherwise specified. A security policy configured with `AFSSLPinningModePublicKey` or `AFSSLPinningModeCertificate` can only be applied on a session manager initialized with a secure base URL (i.e. https). Applying a security policy with pinning enabled on an insecure session manager throws an `Invalid Security Policy` exception.
103 | */
104 | @property (nonatomic, strong) AFSecurityPolicy *securityPolicy;
105 |
106 | ///---------------------
107 | /// @name Initialization
108 | ///---------------------
109 |
110 | /**
111 | Creates and returns an `AFHTTPSessionManager` object.
112 | */
113 | + (instancetype)manager;
114 |
115 | /**
116 | Initializes an `AFHTTPSessionManager` object with the specified base URL.
117 |
118 | @param url The base URL for the HTTP client.
119 |
120 | @return The newly-initialized HTTP client
121 | */
122 | - (instancetype)initWithBaseURL:(nullable NSURL *)url;
123 |
124 | /**
125 | Initializes an `AFHTTPSessionManager` object with the specified base URL.
126 |
127 | This is the designated initializer.
128 |
129 | @param url The base URL for the HTTP client.
130 | @param configuration The configuration used to create the managed session.
131 |
132 | @return The newly-initialized HTTP client
133 | */
134 | - (instancetype)initWithBaseURL:(nullable NSURL *)url
135 | sessionConfiguration:(nullable NSURLSessionConfiguration *)configuration NS_DESIGNATED_INITIALIZER;
136 |
137 | ///---------------------------
138 | /// @name Making HTTP Requests
139 | ///---------------------------
140 |
141 | /**
142 | Creates and runs an `NSURLSessionDataTask` with a `GET` request.
143 |
144 | @param URLString The URL string used to create the request URL.
145 | @param parameters The parameters to be encoded according to the client request serializer.
146 | @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
147 | @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
148 |
149 | @see -dataTaskWithRequest:completionHandler:
150 | */
151 | - (nullable NSURLSessionDataTask *)GET:(NSString *)URLString
152 | parameters:(nullable id)parameters
153 | success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
154 | failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE;
155 |
156 |
157 | /**
158 | Creates and runs an `NSURLSessionDataTask` with a `GET` request.
159 |
160 | @param URLString The URL string used to create the request URL.
161 | @param parameters The parameters to be encoded according to the client request serializer.
162 | @param downloadProgress A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue.
163 | @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
164 | @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
165 |
166 | @see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:
167 | */
168 | - (nullable NSURLSessionDataTask *)GET:(NSString *)URLString
169 | parameters:(nullable id)parameters
170 | progress:(nullable void (^)(NSProgress *downloadProgress))downloadProgress
171 | success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
172 | failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
173 |
174 | /**
175 | Creates and runs an `NSURLSessionDataTask` with a `HEAD` request.
176 |
177 | @param URLString The URL string used to create the request URL.
178 | @param parameters The parameters to be encoded according to the client request serializer.
179 | @param success A block object to be executed when the task finishes successfully. This block has no return value and takes a single arguments: the data task.
180 | @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
181 |
182 | @see -dataTaskWithRequest:completionHandler:
183 | */
184 | - (nullable NSURLSessionDataTask *)HEAD:(NSString *)URLString
185 | parameters:(nullable id)parameters
186 | success:(nullable void (^)(NSURLSessionDataTask *task))success
187 | failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
188 |
189 | /**
190 | Creates and runs an `NSURLSessionDataTask` with a `POST` request.
191 |
192 | @param URLString The URL string used to create the request URL.
193 | @param parameters The parameters to be encoded according to the client request serializer.
194 | @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
195 | @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
196 |
197 | @see -dataTaskWithRequest:completionHandler:
198 | */
199 | - (nullable NSURLSessionDataTask *)POST:(NSString *)URLString
200 | parameters:(nullable id)parameters
201 | success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
202 | failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE;
203 |
204 | /**
205 | Creates and runs an `NSURLSessionDataTask` with a `POST` request.
206 |
207 | @param URLString The URL string used to create the request URL.
208 | @param parameters The parameters to be encoded according to the client request serializer.
209 | @param uploadProgress A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.
210 | @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
211 | @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
212 |
213 | @see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:
214 | */
215 | - (nullable NSURLSessionDataTask *)POST:(NSString *)URLString
216 | parameters:(nullable id)parameters
217 | progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgress
218 | success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
219 | failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
220 |
221 | /**
222 | Creates and runs an `NSURLSessionDataTask` with a multipart `POST` request.
223 |
224 | @param URLString The URL string used to create the request URL.
225 | @param parameters The parameters to be encoded according to the client request serializer.
226 | @param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol.
227 | @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
228 | @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
229 |
230 | @see -dataTaskWithRequest:completionHandler:
231 | */
232 | - (nullable NSURLSessionDataTask *)POST:(NSString *)URLString
233 | parameters:(nullable id)parameters
234 | constructingBodyWithBlock:(nullable void (^)(id formData))block
235 | success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
236 | failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE;
237 |
238 | /**
239 | Creates and runs an `NSURLSessionDataTask` with a multipart `POST` request.
240 |
241 | @param URLString The URL string used to create the request URL.
242 | @param parameters The parameters to be encoded according to the client request serializer.
243 | @param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol.
244 | @param uploadProgress A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue.
245 | @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
246 | @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
247 |
248 | @see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:
249 | */
250 | - (nullable NSURLSessionDataTask *)POST:(NSString *)URLString
251 | parameters:(nullable id)parameters
252 | constructingBodyWithBlock:(nullable void (^)(id formData))block
253 | progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgress
254 | success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
255 | failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
256 |
257 | /**
258 | Creates and runs an `NSURLSessionDataTask` with a `PUT` request.
259 |
260 | @param URLString The URL string used to create the request URL.
261 | @param parameters The parameters to be encoded according to the client request serializer.
262 | @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
263 | @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
264 |
265 | @see -dataTaskWithRequest:completionHandler:
266 | */
267 | - (nullable NSURLSessionDataTask *)PUT:(NSString *)URLString
268 | parameters:(nullable id)parameters
269 | success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
270 | failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
271 |
272 | /**
273 | Creates and runs an `NSURLSessionDataTask` with a `PATCH` request.
274 |
275 | @param URLString The URL string used to create the request URL.
276 | @param parameters The parameters to be encoded according to the client request serializer.
277 | @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
278 | @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
279 |
280 | @see -dataTaskWithRequest:completionHandler:
281 | */
282 | - (nullable NSURLSessionDataTask *)PATCH:(NSString *)URLString
283 | parameters:(nullable id)parameters
284 | success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
285 | failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
286 |
287 | /**
288 | Creates and runs an `NSURLSessionDataTask` with a `DELETE` request.
289 |
290 | @param URLString The URL string used to create the request URL.
291 | @param parameters The parameters to be encoded according to the client request serializer.
292 | @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer.
293 | @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred.
294 |
295 | @see -dataTaskWithRequest:completionHandler:
296 | */
297 | - (nullable NSURLSessionDataTask *)DELETE:(NSString *)URLString
298 | parameters:(nullable id)parameters
299 | success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
300 | failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
301 |
302 | @end
303 |
304 | NS_ASSUME_NONNULL_END
305 |
--------------------------------------------------------------------------------
/Carthage/Build/iOS/AFNetworking.framework/Headers/AFImageDownloader.h:
--------------------------------------------------------------------------------
1 | // AFImageDownloader.h
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 |
24 | #if TARGET_OS_IOS || TARGET_OS_TV
25 |
26 | #import
27 | #import "AFAutoPurgingImageCache.h"
28 | #import "AFHTTPSessionManager.h"
29 |
30 | NS_ASSUME_NONNULL_BEGIN
31 |
32 | typedef NS_ENUM(NSInteger, AFImageDownloadPrioritization) {
33 | AFImageDownloadPrioritizationFIFO,
34 | AFImageDownloadPrioritizationLIFO
35 | };
36 |
37 | /**
38 | The `AFImageDownloadReceipt` is an object vended by the `AFImageDownloader` when starting a data task. It can be used to cancel active tasks running on the `AFImageDownloader` session. As a general rule, image data tasks should be cancelled using the `AFImageDownloadReceipt` instead of calling `cancel` directly on the `task` itself. The `AFImageDownloader` is optimized to handle duplicate task scenarios as well as pending versus active downloads.
39 | */
40 | @interface AFImageDownloadReceipt : NSObject
41 |
42 | /**
43 | The data task created by the `AFImageDownloader`.
44 | */
45 | @property (nonatomic, strong) NSURLSessionDataTask *task;
46 |
47 | /**
48 | The unique identifier for the success and failure blocks when duplicate requests are made.
49 | */
50 | @property (nonatomic, strong) NSUUID *receiptID;
51 | @end
52 |
53 | /** The `AFImageDownloader` class is responsible for downloading images in parallel on a prioritized queue. Incoming downloads are added to the front or back of the queue depending on the download prioritization. Each downloaded image is cached in the underlying `NSURLCache` as well as the in-memory image cache. By default, any download request with a cached image equivalent in the image cache will automatically be served the cached image representation.
54 | */
55 | @interface AFImageDownloader : NSObject
56 |
57 | /**
58 | The image cache used to store all downloaded images in. `AFAutoPurgingImageCache` by default.
59 | */
60 | @property (nonatomic, strong, nullable) id imageCache;
61 |
62 | /**
63 | The `AFHTTPSessionManager` used to download images. By default, this is configured with an `AFImageResponseSerializer`, and a shared `NSURLCache` for all image downloads.
64 | */
65 | @property (nonatomic, strong) AFHTTPSessionManager *sessionManager;
66 |
67 | /**
68 | Defines the order prioritization of incoming download requests being inserted into the queue. `AFImageDownloadPrioritizationFIFO` by default.
69 | */
70 | @property (nonatomic, assign) AFImageDownloadPrioritization downloadPrioritizaton;
71 |
72 | /**
73 | The shared default instance of `AFImageDownloader` initialized with default values.
74 | */
75 | + (instancetype)defaultInstance;
76 |
77 | /**
78 | Creates a default `NSURLCache` with common usage parameter values.
79 |
80 | @returns The default `NSURLCache` instance.
81 | */
82 | + (NSURLCache *)defaultURLCache;
83 |
84 | /**
85 | The default `NSURLSessionConfiguration` with common usage parameter values.
86 | */
87 | + (NSURLSessionConfiguration *)defaultURLSessionConfiguration;
88 |
89 | /**
90 | Default initializer
91 |
92 | @return An instance of `AFImageDownloader` initialized with default values.
93 | */
94 | - (instancetype)init;
95 |
96 | /**
97 | Initializer with specific `URLSessionConfiguration`
98 |
99 | @param configuration The `NSURLSessionConfiguration` to be be used
100 |
101 | @return An instance of `AFImageDownloader` initialized with default values and custom `NSURLSessionConfiguration`
102 | */
103 | - (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration;
104 |
105 | /**
106 | Initializes the `AFImageDownloader` instance with the given session manager, download prioritization, maximum active download count and image cache.
107 |
108 | @param sessionManager The session manager to use to download images.
109 | @param downloadPrioritization The download prioritization of the download queue.
110 | @param maximumActiveDownloads The maximum number of active downloads allowed at any given time. Recommend `4`.
111 | @param imageCache The image cache used to store all downloaded images in.
112 |
113 | @return The new `AFImageDownloader` instance.
114 | */
115 | - (instancetype)initWithSessionManager:(AFHTTPSessionManager *)sessionManager
116 | downloadPrioritization:(AFImageDownloadPrioritization)downloadPrioritization
117 | maximumActiveDownloads:(NSInteger)maximumActiveDownloads
118 | imageCache:(nullable id )imageCache;
119 |
120 | /**
121 | Creates a data task using the `sessionManager` instance for the specified URL request.
122 |
123 | If the same data task is already in the queue or currently being downloaded, the success and failure blocks are
124 | appended to the already existing task. Once the task completes, all success or failure blocks attached to the
125 | task are executed in the order they were added.
126 |
127 | @param request The URL request.
128 | @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`.
129 | @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred.
130 |
131 | @return The image download receipt for the data task if available. `nil` if the image is stored in the cache.
132 | cache and the URL request cache policy allows the cache to be used.
133 | */
134 | - (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *)request
135 | success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *responseObject))success
136 | failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure;
137 |
138 | /**
139 | Creates a data task using the `sessionManager` instance for the specified URL request.
140 |
141 | If the same data task is already in the queue or currently being downloaded, the success and failure blocks are
142 | appended to the already existing task. Once the task completes, all success or failure blocks attached to the
143 | task are executed in the order they were added.
144 |
145 | @param request The URL request.
146 | @param receiptID The identifier to use for the download receipt that will be created for this request. This must be a unique identifier that does not represent any other request.
147 | @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`.
148 | @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred.
149 |
150 | @return The image download receipt for the data task if available. `nil` if the image is stored in the cache.
151 | cache and the URL request cache policy allows the cache to be used.
152 | */
153 | - (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *)request
154 | withReceiptID:(NSUUID *)receiptID
155 | success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *responseObject))success
156 | failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure;
157 |
158 | /**
159 | Cancels the data task in the receipt by removing the corresponding success and failure blocks and cancelling the data task if necessary.
160 |
161 | If the data task is pending in the queue, it will be cancelled if no other success and failure blocks are registered with the data task. If the data task is currently executing or is already completed, the success and failure blocks are removed and will not be called when the task finishes.
162 |
163 | @param imageDownloadReceipt The image download receipt to cancel.
164 | */
165 | - (void)cancelTaskForImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt;
166 |
167 | @end
168 |
169 | #endif
170 |
171 | NS_ASSUME_NONNULL_END
172 |
--------------------------------------------------------------------------------
/Carthage/Build/iOS/AFNetworking.framework/Headers/AFNetworkActivityIndicatorManager.h:
--------------------------------------------------------------------------------
1 | // AFNetworkActivityIndicatorManager.h
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 |
24 | #import
25 |
26 | #if TARGET_OS_IOS
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 session task has started or finished, and start or stop animating the indicator accordingly. The number of active requests is incremented and decremented much like a stack or a semaphore, and the activity indicator will animate so long as that number is greater than zero.
34 |
35 | You should enable the shared instance of `AFNetworkActivityIndicatorManager` when your application finishes launching. In `AppDelegate application:didFinishLaunchingWithOptions:` you can do so with the following code:
36 |
37 | [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES];
38 |
39 | By setting `enabled` to `YES` for `sharedManager`, the network activity indicator will show and hide automatically as requests start and finish. You should not ever need to call `incrementActivityCount` or `decrementActivityCount` yourself.
40 |
41 | See the Apple Human Interface Guidelines section about the Network Activity Indicator for more information:
42 | http://developer.apple.com/library/iOS/#documentation/UserExperience/Conceptual/MobileHIG/UIElementGuidelines/UIElementGuidelines.html#//apple_ref/doc/uid/TP40006556-CH13-SW44
43 | */
44 | NS_EXTENSION_UNAVAILABLE_IOS("Use view controller based solutions where appropriate instead.")
45 | @interface AFNetworkActivityIndicatorManager : NSObject
46 |
47 | /**
48 | A Boolean value indicating whether the manager is enabled.
49 |
50 | If YES, the manager will change status bar network activity indicator according to network operation notifications it receives. The default value is NO.
51 | */
52 | @property (nonatomic, assign, getter = isEnabled) BOOL enabled;
53 |
54 | /**
55 | A Boolean value indicating whether the network activity indicator manager is currently active.
56 | */
57 | @property (readonly, nonatomic, assign, getter=isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible;
58 |
59 | /**
60 | A time interval indicating the minimum duration of networking activity that should occur before the activity indicator is displayed. The default value 1 second. If the network activity indicator should be displayed immediately when network activity occurs, this value should be set to 0 seconds.
61 |
62 | Apple's HIG describes the following:
63 |
64 | > Display the network activity indicator to provide feedback when your app accesses the network for more than a couple of seconds. If the operation finishes sooner than that, you don’t have to show the network activity indicator, because the indicator is likely to disappear before users notice its presence.
65 |
66 | */
67 | @property (nonatomic, assign) NSTimeInterval activationDelay;
68 |
69 | /**
70 | A time interval indicating the duration of time of no networking activity required before the activity indicator is disabled. This allows for continuous display of the network activity indicator across multiple requests. The default value is 0.17 seconds.
71 | */
72 |
73 | @property (nonatomic, assign) NSTimeInterval completionDelay;
74 |
75 | /**
76 | Returns the shared network activity indicator manager object for the system.
77 |
78 | @return The systemwide network activity indicator manager.
79 | */
80 | + (instancetype)sharedManager;
81 |
82 | /**
83 | Increments the number of active network requests. If this number was zero before incrementing, this will start animating the status bar network activity indicator.
84 | */
85 | - (void)incrementActivityCount;
86 |
87 | /**
88 | Decrements the number of active network requests. If this number becomes zero after decrementing, this will stop animating the status bar network activity indicator.
89 | */
90 | - (void)decrementActivityCount;
91 |
92 | /**
93 | Set the a custom method to be executed when the network activity indicator manager should be hidden/shown. By default, this is null, and the UIApplication Network Activity Indicator will be managed automatically. If this block is set, it is the responsiblity of the caller to manager the network activity indicator going forward.
94 |
95 | @param block A block to be executed when the network activity indicator status changes.
96 | */
97 | - (void)setNetworkingActivityActionWithBlock:(nullable void (^)(BOOL networkActivityIndicatorVisible))block;
98 |
99 | @end
100 |
101 | NS_ASSUME_NONNULL_END
102 |
103 | #endif
104 |
--------------------------------------------------------------------------------
/Carthage/Build/iOS/AFNetworking.framework/Headers/AFNetworkReachabilityManager.h:
--------------------------------------------------------------------------------
1 | // AFNetworkReachabilityManager.h
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 |
24 | #if !TARGET_OS_WATCH
25 | #import
26 |
27 | typedef NS_ENUM(NSInteger, AFNetworkReachabilityStatus) {
28 | AFNetworkReachabilityStatusUnknown = -1,
29 | AFNetworkReachabilityStatusNotReachable = 0,
30 | AFNetworkReachabilityStatusReachableViaWWAN = 1,
31 | AFNetworkReachabilityStatusReachableViaWiFi = 2,
32 | };
33 |
34 | NS_ASSUME_NONNULL_BEGIN
35 |
36 | /**
37 | `AFNetworkReachabilityManager` monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces.
38 |
39 | Reachability can be used to determine background information about why a network operation failed, or to trigger a network operation retrying when a connection is established. It should not be used to prevent a user from initiating a network request, as it's possible that an initial request may be required to establish reachability.
40 |
41 | See Apple's Reachability Sample Code ( https://developer.apple.com/library/ios/samplecode/reachability/ )
42 |
43 | @warning Instances of `AFNetworkReachabilityManager` must be started with `-startMonitoring` before reachability status can be determined.
44 | */
45 | @interface AFNetworkReachabilityManager : NSObject
46 |
47 | /**
48 | The current network reachability status.
49 | */
50 | @property (readonly, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus;
51 |
52 | /**
53 | Whether or not the network is currently reachable.
54 | */
55 | @property (readonly, nonatomic, assign, getter = isReachable) BOOL reachable;
56 |
57 | /**
58 | Whether or not the network is currently reachable via WWAN.
59 | */
60 | @property (readonly, nonatomic, assign, getter = isReachableViaWWAN) BOOL reachableViaWWAN;
61 |
62 | /**
63 | Whether or not the network is currently reachable via WiFi.
64 | */
65 | @property (readonly, nonatomic, assign, getter = isReachableViaWiFi) BOOL reachableViaWiFi;
66 |
67 | ///---------------------
68 | /// @name Initialization
69 | ///---------------------
70 |
71 | /**
72 | Returns the shared network reachability manager.
73 | */
74 | + (instancetype)sharedManager;
75 |
76 | /**
77 | Creates and returns a network reachability manager with the default socket address.
78 |
79 | @return An initialized network reachability manager, actively monitoring the default socket address.
80 | */
81 | + (instancetype)manager;
82 |
83 | /**
84 | Creates and returns a network reachability manager for the specified domain.
85 |
86 | @param domain The domain used to evaluate network reachability.
87 |
88 | @return An initialized network reachability manager, actively monitoring the specified domain.
89 | */
90 | + (instancetype)managerForDomain:(NSString *)domain;
91 |
92 | /**
93 | Creates and returns a network reachability manager for the socket address.
94 |
95 | @param address The socket address (`sockaddr_in6`) used to evaluate network reachability.
96 |
97 | @return An initialized network reachability manager, actively monitoring the specified socket address.
98 | */
99 | + (instancetype)managerForAddress:(const void *)address;
100 |
101 | /**
102 | Initializes an instance of a network reachability manager from the specified reachability object.
103 |
104 | @param reachability The reachability object to monitor.
105 |
106 | @return An initialized network reachability manager, actively monitoring the specified reachability.
107 | */
108 | - (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability NS_DESIGNATED_INITIALIZER;
109 |
110 | /**
111 | * Unavailable initializer
112 | */
113 | + (instancetype)new NS_UNAVAILABLE;
114 |
115 | /**
116 | * Unavailable initializer
117 | */
118 | - (instancetype)init NS_UNAVAILABLE;
119 |
120 | ///--------------------------------------------------
121 | /// @name Starting & Stopping Reachability Monitoring
122 | ///--------------------------------------------------
123 |
124 | /**
125 | Starts monitoring for changes in network reachability status.
126 | */
127 | - (void)startMonitoring;
128 |
129 | /**
130 | Stops monitoring for changes in network reachability status.
131 | */
132 | - (void)stopMonitoring;
133 |
134 | ///-------------------------------------------------
135 | /// @name Getting Localized Reachability Description
136 | ///-------------------------------------------------
137 |
138 | /**
139 | Returns a localized string representation of the current network reachability status.
140 | */
141 | - (NSString *)localizedNetworkReachabilityStatusString;
142 |
143 | ///---------------------------------------------------
144 | /// @name Setting Network Reachability Change Callback
145 | ///---------------------------------------------------
146 |
147 | /**
148 | Sets a callback to be executed when the network availability of the `baseURL` host changes.
149 |
150 | @param block A block object to be executed when the network availability of the `baseURL` host changes.. This block has no return value and takes a single argument which represents the various reachability states from the device to the `baseURL`.
151 | */
152 | - (void)setReachabilityStatusChangeBlock:(nullable void (^)(AFNetworkReachabilityStatus status))block;
153 |
154 | @end
155 |
156 | ///----------------
157 | /// @name Constants
158 | ///----------------
159 |
160 | /**
161 | ## Network Reachability
162 |
163 | The following constants are provided by `AFNetworkReachabilityManager` as possible network reachability statuses.
164 |
165 | enum {
166 | AFNetworkReachabilityStatusUnknown,
167 | AFNetworkReachabilityStatusNotReachable,
168 | AFNetworkReachabilityStatusReachableViaWWAN,
169 | AFNetworkReachabilityStatusReachableViaWiFi,
170 | }
171 |
172 | `AFNetworkReachabilityStatusUnknown`
173 | The `baseURL` host reachability is not known.
174 |
175 | `AFNetworkReachabilityStatusNotReachable`
176 | The `baseURL` host cannot be reached.
177 |
178 | `AFNetworkReachabilityStatusReachableViaWWAN`
179 | The `baseURL` host can be reached via a cellular connection, such as EDGE or GPRS.
180 |
181 | `AFNetworkReachabilityStatusReachableViaWiFi`
182 | The `baseURL` host can be reached via a Wi-Fi connection.
183 |
184 | ### Keys for Notification UserInfo Dictionary
185 |
186 | Strings that are used as keys in a `userInfo` dictionary in a network reachability status change notification.
187 |
188 | `AFNetworkingReachabilityNotificationStatusItem`
189 | A key in the userInfo dictionary in a `AFNetworkingReachabilityDidChangeNotification` notification.
190 | The corresponding value is an `NSNumber` object representing the `AFNetworkReachabilityStatus` value for the current reachability status.
191 | */
192 |
193 | ///--------------------
194 | /// @name Notifications
195 | ///--------------------
196 |
197 | /**
198 | Posted when network reachability changes.
199 | This notification assigns no notification object. The `userInfo` dictionary contains an `NSNumber` object under the `AFNetworkingReachabilityNotificationStatusItem` key, representing the `AFNetworkReachabilityStatus` value for the current network reachability.
200 |
201 | @warning In order for network reachability to be monitored, include the `SystemConfiguration` framework in the active target's "Link Binary With Library" build phase, and add `#import ` to the header prefix of the project (`Prefix.pch`).
202 | */
203 | FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityDidChangeNotification;
204 | FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityNotificationStatusItem;
205 |
206 | ///--------------------
207 | /// @name Functions
208 | ///--------------------
209 |
210 | /**
211 | Returns a localized string representation of an `AFNetworkReachabilityStatus` value.
212 | */
213 | FOUNDATION_EXPORT NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status);
214 |
215 | NS_ASSUME_NONNULL_END
216 | #endif
217 |
--------------------------------------------------------------------------------
/Carthage/Build/iOS/AFNetworking.framework/Headers/AFNetworking.h:
--------------------------------------------------------------------------------
1 | // AFNetworking.h
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 |
24 | //! Project version number for AFNetworking.
25 | FOUNDATION_EXPORT double AFNetworkingVersionNumber;
26 |
27 | //! Project version string for AFNetworking.
28 | FOUNDATION_EXPORT const unsigned char AFNetworkingVersionString[];
29 |
30 | // In this header, you should import all the public headers of your framework using statements like #import
31 |
32 | #import
33 | #import
34 |
35 | #ifndef _AFNETWORKING_
36 | #define _AFNETWORKING_
37 |
38 | #import
39 | #import
40 | #import
41 | #import
42 |
43 | #if !TARGET_OS_WATCH
44 | #import
45 | #endif
46 |
47 | #import
48 | #import
49 |
50 | #if TARGET_OS_IOS || TARGET_OS_TV
51 | #import
52 | #import
53 | #import
54 | #import
55 | #import
56 | #import
57 | #import
58 | #endif
59 |
60 | #if TARGET_OS_IOS
61 | #import
62 | #import
63 | #import
64 | #endif
65 |
66 |
67 | #endif /* _AFNETWORKING_ */
68 |
--------------------------------------------------------------------------------
/Carthage/Build/iOS/AFNetworking.framework/Headers/AFSecurityPolicy.h:
--------------------------------------------------------------------------------
1 | // AFSecurityPolicy.h
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
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.
48 |
49 | By default, this property is set to any (`.cer`) certificates included in the target compiling AFNetworking. Note that if you are using AFNetworking as embedded framework, no certificates will be pinned by default. Use `certificatesInBundle` to load certificates from your target, and then create a new policy by calling `policyWithPinningMode:withPinnedCertificates`.
50 |
51 | Note that if pinning is enabled, `evaluateServerTrust:forDomain:` will return true if any pinned certificate matches.
52 | */
53 | @property (nonatomic, strong, nullable) NSSet *pinnedCertificates;
54 |
55 | /**
56 | Whether or not to trust servers with an invalid or expired SSL certificates. Defaults to `NO`.
57 | */
58 | @property (nonatomic, assign) BOOL allowInvalidCertificates;
59 |
60 | /**
61 | Whether or not to validate the domain name in the certificate's CN field. Defaults to `YES`.
62 | */
63 | @property (nonatomic, assign) BOOL validatesDomainName;
64 |
65 | ///-----------------------------------------
66 | /// @name Getting Certificates from the Bundle
67 | ///-----------------------------------------
68 |
69 | /**
70 | Returns any certificates included in the bundle. If you are using AFNetworking as an embedded framework, you must use this method to find the certificates you have included in your app bundle, and use them when creating your security policy by calling `policyWithPinningMode:withPinnedCertificates`.
71 |
72 | @return The certificates included in the given bundle.
73 | */
74 | + (NSSet *)certificatesInBundle:(NSBundle *)bundle;
75 |
76 | ///-----------------------------------------
77 | /// @name Getting Specific Security Policies
78 | ///-----------------------------------------
79 |
80 | /**
81 | Returns the shared default security policy, which does not allow invalid certificates, validates domain name, and does not validate against pinned certificates or public keys.
82 |
83 | @return The default security policy.
84 | */
85 | + (instancetype)defaultPolicy;
86 |
87 | ///---------------------
88 | /// @name Initialization
89 | ///---------------------
90 |
91 | /**
92 | Creates and returns a security policy with the specified pinning mode.
93 |
94 | @param pinningMode The SSL pinning mode.
95 |
96 | @return A new security policy.
97 | */
98 | + (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode;
99 |
100 | /**
101 | Creates and returns a security policy with the specified pinning mode.
102 |
103 | @param pinningMode The SSL pinning mode.
104 | @param pinnedCertificates The certificates to pin against.
105 |
106 | @return A new security policy.
107 | */
108 | + (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode withPinnedCertificates:(NSSet *)pinnedCertificates;
109 |
110 | ///------------------------------
111 | /// @name Evaluating Server Trust
112 | ///------------------------------
113 |
114 | /**
115 | Whether or not the specified server trust should be accepted, based on the security policy.
116 |
117 | This method should be used when responding to an authentication challenge from a server.
118 |
119 | @param serverTrust The X.509 certificate trust of the server.
120 | @param domain The domain of serverTrust. If `nil`, the domain will not be validated.
121 |
122 | @return Whether or not to trust the server.
123 | */
124 | - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust
125 | forDomain:(nullable NSString *)domain;
126 |
127 | @end
128 |
129 | NS_ASSUME_NONNULL_END
130 |
131 | ///----------------
132 | /// @name Constants
133 | ///----------------
134 |
135 | /**
136 | ## SSL Pinning Modes
137 |
138 | The following constants are provided by `AFSSLPinningMode` as possible SSL pinning modes.
139 |
140 | enum {
141 | AFSSLPinningModeNone,
142 | AFSSLPinningModePublicKey,
143 | AFSSLPinningModeCertificate,
144 | }
145 |
146 | `AFSSLPinningModeNone`
147 | Do not used pinned certificates to validate servers.
148 |
149 | `AFSSLPinningModePublicKey`
150 | Validate host certificates against public keys of pinned certificates.
151 |
152 | `AFSSLPinningModeCertificate`
153 | Validate host certificates against pinned certificates.
154 | */
155 |
--------------------------------------------------------------------------------
/Carthage/Build/iOS/AFNetworking.framework/Headers/AFURLRequestSerialization.h:
--------------------------------------------------------------------------------
1 | // AFURLRequestSerialization.h
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 | #import
24 |
25 | #if TARGET_OS_IOS || TARGET_OS_TV
26 | #import
27 | #elif TARGET_OS_WATCH
28 | #import
29 | #endif
30 |
31 | NS_ASSUME_NONNULL_BEGIN
32 |
33 | /**
34 | Returns a percent-escaped string following RFC 3986 for a query string key or value.
35 | RFC 3986 states that the following characters are "reserved" characters.
36 | - General Delimiters: ":", "#", "[", "]", "@", "?", "/"
37 | - Sub-Delimiters: "!", "$", "&", "'", "(", ")", "*", "+", ",", ";", "="
38 |
39 | In RFC 3986 - Section 3.4, it states that the "?" and "/" characters should not be escaped to allow
40 | query strings to include a URL. Therefore, all "reserved" characters with the exception of "?" and "/"
41 | should be percent-escaped in the query string.
42 |
43 | @param string The string to be percent-escaped.
44 |
45 | @return The percent-escaped string.
46 | */
47 | FOUNDATION_EXPORT NSString * AFPercentEscapedStringFromString(NSString *string);
48 |
49 | /**
50 | A helper method to generate encoded url query parameters for appending to the end of a URL.
51 |
52 | @param parameters A dictionary of key/values to be encoded.
53 |
54 | @return A url encoded query string
55 | */
56 | FOUNDATION_EXPORT NSString * AFQueryStringFromParameters(NSDictionary *parameters);
57 |
58 | /**
59 | The `AFURLRequestSerialization` protocol is adopted by an object that encodes parameters for a specified HTTP requests. Request serializers may encode parameters as query strings, HTTP bodies, setting the appropriate HTTP header fields as necessary.
60 |
61 | For example, a JSON request serializer may set the HTTP body of the request to a JSON representation, and set the `Content-Type` HTTP header field value to `application/json`.
62 | */
63 | @protocol AFURLRequestSerialization
64 |
65 | /**
66 | Returns a request with the specified parameters encoded into a copy of the original request.
67 |
68 | @param request The original request.
69 | @param parameters The parameters to be encoded.
70 | @param error The error that occurred while attempting to encode the request parameters.
71 |
72 | @return A serialized request.
73 | */
74 | - (nullable NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request
75 | withParameters:(nullable id)parameters
76 | error:(NSError * _Nullable __autoreleasing *)error NS_SWIFT_NOTHROW;
77 |
78 | @end
79 |
80 | #pragma mark -
81 |
82 | /**
83 |
84 | */
85 | typedef NS_ENUM(NSUInteger, AFHTTPRequestQueryStringSerializationStyle) {
86 | AFHTTPRequestQueryStringDefaultStyle = 0,
87 | };
88 |
89 | @protocol AFMultipartFormData;
90 |
91 | /**
92 | `AFHTTPRequestSerializer` conforms to the `AFURLRequestSerialization` & `AFURLResponseSerialization` protocols, offering a concrete base implementation of query string / URL form-encoded parameter serialization and default request headers, as well as response status code and content type validation.
93 |
94 | Any request or response serializer dealing with HTTP is encouraged to subclass `AFHTTPRequestSerializer` in order to ensure consistent default behavior.
95 | */
96 | @interface AFHTTPRequestSerializer : NSObject
97 |
98 | /**
99 | The string encoding used to serialize parameters. `NSUTF8StringEncoding` by default.
100 | */
101 | @property (nonatomic, assign) NSStringEncoding stringEncoding;
102 |
103 | /**
104 | Whether created requests can use the device’s cellular radio (if present). `YES` by default.
105 |
106 | @see NSMutableURLRequest -setAllowsCellularAccess:
107 | */
108 | @property (nonatomic, assign) BOOL allowsCellularAccess;
109 |
110 | /**
111 | The cache policy of created requests. `NSURLRequestUseProtocolCachePolicy` by default.
112 |
113 | @see NSMutableURLRequest -setCachePolicy:
114 | */
115 | @property (nonatomic, assign) NSURLRequestCachePolicy cachePolicy;
116 |
117 | /**
118 | Whether created requests should use the default cookie handling. `YES` by default.
119 |
120 | @see NSMutableURLRequest -setHTTPShouldHandleCookies:
121 | */
122 | @property (nonatomic, assign) BOOL HTTPShouldHandleCookies;
123 |
124 | /**
125 | Whether created requests can continue transmitting data before receiving a response from an earlier transmission. `NO` by default
126 |
127 | @see NSMutableURLRequest -setHTTPShouldUsePipelining:
128 | */
129 | @property (nonatomic, assign) BOOL HTTPShouldUsePipelining;
130 |
131 | /**
132 | The network service type for created requests. `NSURLNetworkServiceTypeDefault` by default.
133 |
134 | @see NSMutableURLRequest -setNetworkServiceType:
135 | */
136 | @property (nonatomic, assign) NSURLRequestNetworkServiceType networkServiceType;
137 |
138 | /**
139 | The timeout interval, in seconds, for created requests. The default timeout interval is 60 seconds.
140 |
141 | @see NSMutableURLRequest -setTimeoutInterval:
142 | */
143 | @property (nonatomic, assign) NSTimeInterval timeoutInterval;
144 |
145 | ///---------------------------------------
146 | /// @name Configuring HTTP Request Headers
147 | ///---------------------------------------
148 |
149 | /**
150 | Default HTTP header field values to be applied to serialized requests. By default, these include the following:
151 |
152 | - `Accept-Language` with the contents of `NSLocale +preferredLanguages`
153 | - `User-Agent` with the contents of various bundle identifiers and OS designations
154 |
155 | @discussion To add or remove default request headers, use `setValue:forHTTPHeaderField:`.
156 | */
157 | @property (readonly, nonatomic, strong) NSDictionary *HTTPRequestHeaders;
158 |
159 | /**
160 | Creates and returns a serializer with default configuration.
161 | */
162 | + (instancetype)serializer;
163 |
164 | /**
165 | Sets the value for the HTTP headers set in request objects made by the HTTP client. If `nil`, removes the existing value for that header.
166 |
167 | @param field The HTTP header to set a default value for
168 | @param value The value set as default for the specified header, or `nil`
169 | */
170 | - (void)setValue:(nullable NSString *)value
171 | forHTTPHeaderField:(NSString *)field;
172 |
173 | /**
174 | Returns the value for the HTTP headers set in the request serializer.
175 |
176 | @param field The HTTP header to retrieve the default value for
177 |
178 | @return The value set as default for the specified header, or `nil`
179 | */
180 | - (nullable NSString *)valueForHTTPHeaderField:(NSString *)field;
181 |
182 | /**
183 | Sets the "Authorization" HTTP header set in request objects made by the HTTP client to a basic authentication value with Base64-encoded username and password. This overwrites any existing value for this header.
184 |
185 | @param username The HTTP basic auth username
186 | @param password The HTTP basic auth password
187 | */
188 | - (void)setAuthorizationHeaderFieldWithUsername:(NSString *)username
189 | password:(NSString *)password;
190 |
191 | /**
192 | Clears any existing value for the "Authorization" HTTP header.
193 | */
194 | - (void)clearAuthorizationHeader;
195 |
196 | ///-------------------------------------------------------
197 | /// @name Configuring Query String Parameter Serialization
198 | ///-------------------------------------------------------
199 |
200 | /**
201 | HTTP methods for which serialized requests will encode parameters as a query string. `GET`, `HEAD`, and `DELETE` by default.
202 | */
203 | @property (nonatomic, strong) NSSet *HTTPMethodsEncodingParametersInURI;
204 |
205 | /**
206 | Set the method of query string serialization according to one of the pre-defined styles.
207 |
208 | @param style The serialization style.
209 |
210 | @see AFHTTPRequestQueryStringSerializationStyle
211 | */
212 | - (void)setQueryStringSerializationWithStyle:(AFHTTPRequestQueryStringSerializationStyle)style;
213 |
214 | /**
215 | Set the a custom method of query string serialization according to the specified block.
216 |
217 | @param block A block that defines a process of encoding parameters into a query string. This block returns the query string and takes three arguments: the request, the parameters to encode, and the error that occurred when attempting to encode parameters for the given request.
218 | */
219 | - (void)setQueryStringSerializationWithBlock:(nullable NSString * (^)(NSURLRequest *request, id parameters, NSError * __autoreleasing *error))block;
220 |
221 | ///-------------------------------
222 | /// @name Creating Request Objects
223 | ///-------------------------------
224 |
225 | /**
226 | Creates an `NSMutableURLRequest` object with the specified HTTP method and URL string.
227 |
228 | If the HTTP method is `GET`, `HEAD`, or `DELETE`, the parameters will be used to construct a url-encoded query string that is appended to the request's URL. Otherwise, the parameters will be encoded according to the value of the `parameterEncoding` property, and set as the request body.
229 |
230 | @param method The HTTP method for the request, such as `GET`, `POST`, `PUT`, or `DELETE`. This parameter must not be `nil`.
231 | @param URLString The URL string used to create the request URL.
232 | @param parameters The parameters to be either set as a query string for `GET` requests, or the request HTTP body.
233 | @param error The error that occurred while constructing the request.
234 |
235 | @return An `NSMutableURLRequest` object.
236 | */
237 | - (NSMutableURLRequest *)requestWithMethod:(NSString *)method
238 | URLString:(NSString *)URLString
239 | parameters:(nullable id)parameters
240 | error:(NSError * _Nullable __autoreleasing *)error;
241 |
242 | /**
243 | Creates an `NSMutableURLRequest` object with the specified HTTP method and URLString, and constructs a `multipart/form-data` HTTP body, using the specified parameters and multipart form data block. See http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.2
244 |
245 | Multipart form requests are automatically streamed, reading files directly from disk along with in-memory data in a single HTTP body. The resulting `NSMutableURLRequest` object has an `HTTPBodyStream` property, so refrain from setting `HTTPBodyStream` or `HTTPBody` on this request object, as it will clear out the multipart form body stream.
246 |
247 | @param method The HTTP method for the request. This parameter must not be `GET` or `HEAD`, or `nil`.
248 | @param URLString The URL string used to create the request URL.
249 | @param parameters The parameters to be encoded and set in the request HTTP body.
250 | @param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol.
251 | @param error The error that occurred while constructing the request.
252 |
253 | @return An `NSMutableURLRequest` object
254 | */
255 | - (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method
256 | URLString:(NSString *)URLString
257 | parameters:(nullable NSDictionary *)parameters
258 | constructingBodyWithBlock:(nullable void (^)(id formData))block
259 | error:(NSError * _Nullable __autoreleasing *)error;
260 |
261 | /**
262 | Creates an `NSMutableURLRequest` by removing the `HTTPBodyStream` from a request, and asynchronously writing its contents into the specified file, invoking the completion handler when finished.
263 |
264 | @param request The multipart form request. The `HTTPBodyStream` property of `request` must not be `nil`.
265 | @param fileURL The file URL to write multipart form contents to.
266 | @param handler A handler block to execute.
267 |
268 | @discussion There is a bug in `NSURLSessionTask` that causes requests to not send a `Content-Length` header when streaming contents from an HTTP body, which is notably problematic when interacting with the Amazon S3 webservice. As a workaround, this method takes a request constructed with `multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:error:`, or any other request with an `HTTPBodyStream`, writes the contents to the specified file and returns a copy of the original request with the `HTTPBodyStream` property set to `nil`. From here, the file can either be passed to `AFURLSessionManager -uploadTaskWithRequest:fromFile:progress:completionHandler:`, or have its contents read into an `NSData` that's assigned to the `HTTPBody` property of the request.
269 |
270 | @see https://github.com/AFNetworking/AFNetworking/issues/1398
271 | */
272 | - (NSMutableURLRequest *)requestWithMultipartFormRequest:(NSURLRequest *)request
273 | writingStreamContentsToFile:(NSURL *)fileURL
274 | completionHandler:(nullable void (^)(NSError * _Nullable error))handler;
275 |
276 | @end
277 |
278 | #pragma mark -
279 |
280 | /**
281 | The `AFMultipartFormData` protocol defines the methods supported by the parameter in the block argument of `AFHTTPRequestSerializer -multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:`.
282 | */
283 | @protocol AFMultipartFormData
284 |
285 | /**
286 | Appends the HTTP header `Content-Disposition: file; filename=#{generated filename}; name=#{name}"` and `Content-Type: #{generated mimeType}`, followed by the encoded file data and the multipart form boundary.
287 |
288 | The filename and MIME type for this data in the form will be automatically generated, using the last path component of the `fileURL` and system associated MIME type for the `fileURL` extension, respectively.
289 |
290 | @param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`.
291 | @param name The name to be associated with the specified data. This parameter must not be `nil`.
292 | @param error If an error occurs, upon return contains an `NSError` object that describes the problem.
293 |
294 | @return `YES` if the file data was successfully appended, otherwise `NO`.
295 | */
296 | - (BOOL)appendPartWithFileURL:(NSURL *)fileURL
297 | name:(NSString *)name
298 | error:(NSError * _Nullable __autoreleasing *)error;
299 |
300 | /**
301 | Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary.
302 |
303 | @param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`.
304 | @param name The name to be associated with the specified data. This parameter must not be `nil`.
305 | @param fileName The file name to be used in the `Content-Disposition` header. This parameter must not be `nil`.
306 | @param mimeType The declared MIME type of the file data. This parameter must not be `nil`.
307 | @param error If an error occurs, upon return contains an `NSError` object that describes the problem.
308 |
309 | @return `YES` if the file data was successfully appended otherwise `NO`.
310 | */
311 | - (BOOL)appendPartWithFileURL:(NSURL *)fileURL
312 | name:(NSString *)name
313 | fileName:(NSString *)fileName
314 | mimeType:(NSString *)mimeType
315 | error:(NSError * _Nullable __autoreleasing *)error;
316 |
317 | /**
318 | Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the data from the input stream and the multipart form boundary.
319 |
320 | @param inputStream The input stream to be appended to the form data
321 | @param name The name to be associated with the specified input stream. This parameter must not be `nil`.
322 | @param fileName The filename to be associated with the specified input stream. This parameter must not be `nil`.
323 | @param length The length of the specified input stream in bytes.
324 | @param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`.
325 | */
326 | - (void)appendPartWithInputStream:(nullable NSInputStream *)inputStream
327 | name:(NSString *)name
328 | fileName:(NSString *)fileName
329 | length:(int64_t)length
330 | mimeType:(NSString *)mimeType;
331 |
332 | /**
333 | Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary.
334 |
335 | @param data The data to be encoded and appended to the form data.
336 | @param name The name to be associated with the specified data. This parameter must not be `nil`.
337 | @param fileName The filename to be associated with the specified data. This parameter must not be `nil`.
338 | @param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`.
339 | */
340 | - (void)appendPartWithFileData:(NSData *)data
341 | name:(NSString *)name
342 | fileName:(NSString *)fileName
343 | mimeType:(NSString *)mimeType;
344 |
345 | /**
346 | Appends the HTTP headers `Content-Disposition: form-data; name=#{name}"`, followed by the encoded data and the multipart form boundary.
347 |
348 | @param data The data to be encoded and appended to the form data.
349 | @param name The name to be associated with the specified data. This parameter must not be `nil`.
350 | */
351 |
352 | - (void)appendPartWithFormData:(NSData *)data
353 | name:(NSString *)name;
354 |
355 |
356 | /**
357 | Appends HTTP headers, followed by the encoded data and the multipart form boundary.
358 |
359 | @param headers The HTTP headers to be appended to the form data.
360 | @param body The data to be encoded and appended to the form data. This parameter must not be `nil`.
361 | */
362 | - (void)appendPartWithHeaders:(nullable NSDictionary *)headers
363 | body:(NSData *)body;
364 |
365 | /**
366 | Throttles request bandwidth by limiting the packet size and adding a delay for each chunk read from the upload stream.
367 |
368 | When uploading over a 3G or EDGE connection, requests may fail with "request body stream exhausted". Setting a maximum packet size and delay according to the recommended values (`kAFUploadStream3GSuggestedPacketSize` and `kAFUploadStream3GSuggestedDelay`) lowers the risk of the input stream exceeding its allocated bandwidth. Unfortunately, there is no definite way to distinguish between a 3G, EDGE, or LTE connection over `NSURLConnection`. As such, it is not recommended that you throttle bandwidth based solely on network reachability. Instead, you should consider checking for the "request body stream exhausted" in a failure block, and then retrying the request with throttled bandwidth.
369 |
370 | @param numberOfBytes Maximum packet size, in number of bytes. The default packet size for an input stream is 16kb.
371 | @param delay Duration of delay each time a packet is read. By default, no delay is set.
372 | */
373 | - (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes
374 | delay:(NSTimeInterval)delay;
375 |
376 | @end
377 |
378 | #pragma mark -
379 |
380 | /**
381 | `AFJSONRequestSerializer` is a subclass of `AFHTTPRequestSerializer` that encodes parameters as JSON using `NSJSONSerialization`, setting the `Content-Type` of the encoded request to `application/json`.
382 | */
383 | @interface AFJSONRequestSerializer : AFHTTPRequestSerializer
384 |
385 | /**
386 | Options for writing the request JSON data from Foundation objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONWritingOptions". `0` by default.
387 | */
388 | @property (nonatomic, assign) NSJSONWritingOptions writingOptions;
389 |
390 | /**
391 | Creates and returns a JSON serializer with specified reading and writing options.
392 |
393 | @param writingOptions The specified JSON writing options.
394 | */
395 | + (instancetype)serializerWithWritingOptions:(NSJSONWritingOptions)writingOptions;
396 |
397 | @end
398 |
399 | #pragma mark -
400 |
401 | /**
402 | `AFPropertyListRequestSerializer` is a subclass of `AFHTTPRequestSerializer` that encodes parameters as JSON using `NSPropertyListSerializer`, setting the `Content-Type` of the encoded request to `application/x-plist`.
403 | */
404 | @interface AFPropertyListRequestSerializer : AFHTTPRequestSerializer
405 |
406 | /**
407 | The property list format. Possible values are described in "NSPropertyListFormat".
408 | */
409 | @property (nonatomic, assign) NSPropertyListFormat format;
410 |
411 | /**
412 | @warning The `writeOptions` property is currently unused.
413 | */
414 | @property (nonatomic, assign) NSPropertyListWriteOptions writeOptions;
415 |
416 | /**
417 | Creates and returns a property list serializer with a specified format, read options, and write options.
418 |
419 | @param format The property list format.
420 | @param writeOptions The property list write options.
421 |
422 | @warning The `writeOptions` property is currently unused.
423 | */
424 | + (instancetype)serializerWithFormat:(NSPropertyListFormat)format
425 | writeOptions:(NSPropertyListWriteOptions)writeOptions;
426 |
427 | @end
428 |
429 | #pragma mark -
430 |
431 | ///----------------
432 | /// @name Constants
433 | ///----------------
434 |
435 | /**
436 | ## Error Domains
437 |
438 | The following error domain is predefined.
439 |
440 | - `NSString * const AFURLRequestSerializationErrorDomain`
441 |
442 | ### Constants
443 |
444 | `AFURLRequestSerializationErrorDomain`
445 | AFURLRequestSerializer errors. Error codes for `AFURLRequestSerializationErrorDomain` correspond to codes in `NSURLErrorDomain`.
446 | */
447 | FOUNDATION_EXPORT NSString * const AFURLRequestSerializationErrorDomain;
448 |
449 | /**
450 | ## User info dictionary keys
451 |
452 | These keys may exist in the user info dictionary, in addition to those defined for NSError.
453 |
454 | - `NSString * const AFNetworkingOperationFailingURLRequestErrorKey`
455 |
456 | ### Constants
457 |
458 | `AFNetworkingOperationFailingURLRequestErrorKey`
459 | The corresponding value is an `NSURLRequest` containing the request of the operation associated with an error. This key is only present in the `AFURLRequestSerializationErrorDomain`.
460 | */
461 | FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLRequestErrorKey;
462 |
463 | /**
464 | ## Throttling Bandwidth for HTTP Request Input Streams
465 |
466 | @see -throttleBandwidthWithPacketSize:delay:
467 |
468 | ### Constants
469 |
470 | `kAFUploadStream3GSuggestedPacketSize`
471 | Maximum packet size, in number of bytes. Equal to 16kb.
472 |
473 | `kAFUploadStream3GSuggestedDelay`
474 | Duration of delay each time a packet is read. Equal to 0.2 seconds.
475 | */
476 | FOUNDATION_EXPORT NSUInteger const kAFUploadStream3GSuggestedPacketSize;
477 | FOUNDATION_EXPORT NSTimeInterval const kAFUploadStream3GSuggestedDelay;
478 |
479 | NS_ASSUME_NONNULL_END
480 |
--------------------------------------------------------------------------------
/Carthage/Build/iOS/AFNetworking.framework/Headers/AFURLResponseSerialization.h:
--------------------------------------------------------------------------------
1 | // AFURLResponseSerialization.h
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 | #import
24 |
25 | NS_ASSUME_NONNULL_BEGIN
26 |
27 | /**
28 | The `AFURLResponseSerialization` protocol is adopted by an object that decodes data into a more useful object representation, according to details in the server response. Response serializers may additionally perform validation on the incoming response and data.
29 |
30 | For example, a JSON response serializer may check for an acceptable status code (`2XX` range) and content type (`application/json`), decoding a valid JSON response into an object.
31 | */
32 | @protocol AFURLResponseSerialization
33 |
34 | /**
35 | The response object decoded from the data associated with a specified response.
36 |
37 | @param response The response to be processed.
38 | @param data The response data to be decoded.
39 | @param error The error that occurred while attempting to decode the response data.
40 |
41 | @return The object decoded from the specified response data.
42 | */
43 | - (nullable id)responseObjectForResponse:(nullable NSURLResponse *)response
44 | data:(nullable NSData *)data
45 | error:(NSError * _Nullable __autoreleasing *)error NS_SWIFT_NOTHROW;
46 |
47 | @end
48 |
49 | #pragma mark -
50 |
51 | /**
52 | `AFHTTPResponseSerializer` conforms to the `AFURLRequestSerialization` & `AFURLResponseSerialization` protocols, offering a concrete base implementation of query string / URL form-encoded parameter serialization and default request headers, as well as response status code and content type validation.
53 |
54 | Any request or response serializer dealing with HTTP is encouraged to subclass `AFHTTPResponseSerializer` in order to ensure consistent default behavior.
55 | */
56 | @interface AFHTTPResponseSerializer : NSObject
57 |
58 | - (instancetype)init;
59 |
60 | @property (nonatomic, assign) NSStringEncoding stringEncoding DEPRECATED_MSG_ATTRIBUTE("The string encoding is never used. AFHTTPResponseSerializer only validates status codes and content types but does not try to decode the received data in any way.");
61 |
62 | /**
63 | Creates and returns a serializer with default configuration.
64 | */
65 | + (instancetype)serializer;
66 |
67 | ///-----------------------------------------
68 | /// @name Configuring Response Serialization
69 | ///-----------------------------------------
70 |
71 | /**
72 | The acceptable HTTP status codes for responses. When non-`nil`, responses with status codes not contained by the set will result in an error during validation.
73 |
74 | See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
75 | */
76 | @property (nonatomic, copy, nullable) NSIndexSet *acceptableStatusCodes;
77 |
78 | /**
79 | The acceptable MIME types for responses. When non-`nil`, responses with a `Content-Type` with MIME types that do not intersect with the set will result in an error during validation.
80 | */
81 | @property (nonatomic, copy, nullable) NSSet *acceptableContentTypes;
82 |
83 | /**
84 | Validates the specified response and data.
85 |
86 | In its base implementation, this method checks for an acceptable status code and content type. Subclasses may wish to add other domain-specific checks.
87 |
88 | @param response The response to be validated.
89 | @param data The data associated with the response.
90 | @param error The error that occurred while attempting to validate the response.
91 |
92 | @return `YES` if the response is valid, otherwise `NO`.
93 | */
94 | - (BOOL)validateResponse:(nullable NSHTTPURLResponse *)response
95 | data:(nullable NSData *)data
96 | error:(NSError * _Nullable __autoreleasing *)error;
97 |
98 | @end
99 |
100 | #pragma mark -
101 |
102 |
103 | /**
104 | `AFJSONResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes JSON responses.
105 |
106 | By default, `AFJSONResponseSerializer` accepts the following MIME types, which includes the official standard, `application/json`, as well as other commonly-used types:
107 |
108 | - `application/json`
109 | - `text/json`
110 | - `text/javascript`
111 |
112 | In RFC 7159 - Section 8.1, it states that JSON text is required to be encoded in UTF-8, UTF-16, or UTF-32, and the default encoding is UTF-8. NSJSONSerialization provides support for all the encodings listed in the specification, and recommends UTF-8 for efficiency. Using an unsupported encoding will result in serialization error. See the `NSJSONSerialization` documentation for more details.
113 | */
114 | @interface AFJSONResponseSerializer : AFHTTPResponseSerializer
115 |
116 | - (instancetype)init;
117 |
118 | /**
119 | Options for reading the response JSON data and creating the Foundation objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONReadingOptions". `0` by default.
120 | */
121 | @property (nonatomic, assign) NSJSONReadingOptions readingOptions;
122 |
123 | /**
124 | Whether to remove keys with `NSNull` values from response JSON. Defaults to `NO`.
125 | */
126 | @property (nonatomic, assign) BOOL removesKeysWithNullValues;
127 |
128 | /**
129 | Creates and returns a JSON serializer with specified reading and writing options.
130 |
131 | @param readingOptions The specified JSON reading options.
132 | */
133 | + (instancetype)serializerWithReadingOptions:(NSJSONReadingOptions)readingOptions;
134 |
135 | @end
136 |
137 | #pragma mark -
138 |
139 | /**
140 | `AFXMLParserResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLParser` objects.
141 |
142 | By default, `AFXMLParserResponseSerializer` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types:
143 |
144 | - `application/xml`
145 | - `text/xml`
146 | */
147 | @interface AFXMLParserResponseSerializer : AFHTTPResponseSerializer
148 |
149 | @end
150 |
151 | #pragma mark -
152 |
153 | #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
154 |
155 | /**
156 | `AFXMLDocumentResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLDocument` objects.
157 |
158 | By default, `AFXMLDocumentResponseSerializer` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types:
159 |
160 | - `application/xml`
161 | - `text/xml`
162 | */
163 | @interface AFXMLDocumentResponseSerializer : AFHTTPResponseSerializer
164 |
165 | - (instancetype)init;
166 |
167 | /**
168 | Input and output options specifically intended for `NSXMLDocument` objects. For possible values, see the `NSXMLDocument` documentation section "Input and Output Options". `0` by default.
169 | */
170 | @property (nonatomic, assign) NSUInteger options;
171 |
172 | /**
173 | Creates and returns an XML document serializer with the specified options.
174 |
175 | @param mask The XML document options.
176 | */
177 | + (instancetype)serializerWithXMLDocumentOptions:(NSUInteger)mask;
178 |
179 | @end
180 |
181 | #endif
182 |
183 | #pragma mark -
184 |
185 | /**
186 | `AFPropertyListResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLDocument` objects.
187 |
188 | By default, `AFPropertyListResponseSerializer` accepts the following MIME types:
189 |
190 | - `application/x-plist`
191 | */
192 | @interface AFPropertyListResponseSerializer : AFHTTPResponseSerializer
193 |
194 | - (instancetype)init;
195 |
196 | /**
197 | The property list format. Possible values are described in "NSPropertyListFormat".
198 | */
199 | @property (nonatomic, assign) NSPropertyListFormat format;
200 |
201 | /**
202 | The property list reading options. Possible values are described in "NSPropertyListMutabilityOptions."
203 | */
204 | @property (nonatomic, assign) NSPropertyListReadOptions readOptions;
205 |
206 | /**
207 | Creates and returns a property list serializer with a specified format, read options, and write options.
208 |
209 | @param format The property list format.
210 | @param readOptions The property list reading options.
211 | */
212 | + (instancetype)serializerWithFormat:(NSPropertyListFormat)format
213 | readOptions:(NSPropertyListReadOptions)readOptions;
214 |
215 | @end
216 |
217 | #pragma mark -
218 |
219 | /**
220 | `AFImageResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes image responses.
221 |
222 | By default, `AFImageResponseSerializer` accepts the following MIME types, which correspond to the image formats supported by UIImage or NSImage:
223 |
224 | - `image/tiff`
225 | - `image/jpeg`
226 | - `image/gif`
227 | - `image/png`
228 | - `image/ico`
229 | - `image/x-icon`
230 | - `image/bmp`
231 | - `image/x-bmp`
232 | - `image/x-xbitmap`
233 | - `image/x-win-bitmap`
234 | */
235 | @interface AFImageResponseSerializer : AFHTTPResponseSerializer
236 |
237 | #if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH
238 | /**
239 | The scale factor used when interpreting the image data to construct `responseImage`. Specifying a scale factor of 1.0 results in an image whose size matches the pixel-based dimensions of the image. Applying a different scale factor changes the size of the image as reported by the size property. This is set to the value of scale of the main screen by default, which automatically scales images for retina displays, for instance.
240 | */
241 | @property (nonatomic, assign) CGFloat imageScale;
242 |
243 | /**
244 | Whether to automatically inflate response image data for compressed formats (such as PNG or JPEG). Enabling this can significantly improve drawing performance on iOS when used with `setCompletionBlockWithSuccess:failure:`, as it allows a bitmap representation to be constructed in the background rather than on the main thread. `YES` by default.
245 | */
246 | @property (nonatomic, assign) BOOL automaticallyInflatesResponseImage;
247 | #endif
248 |
249 | @end
250 |
251 | #pragma mark -
252 |
253 | /**
254 | `AFCompoundSerializer` is a subclass of `AFHTTPResponseSerializer` that delegates the response serialization to the first `AFHTTPResponseSerializer` object that returns an object for `responseObjectForResponse:data:error:`, falling back on the default behavior of `AFHTTPResponseSerializer`. This is useful for supporting multiple potential types and structures of server responses with a single serializer.
255 | */
256 | @interface AFCompoundResponseSerializer : AFHTTPResponseSerializer
257 |
258 | /**
259 | The component response serializers.
260 | */
261 | @property (readonly, nonatomic, copy) NSArray > *responseSerializers;
262 |
263 | /**
264 | Creates and returns a compound serializer comprised of the specified response serializers.
265 |
266 | @warning Each response serializer specified must be a subclass of `AFHTTPResponseSerializer`, and response to `-validateResponse:data:error:`.
267 | */
268 | + (instancetype)compoundSerializerWithResponseSerializers:(NSArray > *)responseSerializers;
269 |
270 | @end
271 |
272 | ///----------------
273 | /// @name Constants
274 | ///----------------
275 |
276 | /**
277 | ## Error Domains
278 |
279 | The following error domain is predefined.
280 |
281 | - `NSString * const AFURLResponseSerializationErrorDomain`
282 |
283 | ### Constants
284 |
285 | `AFURLResponseSerializationErrorDomain`
286 | AFURLResponseSerializer errors. Error codes for `AFURLResponseSerializationErrorDomain` correspond to codes in `NSURLErrorDomain`.
287 | */
288 | FOUNDATION_EXPORT NSString * const AFURLResponseSerializationErrorDomain;
289 |
290 | /**
291 | ## User info dictionary keys
292 |
293 | These keys may exist in the user info dictionary, in addition to those defined for NSError.
294 |
295 | - `NSString * const AFNetworkingOperationFailingURLResponseErrorKey`
296 | - `NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey`
297 |
298 | ### Constants
299 |
300 | `AFNetworkingOperationFailingURLResponseErrorKey`
301 | The corresponding value is an `NSURLResponse` containing the response of the operation associated with an error. This key is only present in the `AFURLResponseSerializationErrorDomain`.
302 |
303 | `AFNetworkingOperationFailingURLResponseDataErrorKey`
304 | The corresponding value is an `NSData` containing the original data of the operation associated with an error. This key is only present in the `AFURLResponseSerializationErrorDomain`.
305 | */
306 | FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLResponseErrorKey;
307 |
308 | FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey;
309 |
310 | NS_ASSUME_NONNULL_END
311 |
--------------------------------------------------------------------------------
/Carthage/Build/iOS/AFNetworking.framework/Headers/UIActivityIndicatorView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | // UIActivityIndicatorView+AFNetworking.h
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 |
24 | #import
25 |
26 | #if TARGET_OS_IOS || TARGET_OS_TV
27 |
28 | #import
29 |
30 | /**
31 | This category adds methods to the UIKit framework's `UIActivityIndicatorView` class. The methods in this category provide support for automatically starting and stopping animation depending on the loading state of a session task.
32 | */
33 | @interface UIActivityIndicatorView (AFNetworking)
34 |
35 | ///----------------------------------
36 | /// @name Animating for Session Tasks
37 | ///----------------------------------
38 |
39 | /**
40 | Binds the animating state to the state of the specified task.
41 |
42 | @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled.
43 | */
44 | - (void)setAnimatingWithStateOfTask:(nullable NSURLSessionTask *)task;
45 |
46 | @end
47 |
48 | #endif
49 |
--------------------------------------------------------------------------------
/Carthage/Build/iOS/AFNetworking.framework/Headers/UIButton+AFNetworking.h:
--------------------------------------------------------------------------------
1 | // UIButton+AFNetworking.h
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 |
24 | #import
25 |
26 | #if TARGET_OS_IOS || TARGET_OS_TV
27 |
28 | #import
29 |
30 | NS_ASSUME_NONNULL_BEGIN
31 |
32 | @class AFImageDownloader;
33 |
34 | /**
35 | This category adds methods to the UIKit framework's `UIButton` class. The methods in this category provide support for loading remote images and background images asynchronously from a URL.
36 |
37 | @warning Compound values for control `state` (such as `UIControlStateHighlighted | UIControlStateDisabled`) are unsupported.
38 | */
39 | @interface UIButton (AFNetworking)
40 |
41 | ///------------------------------------
42 | /// @name Accessing the Image Downloader
43 | ///------------------------------------
44 |
45 | /**
46 | Set the shared image downloader used to download images.
47 |
48 | @param imageDownloader The shared image downloader used to download images.
49 | */
50 | + (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader;
51 |
52 | /**
53 | The shared image downloader used to download images.
54 | */
55 | + (AFImageDownloader *)sharedImageDownloader;
56 |
57 | ///--------------------
58 | /// @name Setting Image
59 | ///--------------------
60 |
61 | /**
62 | Asynchronously downloads an image from the specified URL, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled.
63 |
64 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
65 |
66 | @param state The control state.
67 | @param url The URL used for the image request.
68 | */
69 | - (void)setImageForState:(UIControlState)state
70 | withURL:(NSURL *)url;
71 |
72 | /**
73 | Asynchronously downloads an image from the specified URL, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled.
74 |
75 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
76 |
77 | @param state The control state.
78 | @param url The URL used for the image request.
79 | @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the button will not change its image until the image request finishes.
80 | */
81 | - (void)setImageForState:(UIControlState)state
82 | withURL:(NSURL *)url
83 | placeholderImage:(nullable UIImage *)placeholderImage;
84 |
85 | /**
86 | Asynchronously downloads an image from the specified URL request, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled.
87 |
88 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
89 |
90 | If a success block is specified, it is the responsibility of the block to set the image of the button before returning. If no success block is specified, the default behavior of setting the image with `setImage:forState:` is applied.
91 |
92 | @param state The control state.
93 | @param urlRequest The URL request used for the image request.
94 | @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the button will not change its image until the image request finishes.
95 | @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`.
96 | @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred.
97 | */
98 | - (void)setImageForState:(UIControlState)state
99 | withURLRequest:(NSURLRequest *)urlRequest
100 | placeholderImage:(nullable UIImage *)placeholderImage
101 | success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success
102 | failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure;
103 |
104 |
105 | ///-------------------------------
106 | /// @name Setting Background Image
107 | ///-------------------------------
108 |
109 | /**
110 | Asynchronously downloads an image from the specified URL, and sets it as the background image for the specified state once the request is finished. Any previous background image request for the receiver will be cancelled.
111 |
112 | If the background image is cached locally, the background image is set immediately, otherwise the specified placeholder background image will be set immediately, and then the remote background image will be set once the request is finished.
113 |
114 | @param state The control state.
115 | @param url The URL used for the background image request.
116 | */
117 | - (void)setBackgroundImageForState:(UIControlState)state
118 | withURL:(NSURL *)url;
119 |
120 | /**
121 | Asynchronously downloads an image from the specified URL, and sets it as the background image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled.
122 |
123 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
124 |
125 | @param state The control state.
126 | @param url The URL used for the background image request.
127 | @param placeholderImage The background image to be set initially, until the background image request finishes. If `nil`, the button will not change its background image until the background image request finishes.
128 | */
129 | - (void)setBackgroundImageForState:(UIControlState)state
130 | withURL:(NSURL *)url
131 | placeholderImage:(nullable UIImage *)placeholderImage;
132 |
133 | /**
134 | Asynchronously downloads an image from the specified URL request, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled.
135 |
136 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
137 |
138 | If a success block is specified, it is the responsibility of the block to set the image of the button before returning. If no success block is specified, the default behavior of setting the image with `setBackgroundImage:forState:` is applied.
139 |
140 | @param state The control state.
141 | @param urlRequest The URL request used for the image request.
142 | @param placeholderImage The background image to be set initially, until the background image request finishes. If `nil`, the button will not change its background image until the background image request finishes.
143 | @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`.
144 | @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred.
145 | */
146 | - (void)setBackgroundImageForState:(UIControlState)state
147 | withURLRequest:(NSURLRequest *)urlRequest
148 | placeholderImage:(nullable UIImage *)placeholderImage
149 | success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success
150 | failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure;
151 |
152 |
153 | ///------------------------------
154 | /// @name Canceling Image Loading
155 | ///------------------------------
156 |
157 | /**
158 | Cancels any executing image task for the specified control state of the receiver, if one exists.
159 |
160 | @param state The control state.
161 | */
162 | - (void)cancelImageDownloadTaskForState:(UIControlState)state;
163 |
164 | /**
165 | Cancels any executing background image task for the specified control state of the receiver, if one exists.
166 |
167 | @param state The control state.
168 | */
169 | - (void)cancelBackgroundImageDownloadTaskForState:(UIControlState)state;
170 |
171 | @end
172 |
173 | NS_ASSUME_NONNULL_END
174 |
175 | #endif
176 |
--------------------------------------------------------------------------------
/Carthage/Build/iOS/AFNetworking.framework/Headers/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 TARGET_OS_IOS || TARGET_OS_TV
26 |
27 | #import
28 |
29 | @interface UIImage (AFNetworking)
30 |
31 | + (UIImage*) safeImageWithData:(NSData*)data;
32 |
33 | @end
34 |
35 | #endif
36 |
--------------------------------------------------------------------------------
/Carthage/Build/iOS/AFNetworking.framework/Headers/UIImageView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | // UIImageView+AFNetworking.h
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 |
24 | #import
25 |
26 | #if TARGET_OS_IOS || TARGET_OS_TV
27 |
28 | #import
29 |
30 | NS_ASSUME_NONNULL_BEGIN
31 |
32 | @class AFImageDownloader;
33 |
34 | /**
35 | This category adds methods to the UIKit framework's `UIImageView` class. The methods in this category provide support for loading remote images asynchronously from a URL.
36 | */
37 | @interface UIImageView (AFNetworking)
38 |
39 | ///------------------------------------
40 | /// @name Accessing the Image Downloader
41 | ///------------------------------------
42 |
43 | /**
44 | Set the shared image downloader used to download images.
45 |
46 | @param imageDownloader The shared image downloader used to download images.
47 | */
48 | + (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader;
49 |
50 | /**
51 | The shared image downloader used to download images.
52 | */
53 | + (AFImageDownloader *)sharedImageDownloader;
54 |
55 | ///--------------------
56 | /// @name Setting Image
57 | ///--------------------
58 |
59 | /**
60 | Asynchronously downloads an image from the specified URL, and sets it once the request is finished. Any previous image request for the receiver will be cancelled.
61 |
62 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
63 |
64 | By default, URL requests have a `Accept` header field value of "image / *", a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:`
65 |
66 | @param url The URL used for the image request.
67 | */
68 | - (void)setImageWithURL:(NSURL *)url;
69 |
70 | /**
71 | Asynchronously downloads an image from the specified URL, and sets it once the request is finished. Any previous image request for the receiver will be cancelled.
72 |
73 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
74 |
75 | By default, URL requests have a `Accept` header field value of "image / *", a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:`
76 |
77 | @param url The URL used for the image request.
78 | @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes.
79 | */
80 | - (void)setImageWithURL:(NSURL *)url
81 | placeholderImage:(nullable UIImage *)placeholderImage;
82 |
83 | /**
84 | Asynchronously downloads an image from the specified URL request, and sets it once the request is finished. Any previous image request for the receiver will be cancelled.
85 |
86 | If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished.
87 |
88 | If a success block is specified, it is the responsibility of the block to set the image of the image view before returning. If no success block is specified, the default behavior of setting the image with `self.image = image` is applied.
89 |
90 | @param urlRequest The URL request used for the image request.
91 | @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes.
92 | @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`.
93 | @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred.
94 | */
95 | - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest
96 | placeholderImage:(nullable UIImage *)placeholderImage
97 | success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success
98 | failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure;
99 |
100 | /**
101 | Cancels any executing image operation for the receiver, if one exists.
102 | */
103 | - (void)cancelImageDownloadTask;
104 |
105 | @end
106 |
107 | NS_ASSUME_NONNULL_END
108 |
109 | #endif
110 |
--------------------------------------------------------------------------------
/Carthage/Build/iOS/AFNetworking.framework/Headers/UIProgressView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | // UIProgressView+AFNetworking.h
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 |
24 | #import
25 |
26 | #if TARGET_OS_IOS || TARGET_OS_TV
27 |
28 | #import
29 |
30 | NS_ASSUME_NONNULL_BEGIN
31 |
32 |
33 | /**
34 | This category adds methods to the UIKit framework's `UIProgressView` class. The methods in this category provide support for binding the progress to the upload and download progress of a session task.
35 | */
36 | @interface UIProgressView (AFNetworking)
37 |
38 | ///------------------------------------
39 | /// @name Setting Session Task Progress
40 | ///------------------------------------
41 |
42 | /**
43 | Binds the progress to the upload progress of the specified session task.
44 |
45 | @param task The session task.
46 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately.
47 | */
48 | - (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task
49 | animated:(BOOL)animated;
50 |
51 | /**
52 | Binds the progress to the download progress of the specified session task.
53 |
54 | @param task The session task.
55 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately.
56 | */
57 | - (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task
58 | animated:(BOOL)animated;
59 |
60 | @end
61 |
62 | NS_ASSUME_NONNULL_END
63 |
64 | #endif
65 |
--------------------------------------------------------------------------------
/Carthage/Build/iOS/AFNetworking.framework/Headers/UIRefreshControl+AFNetworking.h:
--------------------------------------------------------------------------------
1 | // UIRefreshControl+AFNetworking.m
2 | //
3 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
6 | // of this software and associated documentation files (the "Software"), to deal
7 | // in the Software without restriction, including without limitation the rights
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | // copies of the Software, and to permit persons to whom the Software is
10 | // furnished to do so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in
13 | // all copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | // THE SOFTWARE.
22 |
23 | #import
24 |
25 | #import
26 |
27 | #if TARGET_OS_IOS
28 |
29 | #import
30 |
31 | NS_ASSUME_NONNULL_BEGIN
32 |
33 | /**
34 | This category adds methods to the UIKit framework's `UIRefreshControl` class. The methods in this category provide support for automatically beginning and ending refreshing depending on the loading state of a session task.
35 | */
36 | @interface UIRefreshControl (AFNetworking)
37 |
38 | ///-----------------------------------
39 | /// @name Refreshing for Session Tasks
40 | ///-----------------------------------
41 |
42 | /**
43 | Binds the refreshing state to the state of the specified task.
44 |
45 | @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled.
46 | */
47 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task;
48 |
49 | @end
50 |
51 | NS_ASSUME_NONNULL_END
52 |
53 | #endif
54 |
--------------------------------------------------------------------------------
/Carthage/Build/iOS/AFNetworking.framework/Headers/UIWebView+AFNetworking.h:
--------------------------------------------------------------------------------
1 | // UIWebView+AFNetworking.h
2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
3 | //
4 | // Permission is hereby granted, free of charge, to any person obtaining a copy
5 | // of this software and associated documentation files (the "Software"), to deal
6 | // in the Software without restriction, including without limitation the rights
7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | // copies of the Software, and to permit persons to whom the Software is
9 | // furnished to do so, subject to the following conditions:
10 | //
11 | // The above copyright notice and this permission notice shall be included in
12 | // all copies or substantial portions of the Software.
13 | //
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | // THE SOFTWARE.
21 |
22 | #import
23 |
24 | #import
25 |
26 | #if TARGET_OS_IOS
27 |
28 | #import
29 |
30 | NS_ASSUME_NONNULL_BEGIN
31 |
32 | @class AFHTTPSessionManager;
33 |
34 | /**
35 | This category adds methods to the UIKit framework's `UIWebView` class. The methods in this category provide increased control over the request cycle, including progress monitoring and success / failure handling.
36 |
37 | @discussion When using these category methods, make sure to assign `delegate` for the web view, which implements `–webView:shouldStartLoadWithRequest:navigationType:` appropriately. This allows for tapped links to be loaded through AFNetworking, and can ensure that `canGoBack` & `canGoForward` update their values correctly.
38 | */
39 | @interface UIWebView (AFNetworking)
40 |
41 | /**
42 | The session manager used to download all requests.
43 | */
44 | @property (nonatomic, strong) AFHTTPSessionManager *sessionManager;
45 |
46 | /**
47 | Asynchronously loads the specified request.
48 |
49 | @param request A URL request identifying the location of the content to load. This must not be `nil`.
50 | @param progress A progress object monitoring the current download progress.
51 | @param success A block object to be executed when the request finishes loading successfully. This block returns the HTML string to be loaded by the web view, and takes two arguments: the response, and the response string.
52 | @param failure A block object to be executed when the data task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred.
53 | */
54 | - (void)loadRequest:(NSURLRequest *)request
55 | progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress
56 | success:(nullable NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success
57 | failure:(nullable void (^)(NSError *error))failure;
58 |
59 | /**
60 | Asynchronously loads the data associated with a particular request with a specified MIME type and text encoding.
61 |
62 | @param request A URL request identifying the location of the content to load. This must not be `nil`.
63 | @param MIMEType The MIME type of the content. Defaults to the content type of the response if not specified.
64 | @param textEncodingName The IANA encoding name, as in `utf-8` or `utf-16`. Defaults to the response text encoding if not specified.
65 | @param progress A progress object monitoring the current download progress.
66 | @param success A block object to be executed when the request finishes loading successfully. This block returns the data to be loaded by the web view and takes two arguments: the response, and the downloaded data.
67 | @param failure A block object to be executed when the data task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred.
68 | */
69 | - (void)loadRequest:(NSURLRequest *)request
70 | MIMEType:(nullable NSString *)MIMEType
71 | textEncodingName:(nullable NSString *)textEncodingName
72 | progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress
73 | success:(nullable NSData * (^)(NSHTTPURLResponse *response, NSData *data))success
74 | failure:(nullable void (^)(NSError *error))failure;
75 |
76 | @end
77 |
78 | NS_ASSUME_NONNULL_END
79 |
80 | #endif
81 |
--------------------------------------------------------------------------------
/Carthage/Build/iOS/AFNetworking.framework/Info.plist:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awesome-tips/awesome-tips-ios-app/78eec7c0cb5b2c561f95b0016eb832e22f22b2ff/Carthage/Build/iOS/AFNetworking.framework/Info.plist
--------------------------------------------------------------------------------
/Carthage/Build/iOS/AFNetworking.framework/Modules/module.modulemap:
--------------------------------------------------------------------------------
1 | framework module AFNetworking {
2 | umbrella header "AFNetworking.h"
3 | export *
4 | module * { export * }
5 | }
--------------------------------------------------------------------------------
/Carthage/Build/iOS/XMNetworking.framework/Headers/XMCenter.h:
--------------------------------------------------------------------------------
1 | //
2 | // XMCenter.h
3 | // XMNetworking
4 | //
5 | // Created by Zubin Kang on 12/12/2016.
6 | // Copyright © 2016 XMNetworking. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "XMConst.h"
11 |
12 | NS_ASSUME_NONNULL_BEGIN
13 |
14 | @class XMConfig, XMEngine;
15 |
16 | /**
17 | `XMCenter` is a global central place to send and manage all network requests.
18 | `+center` method is used to creates a new `XMCenter` object,
19 | `+defaultCenter` method will return a default shared `XMCenter` singleton object.
20 |
21 | The class methods for `XMCenter` are invoked by `[XMCenter defaultCenter]`, which are recommend to use `Class Method` instead of manager a `XMCenter` yourself.
22 |
23 | Usage:
24 |
25 | (1) Config XMCenter
26 |
27 | [XMCenter setupConfig:^(XMConfig *config) {
28 | config.server = @"general server address";
29 | config.headers = @{@"general header": @"general header value"};
30 | config.parameters = @{@"general parameter": @"general parameter value"};
31 | config.callbackQueue = dispatch_get_main_queue(); // set callback dispatch queue
32 | }];
33 |
34 | [XMCenter setRequestProcessBlock:^(XMRequest *request) {
35 | // Do the custom request pre processing logic by yourself.
36 | }];
37 |
38 | [XMCenter setResponseProcessBlock:^(XMRequest *request, id responseObject, NSError *__autoreleasing *error) {
39 | // Do the custom response data processing logic by yourself.
40 | // You can assign the passed in `error` argument when error occurred, and the failure block will be called instead of success block.
41 | }];
42 |
43 | (2) Send a Request
44 |
45 | [XMCenter sendRequest:^(XMRequest *request) {
46 | request.server = @"server address"; // optional, if `nil`, the genneal server is used.
47 | request.api = @"api path";
48 | request.parameters = @{@"param1": @"value1", @"param2": @"value2"}; // and the general parameters will add to reqeust parameters.
49 | } onSuccess:^(id responseObject) {
50 | // success code here...
51 | } onFailure:^(NSError *error) {
52 | // failure code here...
53 | }];
54 |
55 | */
56 | @interface XMCenter : NSObject
57 |
58 | ///---------------------
59 | /// @name Initialization
60 | ///---------------------
61 |
62 | /**
63 | Creates and returns a new `XMCenter` object.
64 | */
65 | + (instancetype)center;
66 |
67 | /**
68 | Returns the default shared `XMCenter` singleton object.
69 | */
70 | + (instancetype)defaultCenter;
71 |
72 | ///-----------------------
73 | /// @name General Property
74 | ///-----------------------
75 |
76 | // NOTE: The following properties could only be assigned by `XMConfig` through invoking `-setupConfig:` method.
77 |
78 | /**
79 | The general server address for XMCenter, if XMRequest.server is `nil` and the XMRequest.useGeneralServer is `YES`, this property will be assigned to XMRequest.server.
80 | */
81 | @property (nonatomic, copy, nullable) NSString *generalServer;
82 |
83 | /**
84 | The general parameters for XMCenter, if XMRequest.useGeneralParameters is `YES` and this property is not empty, it will be appended to XMRequest.parameters.
85 | */
86 | @property (nonatomic, strong, nullable, readonly) NSMutableDictionary *generalParameters;
87 |
88 | /**
89 | The general headers for XMCenter, if XMRequest.useGeneralHeaders is `YES` and this property is not empty, it will be appended to XMRequest.headers.
90 | */
91 | @property (nonatomic, strong, nullable, readonly) NSMutableDictionary *generalHeaders;
92 |
93 | /**
94 | The general user info for XMCenter, if XMRequest.userInfo is `nil` and this property is not `nil`, it will be assigned to XMRequest.userInfo.
95 | */
96 | @property (nonatomic, strong, nullable) NSDictionary *generalUserInfo;
97 |
98 | /**
99 | The dispatch queue for callback blocks. If `NULL` (default), a private concurrent queue is used.
100 | */
101 | @property (nonatomic, strong, nullable) dispatch_queue_t callbackQueue;
102 |
103 | /**
104 | The global requests engine for current XMCenter object, `[XMEngine sharedEngine]` by default.
105 | */
106 | @property (nonatomic, strong) XMEngine *engine;
107 |
108 | /**
109 | Whether or not to print the request and response info in console, `NO` by default.
110 | */
111 | @property (nonatomic, assign) BOOL consoleLog;
112 |
113 | ///--------------------------------------------
114 | /// @name Instance Method to Configure XMCenter
115 | ///--------------------------------------------
116 |
117 | #pragma mark - Instance Method
118 |
119 | /**
120 | Method to config the XMCenter properties by a `XMConfig` object.
121 |
122 | @param block The config block to assign the values for `XMConfig` object.
123 | */
124 | - (void)setupConfig:(void(^)(XMConfig *config))block;
125 |
126 | /**
127 | Method to set custom request pre processing block for XMCenter.
128 |
129 | @param block The custom processing block (`XMCenterRequestProcessBlock`).
130 | */
131 | - (void)setRequestProcessBlock:(XMCenterRequestProcessBlock)block;
132 |
133 | /**
134 | Method to set custom response data processing block for XMCenter.
135 |
136 | @param block The custom processing block (`XMCenterResponseProcessBlock`).
137 | */
138 | - (void)setResponseProcessBlock:(XMCenterResponseProcessBlock)block;
139 |
140 | /**
141 | Method to set custom error processing block for XMCenter.
142 |
143 | @param block The custom processing block (`XMCenterErrorProcessBlock`).
144 | */
145 | - (void)setErrorProcessBlock:(XMCenterErrorProcessBlock)block;
146 |
147 | /**
148 | Sets the value for the general HTTP headers of XMCenter, If value is `nil`, it will remove the existing value for that header field.
149 |
150 | @param value The value to set for the specified header, or `nil`.
151 | @param field The HTTP header to set a value for.
152 | */
153 | - (void)setGeneralHeaderValue:(nullable NSString *)value forField:(NSString *)field;
154 |
155 | /**
156 | Sets the value for the general parameters of XMCenter, If value is `nil`, it will remove the existing value for that parameter key.
157 |
158 | @param value The value to set for the specified parameter, or `nil`.
159 | @param key The parameter key to set a value for.
160 | */
161 | - (void)setGeneralParameterValue:(nullable id)value forKey:(NSString *)key;
162 |
163 | ///---------------------------------------
164 | /// @name Instance Method to Send Requests
165 | ///---------------------------------------
166 |
167 | #pragma mark -
168 |
169 | /**
170 | Creates and runs a Normal `XMRequest`.
171 |
172 | @param configBlock The config block to setup context info for the new created XMRequest object.
173 | @return Unique identifier for the new running XMRequest object,`nil` for fail.
174 | */
175 | - (nullable NSString *)sendRequest:(XMRequestConfigBlock)configBlock;
176 |
177 | /**
178 | Creates and runs a Normal `XMRequest` with success block.
179 |
180 | NOTE: The success block will be called on `callbackQueue` of XMCenter.
181 |
182 | @param configBlock The config block to setup context info for the new created XMRequest object.
183 | @param successBlock Success callback block for the new created XMRequest object.
184 | @return Unique identifier for the new running XMRequest object,`nil` for fail.
185 | */
186 | - (nullable NSString *)sendRequest:(XMRequestConfigBlock)configBlock
187 | onSuccess:(nullable XMSuccessBlock)successBlock;
188 |
189 | /**
190 | Creates and runs a Normal `XMRequest` with failure block.
191 |
192 | NOTE: The failure block will be called on `callbackQueue` of XMCenter.
193 |
194 | @param configBlock The config block to setup context info for the new created XMRequest object.
195 | @param failureBlock Failure callback block for the new created XMRequest object.
196 | @return Unique identifier for the new running XMRequest object,`nil` for fail.
197 | */
198 | - (nullable NSString *)sendRequest:(XMRequestConfigBlock)configBlock
199 | onFailure:(nullable XMFailureBlock)failureBlock;
200 |
201 | /**
202 | Creates and runs a Normal `XMRequest` with finished block.
203 |
204 | NOTE: The finished block will be called on `callbackQueue` of XMCenter.
205 |
206 | @param configBlock The config block to setup context info for the new created XMRequest object.
207 | @param finishedBlock Finished callback block for the new created XMRequest object.
208 | @return Unique identifier for the new running XMRequest object,`nil` for fail.
209 | */
210 | - (nullable NSString *)sendRequest:(XMRequestConfigBlock)configBlock
211 | onFinished:(nullable XMFinishedBlock)finishedBlock;
212 |
213 | /**
214 | Creates and runs a Normal `XMRequest` with success/failure blocks.
215 |
216 | NOTE: The success/failure blocks will be called on `callbackQueue` of XMCenter.
217 |
218 | @param configBlock The config block to setup context info for the new created XMRequest object.
219 | @param successBlock Success callback block for the new created XMRequest object.
220 | @param failureBlock Failure callback block for the new created XMRequest object.
221 | @return Unique identifier for the new running XMRequest object,`nil` for fail.
222 | */
223 | - (nullable NSString *)sendRequest:(XMRequestConfigBlock)configBlock
224 | onSuccess:(nullable XMSuccessBlock)successBlock
225 | onFailure:(nullable XMFailureBlock)failureBlock;
226 |
227 | /**
228 | Creates and runs a Normal `XMRequest` with success/failure/finished blocks.
229 |
230 | NOTE: The success/failure/finished blocks will be called on `callbackQueue` of XMCenter.
231 |
232 | @param configBlock The config block to setup context info for the new created XMRequest object.
233 | @param successBlock Success callback block for the new created XMRequest object.
234 | @param failureBlock Failure callback block for the new created XMRequest object.
235 | @param finishedBlock Finished callback block for the new created XMRequest object.
236 | @return Unique identifier for the new running XMRequest object,`nil` for fail.
237 | */
238 | - (nullable NSString *)sendRequest:(XMRequestConfigBlock)configBlock
239 | onSuccess:(nullable XMSuccessBlock)successBlock
240 | onFailure:(nullable XMFailureBlock)failureBlock
241 | onFinished:(nullable XMFinishedBlock)finishedBlock;
242 |
243 | /**
244 | Creates and runs an Upload/Download `XMRequest` with progress/success/failure blocks.
245 |
246 | NOTE: The success/failure blocks will be called on `callbackQueue` of XMCenter.
247 | BUT !!! the progress block is called on the session queue, not the `callbackQueue` of XMCenter.
248 |
249 | @param configBlock The config block to setup context info for the new created XMRequest object.
250 | @param progressBlock Progress callback block for the new created XMRequest object.
251 | @param successBlock Success callback block for the new created XMRequest object.
252 | @param failureBlock Failure callback block for the new created XMRequest object.
253 | @return Unique identifier for the new running XMRequest object,`nil` for fail.
254 | */
255 | - (nullable NSString *)sendRequest:(XMRequestConfigBlock)configBlock
256 | onProgress:(nullable XMProgressBlock)progressBlock
257 | onSuccess:(nullable XMSuccessBlock)successBlock
258 | onFailure:(nullable XMFailureBlock)failureBlock;
259 |
260 | /**
261 | Creates and runs an Upload/Download `XMRequest` with progress/success/failure/finished blocks.
262 |
263 | NOTE: The success/failure/finished blocks will be called on `callbackQueue` of XMCenter.
264 | BUT !!! the progress block is called on the session queue, not the `callbackQueue` of XMCenter.
265 |
266 | @param configBlock The config block to setup context info for the new created XMRequest object.
267 | @param progressBlock Progress callback block for the new created XMRequest object.
268 | @param successBlock Success callback block for the new created XMRequest object.
269 | @param failureBlock Failure callback block for the new created XMRequest object.
270 | @param finishedBlock Finished callback block for the new created XMRequest object.
271 | @return Unique identifier for the new running XMRequest object,`nil` for fail.
272 | */
273 | - (nullable NSString *)sendRequest:(XMRequestConfigBlock)configBlock
274 | onProgress:(nullable XMProgressBlock)progressBlock
275 | onSuccess:(nullable XMSuccessBlock)successBlock
276 | onFailure:(nullable XMFailureBlock)failureBlock
277 | onFinished:(nullable XMFinishedBlock)finishedBlock;
278 |
279 | /**
280 | Creates and runs batch requests
281 |
282 | @param configBlock The config block to setup batch requests context info for the new created XMBatchRequest object.
283 | @param successBlock Success callback block called when all batch requests finished successfully.
284 | @param failureBlock Failure callback block called once a request error occured.
285 | @param finishedBlock Finished callback block for the new created XMBatchRequest object.
286 | @return Unique identifier for the new running XMBatchRequest object,`nil` for fail.
287 | */
288 | - (nullable NSString *)sendBatchRequest:(XMBatchRequestConfigBlock)configBlock
289 | onSuccess:(nullable XMBCSuccessBlock)successBlock
290 | onFailure:(nullable XMBCFailureBlock)failureBlock
291 | onFinished:(nullable XMBCFinishedBlock)finishedBlock;
292 |
293 | /**
294 | Creates and runs chain requests
295 |
296 | @param configBlock The config block to setup chain requests context info for the new created XMBatchRequest object.
297 | @param successBlock Success callback block called when all chain requests finished successfully.
298 | @param failureBlock Failure callback block called once a request error occured.
299 | @param finishedBlock Finished callback block for the new created XMChainRequest object.
300 | @return Unique identifier for the new running XMChainRequest object,`nil` for fail.
301 | */
302 | - (nullable NSString *)sendChainRequest:(XMChainRequestConfigBlock)configBlock
303 | onSuccess:(nullable XMBCSuccessBlock)successBlock
304 | onFailure:(nullable XMBCFailureBlock)failureBlock
305 | onFinished:(nullable XMBCFinishedBlock)finishedBlock;
306 |
307 | ///------------------------------------------
308 | /// @name Instance Method to Operate Requests
309 | ///------------------------------------------
310 |
311 | #pragma mark -
312 |
313 | /**
314 | Method to cancel a runnig request by identifier.
315 |
316 | @param identifier The unique identifier of a running request.
317 | */
318 | - (void)cancelRequest:(NSString *)identifier;
319 |
320 | /**
321 | Method to cancel a runnig request by identifier with a cancel block.
322 |
323 | NOTE: The cancel block is called on current thread who invoked the method, not the `callbackQueue` of XMCenter.
324 |
325 | @param identifier The unique identifier of a running request.
326 | @param cancelBlock The callback block to be executed after the running request is canceled. The canceled request object (if exist) will be passed in argument to the cancel block.
327 | */
328 | - (void)cancelRequest:(NSString *)identifier
329 | onCancel:(nullable XMCancelBlock)cancelBlock;
330 |
331 | /**
332 | Method to get a runnig request object matching to identifier.
333 |
334 | @param identifier The unique identifier of a running request.
335 | @return return The runing XMRequest/XMBatchRequest/XMChainRequest object (if exist) matching to identifier.
336 | */
337 | - (nullable id)getRequest:(NSString *)identifier;
338 |
339 | /**
340 | Method to get current network reachablity status.
341 |
342 | @return The network is reachable or not.
343 | */
344 | - (BOOL)isNetworkReachable;
345 |
346 | /**
347 | Method to get current network connection type.
348 |
349 | @return The network connection type, see `XMNetworkConnectionType` for details.
350 | */
351 | - (XMNetworkConnectionType)networkConnectionType;
352 |
353 | ///--------------------------------
354 | /// @name Class Method for XMCenter
355 | ///--------------------------------
356 |
357 | // NOTE: The following class method is invoke through the `[XMCenter defaultCenter]` singleton object.
358 |
359 | #pragma mark - Class Method
360 |
361 | + (void)setupConfig:(void(^)(XMConfig *config))block;
362 | + (void)setRequestProcessBlock:(XMCenterRequestProcessBlock)block;
363 | + (void)setResponseProcessBlock:(XMCenterResponseProcessBlock)block;
364 | + (void)setErrorProcessBlock:(XMCenterErrorProcessBlock)block;
365 | + (void)setGeneralHeaderValue:(nullable NSString *)value forField:(NSString *)field;
366 | + (void)setGeneralParameterValue:(nullable id)value forKey:(NSString *)key;
367 |
368 | #pragma mark -
369 |
370 | + (nullable NSString *)sendRequest:(XMRequestConfigBlock)configBlock;
371 |
372 | + (nullable NSString *)sendRequest:(XMRequestConfigBlock)configBlock
373 | onSuccess:(nullable XMSuccessBlock)successBlock;
374 |
375 | + (nullable NSString *)sendRequest:(XMRequestConfigBlock)configBlock
376 | onFailure:(nullable XMFailureBlock)failureBlock;
377 |
378 | + (nullable NSString *)sendRequest:(XMRequestConfigBlock)configBlock
379 | onFinished:(nullable XMFinishedBlock)finishedBlock;
380 |
381 | + (nullable NSString *)sendRequest:(XMRequestConfigBlock)configBlock
382 | onSuccess:(nullable XMSuccessBlock)successBlock
383 | onFailure:(nullable XMFailureBlock)failureBlock;
384 |
385 | + (nullable NSString *)sendRequest:(XMRequestConfigBlock)configBlock
386 | onSuccess:(nullable XMSuccessBlock)successBlock
387 | onFailure:(nullable XMFailureBlock)failureBlock
388 | onFinished:(nullable XMFinishedBlock)finishedBlock;
389 |
390 | + (nullable NSString *)sendRequest:(XMRequestConfigBlock)configBlock
391 | onProgress:(nullable XMProgressBlock)progressBlock
392 | onSuccess:(nullable XMSuccessBlock)successBlock
393 | onFailure:(nullable XMFailureBlock)failureBlock;
394 |
395 | + (nullable NSString *)sendRequest:(XMRequestConfigBlock)configBlock
396 | onProgress:(nullable XMProgressBlock)progressBlock
397 | onSuccess:(nullable XMSuccessBlock)successBlock
398 | onFailure:(nullable XMFailureBlock)failureBlock
399 | onFinished:(nullable XMFinishedBlock)finishedBlock;
400 |
401 | + (nullable NSString *)sendBatchRequest:(XMBatchRequestConfigBlock)configBlock
402 | onSuccess:(nullable XMBCSuccessBlock)successBlock
403 | onFailure:(nullable XMBCFailureBlock)failureBlock
404 | onFinished:(nullable XMBCFinishedBlock)finishedBlock;
405 |
406 | + (nullable NSString *)sendChainRequest:(XMChainRequestConfigBlock)configBlock
407 | onSuccess:(nullable XMBCSuccessBlock)successBlock
408 | onFailure:(nullable XMBCFailureBlock)failureBlock
409 | onFinished:(nullable XMBCFinishedBlock)finishedBlock;
410 |
411 | #pragma mark -
412 |
413 | + (void)cancelRequest:(NSString *)identifier;
414 |
415 | + (void)cancelRequest:(NSString *)identifier
416 | onCancel:(nullable XMCancelBlock)cancelBlock;
417 |
418 | + (nullable id)getRequest:(NSString *)identifier;
419 |
420 | + (BOOL)isNetworkReachable;
421 |
422 | + (XMNetworkConnectionType)networkConnectionType;
423 |
424 | #pragma mark -
425 |
426 | + (void)addSSLPinningURL:(NSString *)url;
427 | + (void)addSSLPinningCert:(NSData *)cert;
428 | + (void)addTwowayAuthenticationPKCS12:(NSData *)p12 keyPassword:(NSString *)password;
429 |
430 | @end
431 |
432 | #pragma mark - XMConfig
433 |
434 | /**
435 | `XMConfig` is used to assign values for XMCenter's properties through invoking `-setupConfig:` method.
436 | */
437 | @interface XMConfig : NSObject
438 |
439 | ///-----------------------------------------------
440 | /// @name Properties to Assign Values for XMCenter
441 | ///-----------------------------------------------
442 |
443 | /**
444 | The general server address to assign for XMCenter.
445 | */
446 | @property (nonatomic, copy, nullable) NSString *generalServer;
447 |
448 | /**
449 | The general parameters to assign for XMCenter.
450 | */
451 | @property (nonatomic, strong, nullable) NSDictionary *generalParameters;
452 |
453 | /**
454 | The general headers to assign for XMCenter.
455 | */
456 | @property (nonatomic, strong, nullable) NSDictionary *generalHeaders;
457 |
458 | /**
459 | The general user info to assign for XMCenter.
460 | */
461 | @property (nonatomic, strong, nullable) NSDictionary *generalUserInfo;
462 |
463 | /**
464 | The dispatch callback queue to assign for XMCenter.
465 | */
466 | @property (nonatomic, strong, nullable) dispatch_queue_t callbackQueue;
467 |
468 | /**
469 | The global requests engine to assign for XMCenter.
470 | */
471 | @property (nonatomic, strong, nullable) XMEngine *engine;
472 |
473 | /**
474 | The console log BOOL value to assign for XMCenter.
475 | */
476 | @property (nonatomic, assign) BOOL consoleLog;
477 |
478 | @end
479 |
480 | NS_ASSUME_NONNULL_END
481 |
--------------------------------------------------------------------------------
/Carthage/Build/iOS/XMNetworking.framework/Headers/XMConst.h:
--------------------------------------------------------------------------------
1 | //
2 | // XMConst.h
3 | // XMNetworking
4 | //
5 | // Created by Zubin Kang on 12/12/2016.
6 | // Copyright © 2016 XMNetworking. All rights reserved.
7 | //
8 |
9 | #ifndef XMConst_h
10 | #define XMConst_h
11 |
12 | #define XM_SAFE_BLOCK(BlockName, ...) ({ !BlockName ? nil : BlockName(__VA_ARGS__); })
13 | #define XMLock() dispatch_semaphore_wait(self->_lock, DISPATCH_TIME_FOREVER)
14 | #define XMUnlock() dispatch_semaphore_signal(self->_lock)
15 |
16 | NS_ASSUME_NONNULL_BEGIN
17 |
18 | @class XMRequest, XMBatchRequest, XMChainRequest;
19 |
20 | /**
21 | Types enum for XMRequest.
22 | */
23 | typedef NS_ENUM(NSInteger, XMRequestType) {
24 | kXMRequestNormal = 0, //!< Normal HTTP request type, such as GET, POST, ...
25 | kXMRequestUpload = 1, //!< Upload request type
26 | kXMRequestDownload = 2, //!< Download request type
27 | };
28 |
29 | /**
30 | HTTP methods enum for XMRequest.
31 | */
32 | typedef NS_ENUM(NSInteger, XMHTTPMethodType) {
33 | kXMHTTPMethodGET = 0, //!< GET
34 | kXMHTTPMethodPOST = 1, //!< POST
35 | kXMHTTPMethodHEAD = 2, //!< HEAD
36 | kXMHTTPMethodDELETE = 3, //!< DELETE
37 | kXMHTTPMethodPUT = 4, //!< PUT
38 | kXMHTTPMethodPATCH = 5, //!< PATCH
39 | };
40 |
41 | /**
42 | Resquest parameter serialization type enum for XMRequest, see `AFURLRequestSerialization.h` for details.
43 | */
44 | typedef NS_ENUM(NSInteger, XMRequestSerializerType) {
45 | kXMRequestSerializerRAW = 0, //!< Encodes parameters to a query string and put it into HTTP body, setting the `Content-Type` of the encoded request to default value `application/x-www-form-urlencoded`.
46 | kXMRequestSerializerJSON = 1, //!< Encodes parameters as JSON using `NSJSONSerialization`, setting the `Content-Type` of the encoded request to `application/json`.
47 | kXMRequestSerializerPlist = 2, //!< Encodes parameters as Property List using `NSPropertyListSerialization`, setting the `Content-Type` of the encoded request to `application/x-plist`.
48 | };
49 |
50 | /**
51 | Response data serialization type enum for XMRequest, see `AFURLResponseSerialization.h` for details.
52 | */
53 | typedef NS_ENUM(NSInteger, XMResponseSerializerType) {
54 | kXMResponseSerializerRAW = 0, //!< Validates the response status code and content type, and returns the default response data.
55 | kXMResponseSerializerJSON = 1, //!< Validates and decodes JSON responses using `NSJSONSerialization`, and returns a NSDictionary/NSArray/... JSON object.
56 | kXMResponseSerializerPlist = 2, //!< Validates and decodes Property List responses using `NSPropertyListSerialization`, and returns a property list object.
57 | kXMResponseSerializerXML = 3, //!< Validates and decodes XML responses as an `NSXMLParser` objects.
58 | };
59 |
60 | /**
61 | Network connection type enum
62 | */
63 | typedef NS_ENUM(NSInteger, XMNetworkConnectionType) {
64 | kXMNetworkConnectionTypeUnknown = -1,
65 | kXMNetworkConnectionTypeNotReachable = 0,
66 | kXMNetworkConnectionTypeViaWWAN = 1,
67 | kXMNetworkConnectionTypeViaWiFi = 2,
68 | };
69 |
70 | ///------------------------------
71 | /// @name XMRequest Config Blocks
72 | ///------------------------------
73 |
74 | typedef void (^XMRequestConfigBlock)(XMRequest *request);
75 | typedef void (^XMBatchRequestConfigBlock)(XMBatchRequest *batchRequest);
76 | typedef void (^XMChainRequestConfigBlock)(XMChainRequest *chainRequest);
77 |
78 | ///--------------------------------
79 | /// @name XMRequest Callback Blocks
80 | ///--------------------------------
81 |
82 | typedef void (^XMProgressBlock)(NSProgress *progress);
83 | typedef void (^XMSuccessBlock)(id _Nullable responseObject);
84 | typedef void (^XMFailureBlock)(NSError * _Nullable error);
85 | typedef void (^XMFinishedBlock)(id _Nullable responseObject, NSError * _Nullable error);
86 | typedef void (^XMCancelBlock)(id _Nullable request); // The `request` might be a XMRequest/XMBatchRequest/XMChainRequest object.
87 |
88 | ///-------------------------------------------------
89 | /// @name Callback Blocks for Batch or Chain Request
90 | ///-------------------------------------------------
91 |
92 | typedef void (^XMBCSuccessBlock)(NSArray *responseObjects);
93 | typedef void (^XMBCFailureBlock)(NSArray *errors);
94 | typedef void (^XMBCFinishedBlock)(NSArray * _Nullable responseObjects, NSArray * _Nullable errors);
95 | typedef void (^XMBCNextBlock)(XMRequest *request, id _Nullable responseObject, BOOL *isSent);
96 |
97 | ///------------------------------
98 | /// @name XMCenter Process Blocks
99 | ///------------------------------
100 |
101 | /**
102 | The custom request pre-process block for all XMRequests invoked by XMCenter.
103 |
104 | @param request The current XMRequest object.
105 | */
106 | typedef void (^XMCenterRequestProcessBlock)(XMRequest *request);
107 |
108 | /**
109 | The custom response process block for all XMRequests invoked by XMCenter.
110 |
111 | @param request The current XMRequest object.
112 | @param responseObject The response data return from server.
113 | @param error The error that occurred while the response data don't conforms to your own business logic.
114 | */
115 | typedef id (^XMCenterResponseProcessBlock)(XMRequest *request, id _Nullable responseObject, NSError * _Nullable __autoreleasing *error);
116 |
117 | /**
118 | The custom error process block for all XMRequests invoked by XMCenter.
119 |
120 | @param request The current XMRequest object.
121 | @param error The error that occurred while the response data don't conforms to your own business logic.
122 | */
123 | typedef void (^XMCenterErrorProcessBlock)(XMRequest *request, NSError * _Nullable __autoreleasing *error);
124 |
125 | NS_ASSUME_NONNULL_END
126 |
127 | #endif /* XMConst_h */
128 |
--------------------------------------------------------------------------------
/Carthage/Build/iOS/XMNetworking.framework/Headers/XMEngine.h:
--------------------------------------------------------------------------------
1 | //
2 | // XMEngine.h
3 | // XMNetworking
4 | //
5 | // Created by Zubin Kang on 12/12/2016.
6 | // Copyright © 2016 XMNetworking. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @class XMRequest;
14 |
15 | /**
16 | The completion handler block for a network request.
17 |
18 | @param responseObject The response object return by the response serializer.
19 | @param error The error describing the network or parsing error that occurred.
20 | */
21 | typedef void (^XMCompletionHandler) (id _Nullable responseObject, NSError * _Nullable error);
22 |
23 | /**
24 | `XMEngine` is a global engine to lauch the all network requests, which package the API of `AFNetworking`.
25 | */
26 | @interface XMEngine : NSObject
27 |
28 | ///---------------------
29 | /// @name Initialization
30 | ///---------------------
31 |
32 | /**
33 | Creates and returns a new `XMEngine` object.
34 | */
35 | + (instancetype)engine;
36 |
37 | /**
38 | Returns the default shared `XMEngine` singleton object.
39 | */
40 | + (instancetype)sharedEngine;
41 |
42 | ///------------------------
43 | /// @name Request Operation
44 | ///------------------------
45 |
46 | /**
47 | Runs a real network reqeust with a `XMRequest` object and completion handler block.
48 |
49 | @param request The `XMRequest` object to be launched.
50 | @param completionHandler The completion handler block for network response callback.
51 | */
52 | - (void)sendRequest:(XMRequest *)request completionHandler:(nullable XMCompletionHandler)completionHandler;
53 |
54 | /**
55 | Method to cancel a runnig request by identifier
56 |
57 | @param identifier The unique identifier of a running request.
58 | @return return The canceled request object (if exist) matching to identifier.
59 | */
60 | - (nullable XMRequest *)cancelRequestByIdentifier:(NSString *)identifier;
61 |
62 | /**
63 | Method to get a runnig request object matching to identifier.
64 |
65 | @param identifier The unique identifier of a running request.
66 | @return return The runing requset object (if exist) matching to identifier.
67 | */
68 | - (nullable XMRequest *)getRequestByIdentifier:(NSString *)identifier;
69 |
70 | /**
71 | Method to set max concurrent operation count.
72 |
73 | @param count The max concurrent operation count.
74 | */
75 | - (void)setConcurrentOperationCount:(NSInteger)count;
76 |
77 | ///--------------------------
78 | /// @name Network Reachablity
79 | ///--------------------------
80 |
81 | /**
82 | Method to get the current network reachablity status, see `AFNetworkReachabilityManager.h` for details.
83 |
84 | @return Network reachablity status code
85 | */
86 | - (NSInteger)reachabilityStatus;
87 |
88 | ///----------------------------
89 | /// @name SSL Pinning for HTTPS
90 | ///----------------------------
91 |
92 | /**
93 | Add host url of a server whose trust should be evaluated against the pinned SSL certificates.
94 |
95 | @param url The host url of a server.
96 | */
97 | - (void)addSSLPinningURL:(NSString *)url;
98 |
99 | /**
100 | Add certificate used to evaluate server trust according to the SSL pinning URL.
101 |
102 | @param cert The local pinnned certificate data.
103 | */
104 | - (void)addSSLPinningCert:(NSData *)cert;
105 |
106 | ///---------------------------------------
107 | /// @name Two-way Authentication for HTTPS
108 | ///---------------------------------------
109 |
110 | /**
111 | Add client p12 certificate used for HTTPS Two-way Authentication.
112 |
113 | @param p12 The PKCS#12 certificate file data.
114 | @param password The special key password for PKCS#12 data.
115 | */
116 | - (void)addTwowayAuthenticationPKCS12:(NSData *)p12 keyPassword:(NSString *)password;
117 |
118 | @end
119 |
120 | NS_ASSUME_NONNULL_END
121 |
--------------------------------------------------------------------------------
/Carthage/Build/iOS/XMNetworking.framework/Headers/XMNetworking.h:
--------------------------------------------------------------------------------
1 | //
2 | // XMNetworking.h
3 | // XMNetworking
4 | //
5 | // Created by Zubin Kang on 16/12/2016.
6 | // Copyright © 2016 XMNetworking. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | //! Project version number for XMNetworking.
12 | FOUNDATION_EXPORT double XMNetworkingVersionNumber;
13 |
14 | //! Project version string for XMNetworking.
15 | FOUNDATION_EXPORT const unsigned char XMNetworkingVersionString[];
16 |
17 | // In this header, you should import all the public headers of your framework using statements like #import
18 |
19 | #import
20 | #import
21 | #import
22 | #import
23 |
--------------------------------------------------------------------------------
/Carthage/Build/iOS/XMNetworking.framework/Headers/XMRequest.h:
--------------------------------------------------------------------------------
1 | //
2 | // XMRequest.h
3 | // XMNetworking
4 | //
5 | // Created by Zubin Kang on 12/12/2016.
6 | // Copyright © 2016 XMNetworking. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "XMConst.h"
11 |
12 | NS_ASSUME_NONNULL_BEGIN
13 |
14 | @class XMUploadFormData;
15 |
16 | /**
17 | `XMRequest` is the base class for all network requests invoked by XMCenter.
18 | */
19 | @interface XMRequest : NSObject
20 |
21 | /**
22 | Creates and returns a new `XMRequest` object.
23 | */
24 | + (instancetype)request;
25 |
26 | /**
27 | The unique identifier for a XMRequest object, the value is assigned by XMCenter when the request is sent.
28 | */
29 | @property (nonatomic, copy, readonly) NSString *identifier;
30 |
31 | /**
32 | The server address for request, eg. "http://example.com/v1/", if `nil` (default) and the `useGeneralServer` property is `YES` (default), the `generalServer` of XMCenter is used.
33 | */
34 | @property (nonatomic, copy, nullable) NSString *server;
35 |
36 | /**
37 | The API interface path for request, eg. "foo/bar", `nil` by default.
38 | */
39 | @property (nonatomic, copy, nullable) NSString *api;
40 |
41 | /**
42 | The final URL of request, which is combined by `server` and `api` properties, eg. "http://example.com/v1/foo/bar", `nil` by default.
43 | NOTE: when you manually set the value for `url`, the `server` and `api` properties will be ignored.
44 | */
45 | @property (nonatomic, copy, nullable) NSString *url;
46 |
47 | /**
48 | The parameters for request, if `useGeneralParameters` property is `YES` (default), the `generalParameters` of XMCenter will be appended to the `parameters`.
49 | */
50 | @property (nonatomic, strong, nullable) NSDictionary *parameters;
51 |
52 | /**
53 | The HTTP headers for request, if `useGeneralHeaders` property is `YES` (default), the `generalHeaders` of XMCenter will be appended to the `headers`.
54 | */
55 | @property (nonatomic, strong, nullable) NSDictionary *headers;
56 |
57 | @property (nonatomic, assign) BOOL useGeneralServer; //!< Whether or not to use `generalServer` of XMCenter when request `server` is `nil`, `YES` by default.
58 | @property (nonatomic, assign) BOOL useGeneralHeaders; //!< Whether or not to append `generalHeaders` of XMCenter to request `headers`, `YES` by default.
59 | @property (nonatomic, assign) BOOL useGeneralParameters; //!< Whether or not to append `generalParameters` of XMCenter to request `parameters`, `YES` by default.
60 |
61 | /**
62 | Type for request: Normal, Upload or Download, `kXMRequestNormal` by default.
63 | */
64 | @property (nonatomic, assign) XMRequestType requestType;
65 |
66 | /**
67 | HTTP method for request, `kXMHTTPMethodPOST` by default, see `XMHTTPMethodType` enum for details.
68 | */
69 | @property (nonatomic, assign) XMHTTPMethodType httpMethod;
70 |
71 | /**
72 | Parameter serialization type for request, `kXMRequestSerializerRAW` by default, see `XMRequestSerializerType` enum for details.
73 | */
74 | @property (nonatomic, assign) XMRequestSerializerType requestSerializerType;
75 |
76 | /**
77 | Response data serialization type for request, `kXMResponseSerializerJSON` by default, see `XMResponseSerializerType` enum for details.
78 | */
79 | @property (nonatomic, assign) XMResponseSerializerType responseSerializerType;
80 |
81 | /**
82 | Timeout interval for request, `60` seconds by default.
83 | */
84 | @property (nonatomic, assign) NSTimeInterval timeoutInterval;
85 |
86 | /**
87 | The retry count for current request when error occurred, `0` by default.
88 | */
89 | @property (nonatomic, assign) NSUInteger retryCount;
90 |
91 | /**
92 | User info for current request, which could be used to distinguish requests with same context, if `nil` (default), the `generalUserInfo` of XMCenter is used.
93 | */
94 | @property (nonatomic, strong, nullable) NSDictionary *userInfo;
95 |
96 | /**
97 | Success block for request, called when current request completed successful, the block will execute in `callbackQueue` of XMCenter.
98 | */
99 | @property (nonatomic, copy, readonly, nullable) XMSuccessBlock successBlock;
100 |
101 | /**
102 | Failure block for request, called when error occurred, the block will execute in `callbackQueue` of XMCenter.
103 | */
104 | @property (nonatomic, copy, readonly, nullable) XMFailureBlock failureBlock;
105 |
106 | /**
107 | Finished block for request, called when current request is finished, the block will execute in `callbackQueue` of XMCenter.
108 | */
109 | @property (nonatomic, copy, readonly, nullable) XMFinishedBlock finishedBlock;
110 |
111 | /**
112 | Progress block for upload/download request, called when the upload/download progress is updated,
113 | NOTE: This block is called on the session queue, not the `callbackQueue` of XMCenter !!!
114 | */
115 | @property (nonatomic, copy, readonly, nullable) XMProgressBlock progressBlock;
116 |
117 | /**
118 | Nil out all callback blocks when a request is finished to break the potential retain cycle.
119 | */
120 | - (void)cleanCallbackBlocks;
121 |
122 | /**
123 | Upload files form data for upload request, `nil` by default, see `XMUploadFormData` class and `AFMultipartFormData` protocol for details.
124 | NOTE: This property is effective only when `requestType` is assigned to `kXMRequestUpload`.
125 | */
126 | @property (nonatomic, strong, nullable) NSMutableArray *uploadFormDatas;
127 |
128 | /**
129 | Local save path for downloaded file, `nil` by default.
130 | NOTE: This property is effective only when `requestType` is assigned to `kXMRequestDownload`.
131 | */
132 | @property (nonatomic, copy, nullable) NSString *downloadSavePath;
133 |
134 | ///----------------------------------------------------
135 | /// @name Quickly Methods For Add Upload File Form Data
136 | ///----------------------------------------------------
137 |
138 | - (void)addFormDataWithName:(NSString *)name fileData:(NSData *)fileData;
139 | - (void)addFormDataWithName:(NSString *)name fileName:(NSString *)fileName mimeType:(NSString *)mimeType fileData:(NSData *)fileData;
140 | - (void)addFormDataWithName:(NSString *)name fileURL:(NSURL *)fileURL;
141 | - (void)addFormDataWithName:(NSString *)name fileName:(NSString *)fileName mimeType:(NSString *)mimeType fileURL:(NSURL *)fileURL;
142 |
143 | @end
144 |
145 | #pragma mark - XMBatchRequest
146 |
147 | ///------------------------------------------------------
148 | /// @name XMBatchRequest Class for sending batch requests
149 | ///------------------------------------------------------
150 |
151 | @interface XMBatchRequest : NSObject
152 |
153 | @property (nonatomic, copy, readonly) NSString *identifier;
154 | @property (nonatomic, strong, readonly) NSMutableArray *requestArray;
155 | @property (nonatomic, strong, readonly) NSMutableArray *responseArray;
156 |
157 | - (BOOL)onFinishedOneRequest:(XMRequest *)request response:(nullable id)responseObject error:(nullable NSError *)error;
158 |
159 | @end
160 |
161 | #pragma mark - XMChainRequest
162 |
163 | ///------------------------------------------------------
164 | /// @name XMChainRequest Class for sending chain requests
165 | ///------------------------------------------------------
166 |
167 | @interface XMChainRequest : NSObject
168 |
169 | @property (nonatomic, copy, readonly) NSString *identifier;
170 | @property (nonatomic, strong, readonly) XMRequest *runningRequest;
171 |
172 | - (XMChainRequest *)onFirst:(XMRequestConfigBlock)firstBlock;
173 | - (XMChainRequest *)onNext:(XMBCNextBlock)nextBlock;
174 |
175 | - (BOOL)onFinishedOneRequest:(XMRequest *)request response:(nullable id)responseObject error:(nullable NSError *)error;
176 |
177 | @end
178 |
179 | #pragma mark - XMUploadFormData
180 |
181 | /**
182 | `XMUploadFormData` is the class for describing and carring the upload file data, see `AFMultipartFormData` protocol for details.
183 | */
184 | @interface XMUploadFormData : NSObject
185 |
186 | /**
187 | The name to be associated with the specified data. This property must not be `nil`.
188 | */
189 | @property (nonatomic, copy) NSString *name;
190 |
191 | /**
192 | The file name to be used in the `Content-Disposition` header. This property is not recommended be `nil`.
193 | */
194 | @property (nonatomic, copy, nullable) NSString *fileName;
195 |
196 | /**
197 | The declared MIME type of the file data. This property is not recommended be `nil`.
198 | */
199 | @property (nonatomic, copy, nullable) NSString *mimeType;
200 |
201 | /**
202 | The data to be encoded and appended to the form data, and it is prior than `fileURL`.
203 | */
204 | @property (nonatomic, strong, nullable) NSData *fileData;
205 |
206 | /**
207 | The URL corresponding to the file whose content will be appended to the form, BUT, when the `fileData` is assigned,the `fileURL` will be ignored.
208 | */
209 | @property (nonatomic, strong, nullable) NSURL *fileURL;
210 |
211 | // NOTE: Either of the `fileData` and `fileURL` should not be `nil`, and the `fileName` and `mimeType` must both be `nil` or assigned at the same time,
212 |
213 | ///-----------------------------------------------------
214 | /// @name Quickly Class Methods For Creates A New Object
215 | ///-----------------------------------------------------
216 |
217 | + (instancetype)formDataWithName:(NSString *)name fileData:(NSData *)fileData;
218 | + (instancetype)formDataWithName:(NSString *)name fileName:(NSString *)fileName mimeType:(NSString *)mimeType fileData:(NSData *)fileData;
219 | + (instancetype)formDataWithName:(NSString *)name fileURL:(NSURL *)fileURL;
220 | + (instancetype)formDataWithName:(NSString *)name fileName:(NSString *)fileName mimeType:(NSString *)mimeType fileURL:(NSURL *)fileURL;
221 |
222 | @end
223 |
224 | NS_ASSUME_NONNULL_END
225 |
--------------------------------------------------------------------------------
/Carthage/Build/iOS/XMNetworking.framework/Info.plist:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awesome-tips/awesome-tips-ios-app/78eec7c0cb5b2c561f95b0016eb832e22f22b2ff/Carthage/Build/iOS/XMNetworking.framework/Info.plist
--------------------------------------------------------------------------------
/Carthage/Build/iOS/XMNetworking.framework/Modules/module.modulemap:
--------------------------------------------------------------------------------
1 | framework module XMNetworking {
2 | umbrella header "XMNetworking.h"
3 |
4 | export *
5 | module * { export * }
6 | }
7 |
--------------------------------------------------------------------------------
/Carthage/Build/iOS/XMNetworking.framework/XMNetworking:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awesome-tips/awesome-tips-ios-app/78eec7c0cb5b2c561f95b0016eb832e22f22b2ff/Carthage/Build/iOS/XMNetworking.framework/XMNetworking
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Awesome Tips
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # awesome-tips-ios-app
2 | 知识小集 iOS 客户端
3 |
--------------------------------------------------------------------------------