Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
coderZsq committed Nov 22, 2020
1 parent 556cedb commit 0a87763
Show file tree
Hide file tree
Showing 703 changed files with 76,214 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,24 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17125"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="" sceneMemberID="viewController">
<viewController id="BYZ-38-t0r" customClass="ViewController" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<subviews>
<progressView opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="5PR-hN-f9a">
<rect key="frame" x="8" y="44" width="398" height="4"/>
</progressView>
</subviews>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="5PR-hN-f9a" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" constant="8" id="DeK-Ff-313"/>
<constraint firstItem="6Tk-OE-BBY" firstAttribute="trailing" secondItem="5PR-hN-f9a" secondAttribute="trailing" constant="8" id="UcW-df-E5j"/>
<constraint firstItem="5PR-hN-f9a" firstAttribute="top" secondItem="6Tk-OE-BBY" secondAttribute="top" id="u74-B2-prN"/>
</constraints>
</view>
<connections>
<outlet property="progressView" destination="5PR-hN-f9a" id="Ejv-j2-VEX"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="107" y="93"/>
</scene>
</scenes>
<resources>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
#import <AFNetworking.h>

@interface ViewController ()

@property (nonatomic, weak) IBOutlet UIProgressView *progressView;
@end

@implementation ViewController

- (void)viewDidLoad {
[super viewDidLoad];
[self create_an_uploadTask];
[self sharedNetworkReachability];
}

- (void)create_a_downloadTask {
Expand Down Expand Up @@ -105,12 +105,66 @@ - (void)create_an_uploadTask {
manager.responseSerializer = [AFJSONResponseSerializer serializer];
[manager POST:@"http://localhost:8080/afn/uploadTask/upload" parameters:nil headers:nil constructingBodyWithBlock:^(id<AFMultipartFormData> _Nonnull formData) {
NSURL *filePath = [NSURL fileURLWithPath:@"/Users/zhushuangquan/Desktop/AFN.png"];
[formData appendPartWithFileURL:filePath name:@"afn" error:nil];
[formData appendPartWithFileURL:filePath name:@"file" error:nil];
} progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
NSLog(@"Success: %@", responseObject);
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
NSLog(@"Error: %@", error);
}];
}

- (void)create_an_uploadTaskFor_a_MultiPartRequestWithProgress {
NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:@"http://localhost:8080/afn/uploadTask/upload" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
[formData appendPartWithFileURL:[NSURL fileURLWithPath:@"/Users/zhushuangquan/Desktop/AFN.png"] name:@"file" fileName:@"filename.jpg" mimeType:@"image/jpeg" error:nil];
} error:nil];

AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];

NSURLSessionUploadTask *uploadTask;
uploadTask = [manager
uploadTaskWithStreamedRequest:request
progress:^(NSProgress * _Nonnull uploadProgress) {
// This is not called back on the main queue.
// You are responsible for dispatching to the main queue for UI updates
dispatch_async(dispatch_get_main_queue(), ^{
//Update the progress view
[self.progressView setProgress:uploadProgress.fractionCompleted];
});
}
completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) {
if (error) {
NSLog(@"Error: %@", error);
} else {
NSLog(@"%@ %@", response, responseObject);
}
}];

[uploadTask resume];
}

- (void)create_a_dataTask {
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];
manager.responseSerializer = [AFJSONResponseSerializer serializer];

NSURL *URL = [NSURL URLWithString:@"http://localhost:8080/afn/dataTask/get"];
NSURLRequest *request = [NSURLRequest requestWithURL:URL];
NSURLSessionDataTask *dataTask = [manager dataTaskWithRequest:request uploadProgress:nil downloadProgress:nil completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) {
if (error) {
NSLog(@"Error: %@", error);
} else {
NSLog(@"%@ %@", response, responseObject);
}
}];
[dataTask resume];
}

- (void)sharedNetworkReachability {
[[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
NSLog(@"Reachability: %@", AFStringFromNetworkReachabilityStatus(status));
}];

[[AFNetworkReachabilityManager sharedManager] startMonitoring];
}

