Need to Build an iOS App Around a RESTful API?

Making your first Swift app that uses a web service can be overwhelming. It seems like every time you try to figure it out you just add more things to learn to your list: REST, Alamofire, parsing JSON, OAuth, App Transport Security, setting headers, … But it doesn’t have to be confusing.

With iOS Apps with REST APIs skip the hundreds of pages that barely get into how to make a network call in iOS. No esoteric details about Core Anything or mathematical proofs of flatmap. Only the nitty gritty that you need to get real work done now: interfacing with your web services and displaying the results in your UI.

What Will I 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 object.
  • Let users of your app 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 owned by a user on GitHub.) Your model objects might be bus routes, customers, chat messages, or whatever kind of object is core to your app.

iOS Apps with REST APIs is the guide I wish I had on my first iOS contract when I was struggling to figure out how to get the API data showing up in the app I was building.

I had to comment on how you progressed from simple NSURLSession calls to Alamofire serializers. I really like how you explained why you would choose to use one vs. the other and also how using some libraries can dramatically simplify the code and reduce boiler plate. I wish I didn’t have work to do so I could finish reading it all in one sitting.
Mark Johnson, Sr. Architect Apple Products at Proscape Technologies

What Will I Learn?

Right after you purchase iOS Apps with REST APIs, you’ll get all the information you need to build your first web service backed Swift app. Here’s what’s covered in this 298 page guide:

  • 1. From JSON API to Swift App
  • 2. Our App’s Requirements
  • 3. Swift JSON Parsing & Networking Calls 101
  • 4. Using a Router to Organize Alamofire Calls
  • 5. Parsing JSON with Codable
  • 6. Why I Use Libraries Like Alamofire
  • 7. Hooking Up a REST API to a Table View
  • 8. Custom HTTP Headers
  • 9. Loading UITableViewCell Images from an API
  • 10. Pagination, a.k.a., Load More on Scroll
  • 11. Pull to Refresh
  • 12. Authentication: Basic and HTTP Headers
  • 13. Authentication: The OAuth 2.0 Flow
  • 14. Integrating OAuth with the UI
  • 15. Switching Lists
  • 16. Switching Between View Controllers and More JSON Parsing
  • 17. Adding More API Calls - Starring
  • 18. Deleting Gists
  • 19. Creating Gists and Clearing the Cache
  • 20. What if They’re Offline?
  • 21. What Next?

This book is 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 data isn’t showing up in the tableview yet

This book isn’t for:

  • People completely new 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 with no webservice interaction
  • Game devs
I have pretty much used code and examples from every chapter. I have always been a Microsoft developer and only recently gotten into iPhone development. Your book is exactly what myself and my team needed to get started. Every example was relevant to what we needed for the application we are developing. Thank you for the fantastic job and I am looking forward to the update to the book and all future writings.
Igor Shpak, Director, North American Regions Applications, at Estee Lauder Companies

Who Wrote It?

I’m Christina Moulton, an iOS app developer since 2010 who still randomly types retain]; once in a while. I develop custom iPhone & iPad apps at Teak Mobile Inc in Ontario, Canada. Every part of the process is fun: starting with initial concepts then designing the interface, writing code, and submitting apps to the App Store (well, not really the submission part, iTunesConnect is awful).

Right now I’m off sailing for a few years while writing about getting stuff done in Swift.

I love chatting about Swift. Email me or follow me on twitter.

Christina is the perfect example of the difference between hiring someone who’s just good at what they do and someone who’s great at what they do. In less than 30 days Christina produced an app still has some of our other developers mesmerized with how she produced such quality work in such a short period of time.
Matt Scobel, Manager at Canon Innovation Lab

The Expanded Edition: Get your app built faster.

The 8 page TL;DR Edition will help guide you through the book to find the parts you need and get your app started.

Then once you’re on your way, the Adding More API Reference Sheet will help you through all of the necessary steps each time you find yourself integrating yet another REST API call in your Swift app.

iOS Apps with REST APIs Cover iOS Apps with REST APIs Cover iOS Apps with REST APIs Cover Get the Expanded Edition for $39

FAQs

What version of Swift does it use?

The book was written in Swift 4.1, Alamofire 4.7, iOS 11 (with support back to iOS 10), and Xcode 9.3.

What formats does the book come in?

When you buy the book you’ll get it in PDF, EPUB, and MOBI formats.

Does my API need to be RESTful?

Not really, it’s just a convenient buzzword. All that I mean by “REST web service” or even most of the time that I 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. They’re always a bit of a pain since every one has it’s own quirks but most of the integration is similar enough that we can generalize how to integrate them into our iOS apps.

In other words, 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. Unless your API is SOAP based or something really esoteric the book will probably work for you.

How does the book work?

This book is mostly a series of tutorials in implementing a GitHub gists client app. Depending on how you learn best and how urgently you need to create your own app, there are two different approaches you might take:

  • 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.
  • 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.

Are the code samples included?

All of the code samples in the book are freely available on GitHub and can be used in your own code under an MIT License. Each chapter has a tag allowing you to check out the code in progress up to the end of that chapter.

Does the book have DRM?

No, I don’t want you to have to fight to read the book on the device that you want. You can read the book on anything that will work with PDF, MOBI, or EPUB formats.

What if I’m not happy with the book?

If you’re not happy, I don’t want your money. If you don’t feel the book was worth the price or it’s not right for you or for any reason at all, then I’m happy to refund you. If it’s within 45 days after purchase then you can login to LeanPub and hit the button to get a no questions asked refund there. If it’s been longer than that, email me and I’ll refund you.

Did I Forget Something?

Just email me and I’ll answer ASAP.

Your book made me a rockstar in my company :) I can’t thank you enough!
Dave LaPorte, Senior Developer at Volm Companies Inc

Just the Book

iOS Apps with REST APIs Cover

Expanded Edition

iOS Apps with REST APIs Cover iOS Apps with REST APIs Cover iOS Apps with REST APIs Cover

Team License

iOS Apps with REST APIs Cover

The Book

Example Project Code

The Book

Example Project Code

8-Page TL;DR Guide

Adding More API Calls Checklist

The Book

Example Project Code

8-Page TL;DR Guide

Adding More API Calls Checklist

For teams of any size working for the same company or on the same app