iOS Apps with REST APIs PDF Download - Christina Moulton - Programming Ebook

Latest

Download Programming Ebook

Facebook Page

Thursday, June 29, 2017

iOS Apps with REST APIs PDF Download - Christina Moulton




Book Details 
             TitleiOS Apps with REST APIs
      ISBN-10942878397
         AuthorChristina Moulton
     Publisher: Teak Mobile Inc
    Language: English
        SubjectSwift / Computers & Technology / Programming / Apple Programming
No. of pages: 241
         Format: PDF


1. From JSON API to Swift App

You need to build an iOS app around your team’s API or integrate a third party API. You need a quick, clear guide to demystify Xcode and Swift. No esoteric details about Core Anything or mathematical analysis of flatMap. Only the nitty gritty that you need to get real work done now: pulling data from your web services into an iOS app, without tossing your MacBook or Mac Mini through a window.

You just need the bare facts on how to get CRUD done on iOS. That’s what this book will do for you.

1.1 What Will You Be Able to Do?

After reading this book you’ll be able to:
  • Analyze a JSON response from a web service call and write Swift code to parse it into model objects
  • Display those model objects in a table view so that when the user launches the app they have a nice list to scroll through
  • Add authentication to use web service calls that require OAuth 2.0, a username/password, or a token
  • Transition from the main table view to a detail view for each object, possibly making another web service call to get more info about the objec
  • Let users add, modify and delete objects (as long as your web service supports it)
Hook in to more web service calls to extend you app, like adding user profiles or letting users
submit comments or attach photos to objects

To achieve those goals we’ll build out an app based on the GitHub API, focusing on gists. (If you’re not familiar with gists, they’re basically just text snippets, often code written a GitHub user.) Your model objects might be bus routes, customers, chat messages, or whatever kind of object is core to your app. We’ll start by figuring out how to make API calls in Swift then we’ll start building out our app one feature at a time:
  •  Show a list of all public gists in a table view
  •  Load more results when the user scrolls down
  • Let them pull to refresh to get the latest public gists
  • Load images from URLs into table view cell
  • Use OAuth 2.0 for authentication to get lists of private and starred gists
  • Have a detail view for each gist showing the text
  • Allow users to add new gists, star and unstar gists, and delete gists
  • Handle not having an internet connection with warnings to the user and saving the gists on
    the device

1.2 Who Is This Book For?
 
  • Software developers getting started with iOS but experienced in other languages
  • Front-end devs looking to implement native UIs for iOS apps (no CSS, oh noes!)
  • Back-end devs tasked with getting the data into the user’s hands on iOS
  • Android, Windows Phone, Blackberry, Tizen, Symbian & Palm OS devs looking to expand
    their web service backed apps to iOS
  • Anyone whose boss is standing over their shoulder asking why the API data isn’t showing up
    in the table view yet
1.3 Who Is This Book Not For?
  • Complete newcomers to programming, you should have a decent grasp of at least one object- oriented programming language or have completed several intro to iOS tutorials
  • Designers, managers, UX pros, ... It’s a programming book. All the monospace font inserts will probably drive you crazy.
  • Cross-platform developers dedicated to their tools (including HTML5 & Xamarin), this is all Swift & native UI, all the time
  • Programmers building apps that have little or no web service interaction
  • Game devs, unless you’re tying in a REST-like API
1.4 Using This Book

This book is mostly written as a tutorial in implementing the gists app. Depending on how you learn best and how urgently you need to implement your own app, there are two different approaches you might take:
  1. Work through the tutorials as written, creating an app for GitHub Gists. You’ll understand how that app works and later be able to apply it to your own apps.
  2. Read through the tutorials but implement them for your own app and API. Throughout the text I’ll point out where you’ll need to analyze your own requirements and API to help you figure out how to modify the example code to work with your API. Those tips will look like this:

List the tasks or user stories for your app. Compare them to the list for the gists app, focusing on the number of different objects (like stars, users, and gists) and the types of action taken (like viewing a list, viewing an object’s details, adding, deleting, etc.).

