ios - How to call API in background thread? -


i using alamofire api calling in app.

now want call api in background thread when api called, other functionality work propely. how can in alamofire?

this how calling api

func getdesignationlist(pharmacyid : string,completion:(managedesignation : managedesignationlistmodel)-> void)  { let url = "\(vendorurl)all_employee_designation_list" let param : [string : anyobject] = [      "pharmacyid" : pharmacyid ]  alamofire.request(.get, url, parameters: param, encoding: .url).responseobject { (response:response<managedesignationlistmodel, nserror>) in     switch response.result     {     case.success(let value) :         var managedesignationobject : managedesignationlistmodel?         managedesignationobject = value         completion(managedesignation: managedesignationobject!)     case.failure(let error) : break      } }  } 

you doing right already. alamofire calls web services in background threads. if want test works asynchronlusly, can add print("1") after call , print("2") inside response closure.


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -