Weather Forecast Assigment – iOS – MVP + Clean Architecture
Weather Forecast Assigment is an iOS application built to highlight MVP (Model View Presenter) and Clean Architecture concepts
- Xcode 12+
- Swift 5
High Level Layers
View– delegates user interaction events to the
Presenterand displays data passed by the
Presenter– contains the presentation logic and tells the
Viewwhat to present
Configurator– injects the dependency object graph into the scene (view controller)
Clean Architecture Concepts
UseCase / Interactor– contains the application / business logic for a specific use case in application
Swiftclasses / structs
Gateways & Framework Logic
Gateway– contains actual implementation of the protocols defined in the
Persistence / API Entities– contains framework specific representations
Assignment Application Details
- Overview what I have to do in the assignment application:
- Load data weather, display on view.
- Check search input to make sure the keywords more than three characters berfore trigger search request.
- Check if search request have from Cache (CoreData) before request to the server. This to prevent the request calling to the server at the same time with same request.
- Make new search request to get newest data from server.
- Hande error from server response.
- Store the request & response to CoreData.
- Accessibility supports:
- Scaling text if supported to change the font size.
- The screen reader is enable by VoiceOver.
- Following MVP-Clean Architecture, I have been written:
WeatherPresenter– Return weather data to display on screen, valid input,…
SearchWeatherUserCase– Referenced with
WeatherPresenterto process the search weather by city name feature, it manipulates
Weathers Entityand comunicates with
WeatherGatewayto retrive / persist the weathers entity.
WeatherGateway– Implementation of the protocols defined from Use Cases layer.
ApiWeatherGateway– Using URLSession to request data from server.
LocalPersitenceWeatherGateway– Using CoreData to fetch weather data storaged.
Weatherentity – Contains specific representations, includes:
Weather Entityfrom CoreData.
- Unit Tests
- UI Tests
- The application is a simple iOS application that is written by Swift.
- The application is able to retrieve the weather information from OpenWeatherMaps API.
- The application is able to allow user to input the searching term.
- The application is able to proceed searching with a condition of the search term length must be from 3 characters or above.
- The application is able to render the searched results as a list of weather items.
- The application is able to support caching mechanism so as to prevent the app from generating a bunch of API requests.
- The application is able to manage caching mechanism & lifecycle.
- The application is able to handle failures.
- The application is able to support the disability to scale large text for who can’t see the text clearly
- The application is able to support the disability to read out the text using VoiceOver controls.