Skip to content

Commit 120466d

Browse files
author
zhutaofeng
committed
添加使用方法截图
1 parent 326ee54 commit 120466d

13 files changed

+271
-36
lines changed

README.md

+17-1
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,28 @@
1414

1515

1616
## 使用
17-
详情请参照demo
1817

18+
### 普通请求
19+
<div>
20+
<img src="https://github.com/shmxybfq/TFRequest/blob/master/normal_request.png" width="100%" height="100%">
21+
</div>
22+
23+
### 上传
24+
25+
<div>
26+
<img src="https://github.com/shmxybfq/TFRequest/blob/master/upload_request.png" width="100%" height="100%">
27+
</div>
28+
29+
### 下载
30+
31+
<div>
32+
<img src="https://github.com/shmxybfq/TFRequest/blob/master/download_request.png" width="100%" height="100%">
33+
</div>
1934

2035
## 安装
2136
```
2237
pod 'TFRequest'
38+
2339
```
2440

2541
## 如果

TFRequestDemo/TFRequestDemo.xcodeproj/project.pbxproj

+12
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
2081C8A2221BE8C5009EE2CE /* TFBaseRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 2081C8A1221BE8C5009EE2CE /* TFBaseRequest.m */; };
2121
209D08A922200009007570EB /* BaseRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 209D08A822200009007570EB /* BaseRequest.m */; };
2222
209D08AC222000A9007570EB /* TestRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 209D08AB222000A9007570EB /* TestRequest.m */; };
23+
90983E2E23862F42007B635E /* UploadRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 90983E2D23862F42007B635E /* UploadRequest.m */; };
24+
90983E3123862F53007B635E /* DownloadRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 90983E3023862F53007B635E /* DownloadRequest.m */; };
2325
/* End PBXBuildFile section */
2426

2527
/* Begin PBXFileReference section */
@@ -47,6 +49,10 @@
4749
209D08AB222000A9007570EB /* TestRequest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TestRequest.m; sourceTree = "<group>"; };
4850
236549FF0B54658154E92994 /* Pods-TFRequestDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TFRequestDemo.release.xcconfig"; path = "Pods/Target Support Files/Pods-TFRequestDemo/Pods-TFRequestDemo.release.xcconfig"; sourceTree = "<group>"; };
4951
45C92653A6D7B166F9368774 /* libPods-TFRequestDemo.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-TFRequestDemo.a"; sourceTree = BUILT_PRODUCTS_DIR; };
52+
90983E2C23862F42007B635E /* UploadRequest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UploadRequest.h; sourceTree = "<group>"; };
53+
90983E2D23862F42007B635E /* UploadRequest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = UploadRequest.m; sourceTree = "<group>"; };
54+
90983E2F23862F53007B635E /* DownloadRequest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DownloadRequest.h; sourceTree = "<group>"; };
55+
90983E3023862F53007B635E /* DownloadRequest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DownloadRequest.m; sourceTree = "<group>"; };
5056
BC8D317BFFD6FB21F9FB9085 /* Pods-TFRequestDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TFRequestDemo.debug.xcconfig"; path = "Pods/Target Support Files/Pods-TFRequestDemo/Pods-TFRequestDemo.debug.xcconfig"; sourceTree = "<group>"; };
5157
/* End PBXFileReference section */
5258

@@ -89,6 +95,10 @@
8995
2081C884221BE724009EE2CE /* ViewController.m */,
9096
209D08AA222000A9007570EB /* TestRequest.h */,
9197
209D08AB222000A9007570EB /* TestRequest.m */,
98+
90983E2C23862F42007B635E /* UploadRequest.h */,
99+
90983E2D23862F42007B635E /* UploadRequest.m */,
100+
90983E2F23862F53007B635E /* DownloadRequest.h */,
101+
90983E3023862F53007B635E /* DownloadRequest.m */,
92102
209D08A722200009007570EB /* BaseRequest.h */,
93103
209D08A822200009007570EB /* BaseRequest.m */,
94104
2081C896221BE743009EE2CE /* TFRequest */,
@@ -228,12 +238,14 @@
228238
files = (
229239
2081C885221BE724009EE2CE /* ViewController.m in Sources */,
230240
2081C89F221BE8A3009EE2CE /* TFRequestParam.m in Sources */,
241+
90983E3123862F53007B635E /* DownloadRequest.m in Sources */,
231242
2081C899221BE7FF009EE2CE /* TFRequest.m in Sources */,
232243
2081C89C221BE88F009EE2CE /* TFRequestManager.m in Sources */,
233244
209D08AC222000A9007570EB /* TestRequest.m in Sources */,
234245
209D08A922200009007570EB /* BaseRequest.m in Sources */,
235246
2081C8A2221BE8C5009EE2CE /* TFBaseRequest.m in Sources */,
236247
2081C890221BE726009EE2CE /* main.m in Sources */,
248+
90983E2E23862F42007B635E /* UploadRequest.m in Sources */,
237249
2081C882221BE724009EE2CE /* AppDelegate.m in Sources */,
238250
);
239251
runOnlyForDeploymentPostprocessing = 0;

