CleanWeather is an iOS weather app that offers an elegant way to check the weather. It uses the OpenWeather API to provide real-time weather data, and it's built with a clean and user-friendly UI. The app employs various design patterns and technologies to ensure a robust and responsive user experience.
-
Real-Time Weather Data: CleanWeather fetches the latest weather data using the OpenWeather. This includes current conditions, temperature and more.
-
MVC Design Pattern: CleanWeather follows the Model-View-Controller (MVC) architectural pattern, ensuring a clean separation of concerns and maintainability of the codebase.
-
Delegate Design Pattern with Protocols: Delegates and protocols are used to facilitate communication between different parts of the app, promoting modularity and extensibility.
-
Swift URLSession: Swift's URLSession is used for efficient data retrieval from the web, guaranteeing a responsive user experience.
func apiRequest(with url: URLComponents) {
if let urlRequest = url.url {
let session = URLSession(configuration: .default)
let task = session.dataTask(with: urlRequest) { data, response, error in
if error != nil {
print("Error apiRequest")
self.delegate?.didFail(error: error!)
return
}
if let safeData = data {
if let weather = self.jsonParse(weatherData: safeData) {
self.delegate?.didUpdateWeather(self, weather: weather)
}
}
}
task.resume()
}
}
-
Swift Extensions: Swift extensions are harnessed to enhance the app's functionality and maintainability.
-
Swift CoreLocation: The app utilizes Swift CoreLocation to determine the user's location, enabling access to weather information for the current location or any other specified location.
extension ViewController: CLLocationManagerDelegate {
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
if let location = locations.last{
locationManager.stopUpdatingLocation()
let lat = location.coordinate.latitude
let lon = location.coordinate.longitude
apiManager.getWeatherData(latitude: lat, longitude: lon)
}
}
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
print(error)
}
}
-
JSON Decoding: JSON decoding is employed to parse data from the OpenWeather API, ensuring accurate and meaningful weather information.
-
Dark Mode Support: CleanWeather iOS weather app supports Dark Mode, providing users with the option to switch between light and dark interfaces for comfortable viewing in various lighting conditions.
CleanWeather follows the Model-View-Controller design pattern for structured and organized code architecture. The Model handles data and business logic, the View handles the user interface, and the Controller acts as the intermediary.
The app uses the Delegate design pattern in combination with protocols to facilitate data communication and separation of concerns. This ensures modular and efficient code.
- OpenWeather RESTful API (Free Subscription): The app relies on a RESTful API to obtain weather data. You'll need to sign up for a free API key from OpenWeather REST API provider and integrate it into the project to fetch weather data. To use the REST API, you'll need to make HTTP requests to specific endpoints provided by the API service and handle responses according to their documentation. This transition allows the app to access accurate and up-to-date weather data while maintaining a responsive user experience. OpenWeather's RESTful API is commonly used by developers to integrate weather information into their applications and services.
CleanWeather works by fetching weather data from the OpenWeather API based on the specified location or the user's current location. It uses Swift's CoreLocation framework to determine the device's location. The app follows the MVC design pattern for structured code organization and the delegate design pattern with protocols for efficient data communication.
To run CleanWeather on your local machine, follow these steps:
-
Clone the repository:
git clone https://github.com/serhatcihangir/CleanWeather.git
-
Open the Xcode project.
-
Build and run the app on your iOS device or simulator.
We welcome contributions from the open-source community! Whether you want to report a bug, suggest a feature, or submit a pull request, your involvement is appreciated. Here's how to contribute:
- Fork the repository.
- Create a new branch (e.g.,
feature/new-feature
). - Commit your changes.
- Push to your branch.
- Create a Pull Request.