SNet 1.0

SNet 1.0

Maintained by RAJAMOHAN SADHU SUNDAR SINGH.




SNet 1.0

Swift Net is a URLSession for making URL Request for iOS and macOS platforms.

Requirements

  • iOS 8.0+
  • macOS 10.9+
  • Xcode 10.1+

Installation

Using Cocoapods

pod 'SNet', '~> 1.0' #Swift 4.2.1

Manually

  1. Download and drop Source folder in your project.
  2. Congratulations!

Usage

Import SNet

import SNet

Variables

let urlString = "https://rajamohan-s.github.io/test/web.json"
var headers:[String:String]?
let method = HTTPMethod.GET

Use dictionary type

var data:[String:String]?

Use Data type

var data:Data?

Make request

SNet.request(urlString, data: data, headers: headers, method:method) { (result) in

    if let error = result as? String{
        print("Error:",error)
    }

    if let array = result as? [String]{
        print("Object:",array)
    }

}

Debugging

To use mode then use SNet.mode under didFinishLaunchingWithOptions under AppDelegate class to print all reaquest informations in console. Default mode is debug.

SNet.mode = .debug

Release

SNet.mode = .release

Contribute

I would love you for the contribution to SNet, check the LICENSE file for more info.

Meta

Rajamohan S – (https://rajamohan-s.github.io/)

Distributed under the MIT license. See LICENSE for more information.