TFRequestDemo/TFRequestDemo/Base.lproj/Main.storyboard

+27-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
3-
<device id="retina4_7" orientation="portrait">
4-
<adaptation id="fullscreen"/>
5-
</device>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
3+
<device id="retina4_7" orientation="portrait" appearance="light"/>
64
<dependencies>
75
<deployment identifier="iOS"/>
8-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15510"/>
97
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
108
</dependencies>
119
<scenes>
@@ -22,38 +20,59 @@
2220
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
2321
<subviews>
2422
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="zOB-X4-dI7">
25-
<rect key="frame" x="30" y="80" width="315" height="50"/>
23+
<rect key="frame" x="30" y="60" width="70" height="50"/>
2624
<color key="backgroundColor" red="0.86666666670000003" green="0.86666666670000003" blue="0.86666666670000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
2725
<constraints>
26+
<constraint firstAttribute="width" constant="70" id="Ij4-OH-wQg"/>
2827
<constraint firstAttribute="height" constant="50" id="TEY-nz-NMO"/>
2928
</constraints>
3029
<state key="normal" title="发送请求"/>
3130
</button>
3231
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" text="日志显示区域" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="S7j-ev-Olh">
33-
<rect key="frame" x="20" y="150" width="335" height="497"/>
32+
<rect key="frame" x="20" y="130" width="335" height="517"/>
3433
<color key="backgroundColor" red="0.94509803920000002" green="0.95294117649999999" blue="0.97254901959999995" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
3534
<fontDescription key="fontDescription" type="system" pointSize="14"/>
3635
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
3736
</textView>
37+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="N2r-Uc-mBV">
38+
<rect key="frame" x="110" y="60" width="70" height="50"/>
39+
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
40+
<state key="normal" title="上传"/>
41+
</button>
42+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="EE7-Yb-zRz">
43+
<rect key="frame" x="190" y="60" width="70" height="50"/>
44+
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
45+
<state key="normal" title="下载"/>
46+
</button>
3847
</subviews>
3948
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
4049
<constraints>
50+
<constraint firstItem="N2r-Uc-mBV" firstAttribute="leading" secondItem="zOB-X4-dI7" secondAttribute="trailing" constant="10" id="04q-9d-s23"/>
4151
<constraint firstAttribute="trailing" secondItem="S7j-ev-Olh" secondAttribute="trailing" constant="20" id="3r0-PD-fIj"/>
4252
<constraint firstItem="S7j-ev-Olh" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" constant="20" id="Egk-AD-atG"/>
4353
<constraint firstItem="zOB-X4-dI7" firstAttribute="top" secondItem="Xy4-Cp-P6W" secondAttribute="bottom" constant="60" id="OBR-fG-EPx"/>
54+
<constraint firstItem="EE7-Yb-zRz" firstAttribute="width" secondItem="zOB-X4-dI7" secondAttribute="width" id="Ogk-ew-nAA"/>
4455
<constraint firstItem="OOT-nv-YIw" firstAttribute="top" secondItem="S7j-ev-Olh" secondAttribute="bottom" constant="20" id="Tep-UD-Wg9"/>
56+
<constraint firstItem="N2r-Uc-mBV" firstAttribute="width" secondItem="zOB-X4-dI7" secondAttribute="width" id="U0J-KU-eHY"/>
57+
<constraint firstItem="N2r-Uc-mBV" firstAttribute="height" secondItem="zOB-X4-dI7" secondAttribute="height" id="Vgt-O1-pBN"/>
4558
<constraint firstItem="S7j-ev-Olh" firstAttribute="top" secondItem="zOB-X4-dI7" secondAttribute="bottom" constant="20" id="fTo-8L-Ilj"/>
46-
<constraint firstAttribute="trailing" secondItem="zOB-X4-dI7" secondAttribute="trailing" constant="30" id="jWn-r0-F1G"/>
59+
<constraint firstItem="EE7-Yb-zRz" firstAttribute="top" secondItem="zOB-X4-dI7" secondAttribute="top" id="kxX-kl-d2J"/>
4760
<constraint firstItem="zOB-X4-dI7" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" constant="30" id="pBk-22-RNv"/>
61+
<constraint firstItem="N2r-Uc-mBV" firstAttribute="top" secondItem="zOB-X4-dI7" secondAttribute="top" id="rrs-bu-MTE"/>
62+
<constraint firstItem="EE7-Yb-zRz" firstAttribute="leading" secondItem="N2r-Uc-mBV" secondAttribute="trailing" constant="10" id="w3n-PH-Dwd"/>
63+
<constraint firstItem="EE7-Yb-zRz" firstAttribute="height" secondItem="zOB-X4-dI7" secondAttribute="height" id="x3j-IF-tSw"/>
4864
</constraints>
4965
</view>
5066
<connections>
67+
<outlet property="downloadButton" destination="EE7-Yb-zRz" id="vWj-1V-sTy"/>
5168
<outlet property="postButton" destination="zOB-X4-dI7" id="PcI-sY-FXq"/>
5269
<outlet property="textView" destination="S7j-ev-Olh" id="Kzv-ef-3QY"/>
70+
<outlet property="uploadButton" destination="N2r-Uc-mBV" id="Ilo-Xl-D90"/>
5371
</connections>
5472
</viewController>
5573
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
5674
</objects>
75+
<point key="canvasLocation" x="140" y="134"/>
5776
</scene>
5877
</scenes>
5978
</document>

