https://github.com/song-react/network
A network request tool based on URLSession
https://github.com/song-react/network
carthage ios macos network network-reachability nsurlsession swift tvos watchos
Last synced: about 1 month ago
JSON representation
A network request tool based on URLSession
- Host: GitHub
- URL: https://github.com/song-react/network
- Owner: song-react
- License: mit
- Created: 2016-03-02T10:22:10.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2020-01-20T06:38:15.000Z (over 6 years ago)
- Last Synced: 2026-04-19T20:38:57.695Z (about 2 months ago)
- Topics: carthage, ios, macos, network, network-reachability, nsurlsession, swift, tvos, watchos
- Language: Swift
- Homepage:
- Size: 401 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
- License: LICENSE
Awesome Lists containing this project
README




[](https://paypal.me/DingSongwen)
# Introduction
Networks is a lightweight network request tool based on NSURLSession
Supported functions:
- GET
- POST
- Download
- SSL Pinning
- Network Reachability, Status and Type
# Install
Swift Package Manager
```swift
"https://github.com/DingSoung/Network" "master"
```
# Usage
Execute the request
```objc
NSString *url = @"https://dingsoung.tk:520/";
NSURLRequest *getRequest = [NSURLRequest requestWithMethod: HTTPMethodGet url:url parameters:nil];
// manually
NSURLSessionDataTask *manuallyTask = [request dataTaskWithSession:nil completion:^(id _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
NSLog(@"%@, %@, %@", data, response, error);
}];
[manuallyTask resume];
// via manager
NSURLSessionDataTask *managerTask = [Network jsonWithRequest:request trasnform:^id _Nullable(NSDictionary * _Nonnull json) {
return json;
} completion:^(id _Nullable obj, NSError * _Nullable error) {
NSLog(@"%@, %@", obj, error);
}];
[managerTask resume];
```