Swift Package Index


A network request tool based on URLSession


  • The latest stable release is 0.6.5. Released 2 years ago.
  • The last commit to master was about 1 year ago.

Swift Version Compatibility

  • 0.6.5
    5.3
    5.2
    5.1
    5.0
    4.2
  • master
    5.3
    5.2
    5.1
    5.0
    4.2
Full build results

Platform Compatibility

  • 0.6.5
    iOS
    macOS(Intel)
    macOS(ARM)
    Linux
    tvOS
    watchOS
  • master
    iOS
    macOS(Intel)
    macOS(ARM)
    Linux
    tvOS
    watchOS
Full build results

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];