Summary
If you have made it this far, then great job! You have not only created an API server using Swift but also built a network-based iOS application that uses the API you built to load and save data. There are a few things we can improve in the app, such as having better error handling, as we have not taken care of a situation where there is no network connection or there is a bad network taking the network request a long time to return. Nevertheless, you should have a good understanding of how to make a network request from your iOS application and make different kinds of HTTP requests, such as GET
, POST
, PUT
, and DELETE
. You should also have a better grasp on how to convert Swift class objects to JSON data to send to our API server, and convert JSON data from the API response into Swift class objects to be used in our iOS code. This has become a lot easier, starting with Swift 4, due to the codable protocol and CodingKeys
, which helped map out keys from the JSON object to attributes...