Skip to content

ILYA2606/Requester

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CocoaPods SPM

Requester

Lightweight HTTP Networking in Swift

Requirements:

  • CocoaPods or SPM
  • iOS 9+

Features:

  • Lightweight wrapper for URLSession
  • Task management
  • Decodable support
  • JSON parsing
  • Image decoding
  • Authentication with URLCredential
  • Detail progress information
  • iOS 9+ Support

Installation

  • Add Requester in your iOS Project with CocoaPods:
pod 'Requester'

How to use:

Image downloading:

let requester = Requester.shared
requester.sendDataRequest(
    url: url,
    completion: { (image: UIImage) in
        // Image downloaded
},
    failure: { error in
        // Image not loaded with error
},
    progressHandler: { progress in
        // Image downloading with progress
)}

Custom file downloading:

let requester = Requester.shared
requester.sendDataRequest(
    url: url,
    completion: { (data: Data) in
        // Data downloaded
},
    failure: { error in
        // Data not loaded with error
},
    progressHandler: { progress in
        // Data downloading with progress
)}

String downloading:

let requester = Requester.shared
requester.sendDataRequest(
    url: url,
    completion: { (string: String) in
        // String downloaded
},
    failure: { error in
        // String not loaded with error
},
    progressHandler: { progress in
        // String downloading with progress
)}

JSON API:

struct SomeResponseDTO: Decodable {
    let parameter1: String
    let parameter2: Double
}

let requester = Requester.shared
requester.sendJSONRequest(
    url: url,
    completion: { (dto: SomeResponseDTO) in
        // JSON is loaded and DTO model has been parsed
},
    failure: { error in
        // JSON not loaded and parsed with error
},
    progressHandler: { progress in
        // JSON downloading with progress
)}