This imple app displays weather data from OpenWeatherMap.org. You can build this project yourself following the videos here on youtube here.
The app has the following features:
- Weather information for a city location.
- Image representing the weather condition.
- Current temperature
- Humidity
- Wind speed
#What you will learn
By following the video tutorials and building this app on your own you will learn how to build a simple yet sophisticated app that you can publish to the iTunes store.
Techniques covered in these tutorials:
- Storyboard, and auto layout - this is the system used to create the user interface in Xcode.
- IBOutlets and IBActions - these are the connections between elements created in storyboard and the code you write.
- Swift Basics - Swift is a new programming language created by Apple. This entire tutorial is written in Swift.
- Cocoa Touch - Cocoa Touch is the framework that underlies iOS. The framework is the code that creates all of the underlying systems.
- View Controllers - A view controller represents a screen of information. This is a fundemental building block of iOS development.
- Design Patterns - These are ways of arranging code to solve problems and accomplish goals. This tutorial talks about some of the design patterns user in Cocoa Touch. You will build components using the MVC and Delegate pattern.
- NSURLSession - use this to request data from the internet. In this case you will pass the city name to a service, and receieve the weather data.
- Formatting Numbers - Using NSNumberFormatter to format numeric values for their best display in oyur app.
- Error handling - Making connections to services over the internet leaves plenty of opportunity for errors. You will learn how to handle different types of errors that might occur.
- Working with JSON - JSON is a standard format for passing data over an internet connection. You will learn how to load JSON formatted data using SwiftyJSON.
These example files also include a bonus features for your exploration. This includes:
- CoreLocation
- UIImagePickerController
#Videos
- Create a new project and setup storyboard - Here you will create a project and add labels, and add some constraints fit the elements to the view. Then create IBOulets and IBActions for elements created in storyboard.
- Create an Alert action to input cityname. An alert controller (UIAlertController) displays a popup dialog box. In this video we add a text field and some buttons to this to allow the input of a city name.
- Add a textfield to the alert controller. This takes a look at closures.
- Creating the weather service class. The goal in this video is a class to manage weather data. This discussion talks about the delegate pattern.
- Weather Struct. The app needs a way to pass the weather data around. A struct works well for this.
- OpenWeatherMap. Take a quick tour of the openweathermap.org site, and look at their API.
- Authorizing the app for HTTP. Here we set the security options to allow the app to access HTTP data from OpenWeatherMap.
- Working with JSON and SwiftyJSON. SwiftyJSON is a helper class that simplifies working with JSON.
- Collecting the data and sending it back to the Main thread. Here we take a look at the data return as JSON, and how to access the pieces we need.
- Passing the city name to WeatherService. Here you will make it possible to get the weather for any city.
- Set the City name on the button. Changing the text of the button to match the name of the city.
- Working with Weather icons. Now it's time to display images matching the weather condition.
- Working with other weather properties. Here you will learn to expand the range of weather properties your app displays.
- Using your App ID and response code from openweatherma.org. Looking at status codes and HTTP responses for possible errors.
- Error messages from the weather service. Even when your app is working correctly, its still possible to get errors, your app needs to handle these.
- Handling HTTP responses. Even when the app is working well, there can be a problem with the internet connection.
- JSON Status code. Handling the status code in JSON.
- Working with the status code in the app.
- Formatting numbers.You app needs to display numbers, and you need to format them to best display the information. NSNumberFormatter is tool for the job.
- Get the weather via GPS location.We can also get the weather by using the phones GPS location.