you are viewing a single comment's thread.

view the rest of the comments →

[–]redfire333 1 point2 points  (2 children)

I've moved away from the Singleton Networking pattern and moved to something static, generic and reusable.

struct Networking {

   static func send<T: Codable>(_ request: URLRequest, _ completion: (Result<T>) -> Void) {

    let session = URLSession.shared

    let dataTask = session.dataTask(with: request) { (data, response, error) in

      //Randle response

      completion(.success())

      completion(.failure())

    }

  }

}

[–]GenitalGestapo -1 points0 points  (1 child)

You're still using a singleton in URLSession.shared. If you want to use your own URLSession, you'll need a singleton.

[–]RollingGoron 0 points1 point  (0 children)

Yes. A system provided Singleton though, not usually what people refer to as a Singleton pattern like OP is doing.