How to return value from Alamofire

前端 未结 5 2052
忘掉有多难
忘掉有多难 2020-11-22 02:41

I am making url calls thru an API that I created using swift as follows:

class API {

  let apiEndPoint = \"endpoint\"
  let apiUrl:String!
  let consumerKey         


        
5条回答
  •  半阙折子戏
    2020-11-22 03:20

    From the Alamofire README (emphasis added):

    Networking in Alamofire is done asynchronously. Asynchronous programming may be a source of frustration to programmers unfamiliar with the concept, but there are very good reasons for doing it this way.

    Rather than blocking execution to wait for a response from the server, a callback is specified to handle the response once it's received. The result of a request is only available inside the scope of a response handler. Any execution contingent on the response or data received from the server must be done within a handler.

提交回复
热议问题