NetworkManager

The NetworkManager class manages network requests and processing of data. The NetworkManager class conforms to the NetworkManagerProtocol, which defines the set of methods and properties that are used to manage network requests and responses.

Use this signature to define the NetworkManager class.

1public class NetworkManager : NetworkManagerProtocol

Create a Shared Instance

Create a shared instance of the NetworkManager class by using this signature.

shared

1public static let shared: NetworkManager

Get REST Requests

Use Async/Await to get all the REST requests asynchronously by using this signature.

fetch(type:request:urlSession:)

1public func fetch<T>(type: T.Type, request: URLRequest, urlSession: URLSession = URLSession.shared) async throws -> T where T : Decodable

Use the parameters in this table to create a fetch request.

Parameters Description
type A type or model of data that you want to decode from the JSON format.
request The URLRequest, which is executed by URLSession.
urlSession An instance of URLSession, which is used to execute the request and manage HTTP requests and responses. The default instance is URLSession.shared.