We’ll start with that task in the next chapter. We’ll analyze our requirements and figure out just what we’re going to build. Then we’ll start building the gists app, right after an introduction to making network calls and parsing JSON in Swift.

1.5 What We Mean By Web Services / APIs / REST / CRUD

Like anything in tech there are plenty of buzzwords around web services. For a while it was really trendy to say your web services were RESTful. If you want to read the theory behind it, head over to Wikipedia1. For our purposes in this book, all we mean by “REST web service” or even when we say “web service” or “API” is that we can send an HTTP request and we get back some data in a format that’s easy to use in our app. Usually the response will be in JSON.

Web services are wonderful since they let you use existing systems in your own apps. There’s always a bit of a learning curve with any web service that you’re using for the first time since every one has its own quirks. Most of the integration is similar enough that we can generalize how to integrate them into our iOS apps.

If you want an argument about whether or not a web service is really RESTful you’re not going to find it here. We’ve got work that just needs to get done.

1.6 JSON

In this book we’re going to deal with web services that return JSON. JSON is hugely common these days so it’s probably what you’ll be dealing with. Of course, there are other return types out there, like XML. This book won’t cover responses in anything but JSON but it will encapsulate the JSON parsing so that you can replace it with whatever you need to without having to touch a ton of code. If you are dealing with XML response you should look at NSXMLParser2.

1.7 Versions

This is version 1.1.1 of this book. It uses Swift 2.0, iOS 9, and Xcode 7.1. When we use libraries we’ll explicitly list the versions used. The most commonly used ones are Alamofire 3.1 and SwiftyJSON 2.3.

https://en.wikipedia.org/wiki/Representational_state_transfer https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSXMLParser_Class/

From JSON API to Swift App 4 Version 1.0 of this book used Alamofire 2.0 and SwiftyJSON 2.2. Changes to the code between
versions 1.0 and this version can be found on GitHub3

1.8 Source Code

All sample code is available on GitHub4 under the MIT license5. Links are provided throughout the text. Each chapter has a tag allowing you to check out the code in progress up to the end of that chapter.

Individuals are welcome to use code for commercial and open-source projects. As a courtesy, please provide attribution to “Teak Mobile Inc.” or “Christina Moulton”. For more information, review the complete license agreement in the GitHub repo6.

1.9 Disclaimer

The information provided within this eBook is for general informational purposes only. The author has made every effort to ensure the accuracy of the information within this book was correct at time of publication. Teak Mobile Inc. and/or Christina Moulton do not assume and hereby disclaims any liability to any party for any loss, damage, or disruption caused by errors or omissions, whether such errors or omissions result from accident, negligence, or any other cause.

Teak Mobile Inc. and/or Christina Moulton shall in no event be liable for any loss of profit or any other commercial damage, including but not limited to special, incidental, consequential, or other damages.

Any use of this information is at your own risk.

1.10 Trademarks

This book identifies product names and services known to be trademarks, registered trademarks, or service marks of their respective holders. They are used throughout this book in an editorial fashion only. In addition, terms suspected of being trademarks, registered trademarks, or service marks have been appropriately capitalized, although Teak Mobile Inc. and Christina Moulton cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark, registered trademark, or service mark. Teak Mobile Inc. and/or Christina Moulton are not associated with any product or vendor mentioned in this book.

Apple, Xcode, App Store, Cocoa, Cocoa Touch, Interface Builder, iOS, iPad, iPhone, Mac, OS X, Swift, and Xcode are trademarks of Apple, Inc., registered in the United States and other countries.

https://github.com/cmoulton/grokSwiftREST/compare/Alamofire3 4https://github.com/cmoulton/grokSwiftREST_v1.1
https://opensource.org/licenses/MIT 6https://github.com/cmoulton/grokSwiftREST_v1.1/blob/master/grokSwiftREST/LICENSE.txt

GitHub is a trademark of GitHub, Inc. registered in the United States. Mashape is a trademark of Mashape, Inc. registered in the United States. 

No comments:

Post a Comment