Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift Library for Access API

Tags:

android

ios

api

I'm new in iOS development. I have a little experience in Android development and wanna to learn iOS development. In Android i use Retrofit library to access API.

And now i want to know kind of library for access API. I want to discuss about API library that have good performance, easy to use, and easy to understand. yeah of course i already try to find it and i get it :

https://medium.com/ios-os-x-development/restkit-tutorial-how-to-fetch-data-from-an-api-into-core-data-9326af750e10

But i need more idea about library for access API, can anyone help me?

Thank you.

like image 699
Patrick Avatar asked Dec 11 '22 10:12

Patrick


2 Answers

you can Alamofire in ios.

 Alamofire.request("https://httpbin.org/get").responseJSON { response in
    print(response.request)  // original URL request
    print(response.response) // HTTP URL response
    print(response.data)     // server data
    print(response.result)   // result of response serialization

    if let JSON = response.result.value {
        print("JSON: \(JSON)")
    }
}
like image 99
Rasoul Miri Avatar answered Dec 25 '22 01:12

Rasoul Miri


Even though Alamofire might seem like a good choice for networking, the native URLSession along with the Codable protocol provide the same functionality without adding any dependencies to your project.

let task = URLSession.shared.dataTask(with: url) { data, response, error in
    // Handle data, response, and error
}

task.resume()
like image 45
Richard N. Avatar answered Dec 25 '22 01:12

Richard N.