|
|
|
# Basic networking
|
|
|
|
|
|
|
|
https://www.tutorialspoint.com/http/http_requests.htm
|
|
|
|
|
|
|
|
http://www.json.org
|
|
|
|
|
|
|
|
https://github.com/Alamofire/Alamofire
|
|
|
|
|
|
|
|
|
|
|
|
## You should do the following:
|
|
|
|
1. Read about HTTP requests.
|
|
|
|
2. Read about JSON.
|
|
|
|
3. Install Google Chrome and Postman extension.
|
|
|
|
4. Execute `GET` request with `http://gitlab.faifly.com/ios-general/ios-tutorial/uploads/75727472327ca7b210bb1d904438a2d7/tutorial.json` URL. You should see JSON with a list of organizations.
|
|
|
|
5. Create a new branch from develop called feature/basic_networking.
|
|
|
|
6. Create a new class called `RequestManager`, which is subclass of `NSObject`.
|
|
|
|
7. Implement `fetchOrganizations` static method, which accepts one argument - a closure (block) with a single parameter - `[String : AnyObject]`. It should send a `GET` request to a URL specified above and return the response with the help of the closure.
|
|
|
|
8. Add a new button in `OrganizationInfoViewController`, called “Fetch organizations”. Upon tapping that button you should call `fetchOrganizations` method from `RequestManager`, parse it into the database and present an action sheet with a list of organizations. After selecting an organization you should return to `MainViewController` and its table should be reloaded with appropriate organization. Request should be done with `Alamofire`.
|
|
|
|
9. Create a pull request.
|
|
|
|
|
|
|
|
## You should be able to answer the following questions:
|
|
|
|
* What is an HTTP request?
|
|
|
|
* What is JSON?
|
|
|
|
* What data types does JSON support?
|
|
|
|
* What is an HTTP method?
|
|
|
|
* What HTTP methods do you know? What methods are the most common?
|
|
|
|
* What does an HTTP request consists of?
|
|
|
|
* What is Alamofire? |
|
|
|
\ No newline at end of file |