iOS Apps with REST APIs

By Christina Moulton

Making your first fast app that makes use of an online provider could be overwhelming. it sort of feels like several time you are trying to determine it out you simply upload extra issues to profit in your record: relaxation, Alamofire, parsing JSON, OAuth, App delivery safety, environment headers, … however it doesn’t must be complicated.

Show description

Quick preview of iOS Apps with REST APIs PDF

Similar Programming books

Joe Celko's SQL for Smarties: Advanced SQL Programming Third Edition (The Morgan Kaufmann Series in Data Management Systems)

SQL for Smarties used to be hailed because the first ebook dedicated explicitly to the complex concepts had to rework an skilled SQL programmer into a professional. Now, 10 years later and within the 3rd variation, this vintage nonetheless reigns ideally suited because the e-book written through an SQL grasp that teaches destiny SQL masters.

Designing Audio Effect Plug-Ins in C++: With Digital Audio Signal Processing Theory

Not only one other theory-heavy electronic sign processing booklet, nor one other uninteresting build-a-generic-database programming booklet, Designing Audio impact Plug-Ins in C++ supplies every little thing you every little thing you must understand to just do that, together with absolutely labored, downloadable code for dozens audio impression plug-ins and virtually awarded algorithms.

Effective C++: 55 Specific Ways to Improve Your Programs and Designs (3rd Edition)

“Every C++ expert wishes a replica of potent C++. it really is an absolute must-read for a person taking into consideration doing severe C++ improvement. If you’ve by no means learn powerful C++ and also you imagine you recognize every little thing approximately C++, reconsider. ”— Steve Schirripa, software program Engineer, Google “C++ and the C++ group have grown up within the final fifteen years, and the 3rd version of powerful C++ displays this.

Cocoa Design Patterns

“Next time a few child exhibits up at my door soliciting for a code overview, this can be the booklet that i'm going to throw at him. ”   –Aaron Hillegass, founding father of enormous Nerd Ranch, Inc. , and writer of Cocoa Programming for Mac OS X   Unlocking the secrets and techniques of Cocoa and Its Object-Oriented Frameworks   Mac and iPhone builders are usually crushed through the breadth and class of the Cocoa frameworks.

Extra resources for iOS Apps with REST APIs

Show sample text content

DateStyle = . ShortStyle self. dateFormatter. timeStyle = . LongStyle } } } Then we simply have to set the textual content for the refresh control’s label every time we load new facts: func loadGists(urlToLoad: String? ) { self. isLoading = precise GitHubAPIManager. sharedInstance. fetchPublicGists(urlToLoad) { (result, nextPage) in self. isLoading = fake self. nextPageURLString = nextPage // inform refresh keep watch over it will possibly cease displaying up now if self. refreshControl ! = nil && self. refreshControl!. clean { self. refreshControl?. endRefreshing() } // ... // replace "last up-to-date" name for refresh regulate allow now = NSDate() allow updateString = "Last up to date at " + self. dateFormatter. stringFromDate(now) self. refreshControl?. attributedTitle = NSAttributedString(string: updateString) self. tableView. reloadData() } } nine. three And That’s All store and run. You’ll see your refresh regulate exhibit the final refresh time and it’ll replace every time you refresh: Pull to refresh with date in the event you received uninterested in typing, here’s the code: (tagged “pull_to_refresh”). 10. Authentication: simple and HTTP Headers If you’re construction an app according to a leisure API you’re most likely going to wish to authenticate at some point soon. it's possible you'll even have to authenticate to make any leisure calls in any respect. utilizing the GitHub API, we’ll work out tips on how to organize kinds of authentication: easy auth and OAuth 2. zero. Our gists app will ultimately use the OAuth 2. zero authentication. We’ll additionally conceal the best way to use header/token auth utilizing Mashape. 10. 1 The doctors when you wish to dig into documentation, learn up at the GitHub API medical doctors for authentication. If we try out the medical doctors we’ll discover a few key issues: The GitHub API can be utilized with uncomplicated Auth or OAuth 2. zero If we strive to authenticate with invalid credentials we’ll get a 401 Unauthorized reaction Requests that require authentication will go back 404 now not chanced on, rather than 403 Forbidden, in a few locations. money your documentation for authentication standards. enforce the component of this bankruptcy that fits your API. additionally enforce the integrating the authentication on your API supervisor as proven close to the top of this bankruptcy. 10. 2 simple Auth: Username/Password We’ll finally be including OAuth 2. zero yet we’ll conceal how one can use uncomplicated auth first. For now we’ll simply print the API effects to verify that we’ve succeeded, just like once we arrange printPublicGists. We’ll organize returning the arrays of gists for the desk view to demonstrate after we enforce OAuth 2. zero later during this bankruptcy. Let’s upload a statement for a functionality that would make an API name utilizing easy auth: classification GitHubAPIManager { // MARK: - simple Auth func printMyStarredGistsWithBasicAuth() -> Void { // TODO: enforce } } We’ll have to upload the decision to get starred gists to our router: enum GistRouter: URLRequestConvertible { static allow baseURLString:String = "https://api. github. com/" case GetPublic() // GET https://api. github. com/gists/public case GetMyStarred() // GET https://api. github. com/gists/starred case GetAtPath(String) // GET at given direction var URLRequest: NSMutableURLRequest { var technique: Alamofire.

Download PDF sample

Rated 4.68 of 5 – based on 36 votes