Skip to content

song-react/Network

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

104 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Release Status

SwiftPackage

Language

Donate

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

"https://github.com/DingSoung/Network" "master"

Usage

Execute the request

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<NSString *,id> * _Nonnull json) {
     return json;
} completion:^(id _Nullable obj, NSError * _Nullable error) {
     NSLog(@"%@, %@", obj, error);
}];
[managerTask resume];

About

A network request tool based on URLSession

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages