The API Awakens

This app can be used to view stats for Star Wars characters, vehicles, and spaceships by fetching this data from the Star Wars API.

This was created for Treehouse iOS Techdegree Unit 6.

Technical Background

The app relies on the Star Wars API for all of its data. It fetched data for characters, vehicles, and spaceships and displays these stats in a table view. Displaying character stats required a bit more work because each character has associations vehicles, spaceships, and a homeworld. These associations are sent as URLs. So to get the actual data for these entities requires follow-up API calls to get more data. Because the Star Wars API is such a small data set, character fetches could be sped up by downloading all entities for vehicles, spaceships, and homeworlds, and storing them in dictionaries using each entity's URL as its key. This way, fetching more information about a character's associated spaceships would just be a matter of getting the values out of the spaceships dictionary. Much faster than a follow-up API query. This would not be possible with a large data-set however as this would eat up way too much memory.

To download all entities in a certain category was not as straightforward as making a single request to get them all. The API is paginated, so a recursive asynchronous loop was created to download each page until the last page is reached.


Star Wars App – Characters


Because the screens for characters, vehicles, and spaceships all looked very similar, one view controller was used for all of them. A UIPickerView is used to select which entity to view the stats of. Resizable cells needed to be used for a list of vehicles and starships associated with a character. UISegmentedControls were added to allow users to convert between English and Metric units for things like character height or spaceship length. A UISegmentedControl was also used to convert currency between US dollars and galactic credits for vehicles and spaceships.


Star Wars App – Spaceships