This is a simple demo application that shows car information, both on a map and a list. If users launch the application, they can see the pins on the map that locates the car. If they tap the pin, a message bubble with the car manufacturer and model name will show up. In addition, there is a button on the upper-right side of the screen. If the button is pushed, the app moves to the next screen and shows a list of car information.
- Query Car Information from JSON
- Display Car Information both in a
MKMapView
and in aUITableView
- Populate car information on a custom
MKMapView
viaMKMapViewDelegate
Method. - Use a open source library(SDWebImage) to download car images asynchronously
- Car images are cached automatically since SDWebImage provides a built-in cache mechanism
- Populate car information on a custom
UITableViewCell
viaUITableViewDataSource
Methods.
This application follows the MVC (Model-View-Controller) pattern.
-
Model Layer - CarInfo class is a subclass of
MKAnnotation
and is defined with Initializer and member variables. It stores information related to the car such as a car image URL, a model name, a location, and so on during the initialization process. -
Controller Layer - CarInfoInMapViewController displays the locations of cars on the
MKMapView
. It holds CarInfo array and the values of the array are assigned after car information is downloaded via the web. As aforementioned, CarInfo is the subclass ofMKAnnotation
and it is used as a data source ofMKMapView
to displayMKPinAnnotationView
on the map. CarInfoListTableViewController is a subclass ofUITableViewController
and holds a carInfo type array which was passed from the CarInfoInMapViewController. The controller populates car information on the tableView viaUITableViewDataSource
Methods. -
View Layer - CarInfoListTableViewCell is responsible for displaying car information including images. The cell has a property observer of CarInfo type which triggers the cell's UI updates when a property is assigned a new value in the Controller layer.
- Clone the repository
$ git clone https://github.com/woogii/CarList.git
$ cd CarList
- Install SwiftLint
$ brew install swiftlint
- Set up the third party library
$ pod install
- Open the workspace in XCode
$ open CarList.xcworkspace/
- Compile and run the app in your simulator or iPhone
The code of this project works in Swift3.0, Xcode 8.3.1 and iOS9