TFRequestDemo/TFRequestDemo/BaseRequest.m

+8-8
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,20 @@ -(void)dealloc{
1515
}
1616

1717
#pragma mark ---------------------- 配置请求参数 ----------------------
18-
1918
-(NSString *)configureBaseUrl{
2019
return @"http://180.76.121.105:8296";
2120
}
2221

2322

2423
-(NSDictionary *)configureHeader{
2524
NSMutableDictionary *header = [NSMutableDictionary dictionary];
26-
[header setObject:@"1" forKey:@"appBundleVersion"];
27-
[header setObject:@"1.0" forKey:@"appVersion"];
28-
[header setObject:@"US" forKey:@"countryCode"];
29-
[header setObject:@"en" forKey:@"lang"];
3025
[header setObject:@"375x812" forKey:@"screenSize"];
3126
[header setObject:@"ios" forKey:@"source"];
32-
[header setObject:@"12.1" forKey:@"systemVersion"];
27+
//版本
28+
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
29+
[header setObject:version forKey:@"version"];
30+
//设备系统版本号
31+
[header setObject:[UIDevice currentDevice].systemVersion forKey:@"systemVersion"];
3332
return header;
3433
}
3534

@@ -74,8 +73,9 @@ -(RequestMethod)configureRequestMethod{
7473
//}
7574

7675

77-
#pragma mark ---------------------- 监听(阻断)请求过程 ----------------------
78-
76+
#pragma mark
77+
//---------------------- 监听(阻断)请求过程 ----------------------
78+
//---------------------- 也可以监听(阻断)其他请求过程 ----------------------
7979
- (BOOL)requestProgressDidGetParams:(TFBaseRequest *)request{
8080

8181
return YES;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// DownloadRequest.h
3+
// TFRequestDemo
4+
//
5+
// Created by zhutaofeng on 2019/11/21.
6+
// Copyright © 2019 ztf. All rights reserved.
7+
//
8+
9+
#import "BaseRequest.h"
10+
11+
NS_ASSUME_NONNULL_BEGIN
12+
13+
@interface DownloadRequest : BaseRequest
14+
15+
@end
16+
17+
NS_ASSUME_NONNULL_END
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//
2+
// DownloadRequest.m
3+
// TFRequestDemo
4+
//
5+
// Created by zhutaofeng on 2019/11/21.
6+
// Copyright © 2019 ztf. All rights reserved.
7+
//
8+
9+
#import "DownloadRequest.h"
10+
11+
@implementation DownloadRequest
12+
13+
-(RequestMethod)configureRequestMethod {
14+
return RequestMethodDownload;
15+
}
16+
17+
-(NSURL *)configureDownloadDestinationPath:(NSURL *)targetPath response:(NSURLResponse *)response{
18+
NSAssert(NO, @"");
19+
return nil;
20+
21+
NSString *string = self.downLoadRequest.URL.absoluteString;
22+
NSString *filePath = [NSString stringWithFormat:@"%@%@",@"/Users/xxx/Desktop/trueResult/xxx.jpg",string];
23+
return [NSURL fileURLWithPath:filePath];
24+
}
25+
26+
27+
28+
@end

TFRequestDemo/TFRequestDemo/Info.plist

+5
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,10 @@
4141
<string>UIInterfaceOrientationLandscapeLeft</string>
4242
<string>UIInterfaceOrientationLandscapeRight</string>
4343
</array>
44+
<key>NSAppTransportSecurity</key>
45+
<dict>
46+
<key>NSAllowsArbitraryLoads</key>
47+
<true/>
48+
</dict>
4449
</dict>
4550
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// UploadRequest.h
3+
// TFRequestDemo
4+
//
5+
// Created by zhutaofeng on 2019/11/21.
6+
// Copyright © 2019 ztf. All rights reserved.
7+
//
8+
9+
#import "BaseRequest.h"
10+
11+
NS_ASSUME_NONNULL_BEGIN
12+
13+
@interface UploadRequest : BaseRequest
14+
15+
@end
16+
17+
NS_ASSUME_NONNULL_END
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//
2+
// UploadRequest.m
3+
// TFRequestDemo
4+
//
5+
// Created by zhutaofeng on 2019/11/21.
6+
// Copyright © 2019 ztf. All rights reserved.
7+
//
8+
9+
#import "UploadRequest.h"
10+
11+
@implementation UploadRequest
12+
13+
//-(NSString *)configureBaseUrl{
14+
// return @"http://180.76.121.105:8296";
15+
//}
16+
17+
-(NSString *)configureUrl{
18+
return @"app/img/upload";
19+
}
20+
21+
- (RequestMethod)configureRequestMethod {
22+
return RequestMethodUploadPost;
23+
}
24+
25+
@end

0 commit comments

Comments
 (0)