title: Alamofire response object mapping
body: <p>I am an android developer new to swift 3 programming, I am using <a href="https://github.com/Alamofire/Alamofire" rel="noreferrer">Alamofire</a> for making api calls and to avoid tedious json paring I am using <a href="https://github.com/tristanhimmelman/AlamofireObjectMapper" rel="noreferrer">AlamofireObjectMapper</a> library.
  I have a <code>ApiController</code> which has a function to make api calls below is the code for that:</p>
  
  <pre><code>public static func makePostRequest&lt;T: Mappable&gt;(url: String, params: Parameters, networkProtocol: NetworkProtocol, responseClass: T){
  
      let headers = getHeaders()
  
      networkProtocol.showProgress()
  
      Alamofire.request(url, method: .post, parameters: params, encoding: JSONEncoding.default, headers: headers)
          .validate()
          .responseData{ response in
              let json = response.result.value
              var jsonString = String(data: json!, encoding: String.Encoding.utf8)
              let responseObject = responseClass(JSONString: jsonString!)
              switch(response.result){
              case .success(_):
                  networkProtocol.hideProgress()
                  networkProtocol.onResponse(response: response)
                  break
              case .failure(_):
                  networkProtocol.hideProgress()
                  networkProtocol.onErrorResponse(response: response)
                  break
              }
  
      }
  </code></pre>
  
  <p>The Json response template I am getting from server is:</p>
  
  <pre><code>{
   "some_int": 10, 
   "some_array":[...]
  }
  </code></pre>
  
  <p>Below is my model class:</p>
  
  <pre><code>import ObjectMapper
  
      class BaseResponse: Mappable {
      var some_int: Int?
      var some_array: [Array_of_objects]?
  
      required init?(map: Map) {
          some_int &lt;- map["some_int"]
          some_array &lt;- map["some_array"]
      }
  
      func mapping(map: Map) {
  
      }
  }
  </code></pre>
  
  <p>And below is the function to class make the api call:</p>
  
  <pre><code>public static func callSomeApi(params: Parameters, networkProtocol: NetworkProtocol){
      ApiHelper.makePostRequest(url: AppConstants.URLs.API_NAME, params: params, networkProtocol: networkProtocol, responseClass: BaseResponse)
  }
  </code></pre>
  
  <p>Now the error is in the below line </p>
  
  <pre><code>let responseObject = responseClass(JSONString: jsonString!)
  </code></pre>
  
  <p>I am not able to understand how to convert <code>jsonString</code> into the <code>responseClass</code> generic object which I am accepting from View controller</p>
  
  <p>Someone please help me resolve this, stuck on this issue for quite a while now.</p>