A Swift Example of ISL's MVVM Technique
- Create an account or grab a new API key from Dark Sky API
- Make sure CocoaPods is installed and up to date. Run
pod install
in the project directory. - At the root of the repo find the
keys_template.plst
file. Copy or rename tokeys.plist
. - Open
swift-mvvm.workspace
and drag thekeys.plist
into the project and add to target. Open the file an put your API Key in the plist underapiKey
. - Build and run!
To minimize code and highlight the MVVM structure, two dependencies were used to make network calls easier.
- Alamofire
- SwiftyJSON
NetworkManager.swift
- Handles the GET Request to Dark Sky's API.WeatherData.swift
- Data model with the information we want to show in the app.WeatherViewModel.swift
- Takes inWeatherData
and formats the data to be displayed in the views.WeatherTableViewCell.swift
- Updates the view from the view model.Utilities.swift
- Converts the payload into an array ofWeatherData
.