title: How to use singleton with Alamofire using Swift 3?
body: <p>I am new in iOS and I am bit confused that how to use singleton with Alamofire and how singleton is important. I created a networkWrapper class in that I have written Alamofire  post and get method, but I didn't use singleton.</p>
  
  <p>How can I create a Wrapper class of Alamofire with singleton? How can I get all tricks that is really important?</p>
  
  <p>Below is my code for wrapper class:</p>
  
  <pre><code>import Foundation
  import UIKit
  import Alamofire
  import SwiftyJSON
  
  class AFWrapper: NSObject {
  
  //TODO :-
  /* Handle Time out request alamofire */
  
  
   class func requestGETURL(_ strURL: String, success:@escaping (JSON) -&gt; Void, failure:@escaping (Error) -&gt; Void)
      {
          Alamofire.request(strURL).responseJSON { (responseObject) -&gt; Void in
              //print(responseObject)
              if responseObject.result.isSuccess {
                  let resJson = JSON(responseObject.result.value!)
                  //let title = resJson["title"].string
                  //print(title!)
                  success(resJson)
              }
  
          if responseObject.result.isFailure {
              let error : Error = responseObject.result.error!
              failure(error)
          }
      }
    }
  
  static func requestPOSTURL(_ strURL : String, params : [String : AnyObject]?, headers : [String : String]?, success:@escaping (JSON) -&gt; Void, failure:@escaping (Error) -&gt; Void){
      Alamofire.request(strURL, method: .post, parameters: params, encoding: JSONEncoding.default, headers: headers).responseJSON { (responseObject) -&gt; Void in
          //print(responseObject)
          if responseObject.result.isSuccess {
              let resJson = JSON(responseObject.result.value!)
              success(resJson)
          }
          if responseObject.result.isFailure {
              let error : Error = responseObject.result.error!
              failure(error)
          }
      }
    }
  }  
  </code></pre>
  
  <p>In my controller:</p>
  
  <pre><code>           if newLength == 6
              {
                  let textZipCode = textField.text! + string
  
                  let dict = ["id" : "43","token": "2y103pfjNHbDewLl9OaAivWhvMUp4cWRXIpa399","zipcode" : textZipCode] as [String : Any]
  
                  //Call Service
                 AFWrapper.requestPOSTURL(HttpsUrl.Address, params: dict as [String : AnyObject]?, headers: nil, success: { (json) in
                      // success code
                      print(json)
                  }, failure: { (error) in
                      //error code
                      print(error)
                  })
  
  
                  setFields(city: "Ajmer", state: "Rajasthan", country: "India")
                  return newLength &lt;= 6
              }
  </code></pre>