Swift Net is a URLSession for making URL Request for iOS and macOS platforms.
- iOS 8.0+
- macOS 10.9+
- Xcode 10.1+
pod 'SNet', '~> 1.0' #Swift 4.2.1
- Download and drop Source folder in your project.
- Congratulations!
import SNet
let urlString = "https://rajamohan-s.github.io/test/web.json"
var headers:[String:String]?
let method = HTTPMethod.GET
var data:[String:String]?
var data:Data?
SNet.request(urlString, data: data, headers: headers, method:method) { (result) in
if let error = result as? String{
print("Error:",error)
return
}
if let array = result as? [String]{
print("Object:",array)
}
}
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
SNet.mode = .release
I would love you for the contribution to SNet, check the LICENSE file for more info.
Rajamohan S – (https://rajamohan-s.github.io/)
Distributed under the MIT license. See LICENSE for more information.