@end
183 changes: 177 additions & 6 deletions SQDebug/AFNetworking/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ router.post('/uploadTask/upload', upload.single('afn'), (ctx, next) => {
manager.responseSerializer = [AFJSONResponseSerializer serializer];
[manager POST:@"http://localhost:8080/afn/uploadTask/upload" parameters:nil headers:nil constructingBodyWithBlock:^(id<AFMultipartFormData> _Nonnull formData) {
NSURL *filePath = [NSURL fileURLWithPath:@"/Users/zhushuangquan/Desktop/AFN.png"];
[formData appendPartWithFileURL:filePath name:@"afn" error:nil];
[formData appendPartWithFileURL:filePath name:@"file" error:nil];
} progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
NSLog(@"Success: %@", responseObject);
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
Expand All @@ -156,13 +156,13 @@ router.post('/uploadTask/upload', upload.single('afn'), (ctx, next) => {

```js
{
fieldname: 'afn',
originalname: 'AFN.png',
fieldname: 'file',
originalname: 'AFN.jpg',
encoding: '7bit',
mimetype: 'image/png',
mimetype: 'image/jpeg',
destination: 'uploads/',
filename: '1605983019624.png',
path: 'uploads/1605983019624.png',
filename: '1606012485650.jpg',
path: 'uploads/1606012485650.jpg',
size: 88871
}
```
Expand All @@ -171,6 +171,177 @@ router.post('/uploadTask/upload', upload.single('afn'), (ctx, next) => {
Success: { msg = 'upload success!' }
```

```objc
- (void)create_an_uploadTaskFor_a_MultiPartRequestWithProgress {
NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:@"http://localhost:8080/afn/uploadTask/upload" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
[formData appendPartWithFileURL:[NSURL fileURLWithPath:@"/Users/zhushuangquan/Desktop/AFN.png"] name:@"file" fileName:@"filename.jpg" mimeType:@"image/jpeg" error:nil];
} error:nil];

AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];

NSURLSessionUploadTask *uploadTask;
uploadTask = [manager
uploadTaskWithStreamedRequest:request
progress:^(NSProgress * _Nonnull uploadProgress) {
// This is not called back on the main queue.
// You are responsible for dispatching to the main queue for UI updates
dispatch_async(dispatch_get_main_queue(), ^{
//Update the progress view
[self.progressView setProgress:uploadProgress.fractionCompleted];
});
}
completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) {
if (error) {
NSLog(@"Error: %@", error);
} else {
NSLog(@"%@ %@", response, responseObject);
}
}];

[uploadTask resume];
}
```

```objc
<NSHTTPURLResponse: 0x600000f74ee0> { URL: http://localhost:8080/afn/uploadTask/upload } { Status Code: 200, Headers {
Connection = (
"keep-alive"
);
"Content-Length" = (
25
);
"Content-Type" = (
"application/json; charset=utf-8"
);
Date = (
"Sun, 22 Nov 2020 02:47:06 GMT"
);
"Keep-Alive" = (
"timeout=5"
);
} } {
msg = "upload success!";
}
```

```objc
- (void)create_a_dataTask {
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];
manager.responseSerializer = [AFJSONResponseSerializer serializer];

NSURL *URL = [NSURL URLWithString:@"http://localhost:8080/afn/dataTask/get"];
NSURLRequest *request = [NSURLRequest requestWithURL:URL];
NSURLSessionDataTask *dataTask = [manager dataTaskWithRequest:request uploadProgress:nil downloadProgress:nil completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) {
if (error) {
NSLog(@"Error: %@", error);
} else {
NSLog(@"%@ %@", response, responseObject);
}
}];
[dataTask resume];
}
```

```js
router.get('/dataTask/get', (ctx, next) => {
ctx.status = 200;
ctx.body = {
msg: 'get success!'
}
});
```

```objc
<NSHTTPURLResponse: 0x600002b5c960> { URL: http://localhost:8080/afn/dataTask/get } { Status Code: 200, Headers {
Connection = (
"keep-alive"
);
"Content-Length" = (
22
);
"Content-Type" = (
"application/json; charset=utf-8"
);
Date = (
"Sun, 22 Nov 2020 02:55:30 GMT"
);
"Keep-Alive" = (
"timeout=5"
);
} } {
msg = "get success!";
}
```

```objc
/*
* Configuration options for an NSURLSession. When a session is
* created, a copy of the configuration object is made - you cannot
* modify the configuration of a session after it has been created.
*
* The shared session uses the global singleton credential, cache
* and cookie storage objects.
*
* An ephemeral session has no persistent disk storage for cookies,
* cache or credentials.
*
* A background session can be used to perform networking operations
* on behalf of a suspended application, within certain constraints.
*/
API_AVAILABLE(macos(10.9), ios(7.0), watchos(2.0), tvos(9.0))
@interface NSURLSessionConfiguration : NSObject <NSCopying>
```
```objc
@interface NSURL: NSObject <NSSecureCoding, NSCopying>
{
NSString *_urlString;
NSURL *_baseURL;
void *_clients;
void *_reserved;
}
```

```objc
@interface NSURLRequest : NSObject <NSSecureCoding, NSCopying, NSMutableCopying>
{
@private
NSURLRequestInternal *_internal;
}
```
```objc
@interface NSMutableURLRequest : NSURLRequest
```

```objc
@interface NSURLSessionDownloadTask : NSURLSessionTask
```
```objc
@interface NSURLSessionUploadTask : NSURLSessionDataTask
```

```objc
@interface NSURLSessionDataTask : NSURLSessionTask
```
```objc
- (void)sharedNetworkReachability {
[[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
NSLog(@"Reachability: %@", AFStringFromNetworkReachabilityStatus(status));
}];
[[AFNetworkReachabilityManager sharedManager] startMonitoring];
}
```

```
Reachability: Reachable via WiFi
Reachability: Not Reachable
```

```shell
$ cd AFNetworking-4.0.1
$ tree
Expand Down
1 change: 1 addition & 0 deletions SQDebug/debug/node_modules/.bin/mkdirp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0a87763

Please sign in to comment.