Let’s Call REST APIs with AlamoFire, iOS 8 and Swift

Screen Shot 2014-10-26 at 2.22.38 PM

About Rex St John

I am a mobile software engineer and technical evangelist working for Intel’s Mashery subsidiary. Aside from attending dozens of hackathons, workshops and technical events, it is my job to help developers learn about and engage with REST APIs.

iOS 8 Networking With AlamoFire and Swift

Welcome to chapter 1 of my free online eBook “APIs with iOS 8 and Swift.” In this chapter, we will be exploring the basics of REST APIs, learning how to create our first iOS 8 networking application using the AlamoFire library (and using the Swift programming language with Xcode 6). I have written this book to help beginners learn how to interact with REST APIs and learn the basics of iOS 8 development. The GitHub repo for this book is freely available by clicking here.

What are we building?

We are going to be building a basic app to make REST API calls to the JamBase API and display the results in a UISplitViewController. This particular chapter will be primarily concerned with building a very basic networking layer using AlamoFire.
[Read more...]

APIs with iOS 8 and Swift by Rex St John

apis

Screen Shot 2014-10-26 at 2.22.38 PM

About Rex St John

I am a mobile software engineer and technical evangelist working for Intel’s Mashery subsidiary. Aside from attending dozens of hackathons, workshops and technical events, it is my job to help developers learn about and engage with REST APIs.

Introduction

Hello API-friends, I have written this free eBook to help beginners (who I often meet at college and high school hackathons) build their first application with iOS 8, the Swift programming language and Xcode 6. The ultimate goal is to help you create your first Universal (iPhone + iPad) iOS 8 application using Interface Builder, make network calls to an Intel Mashery API and populate a UISplitViewController with the results!

Furthermore, I will be using this guide as a method to explore the basics of testing, REST API fundamentals and HTTP Networking. Instead of simply showing you a few code snippets, I will try to steer you in the direction of common mobile application development best practices!

Some of the topics I will explore here:

  • Creating a iPhone + iPad application using Interface Builder and Universal Storyboards
  • Using Adaptive Layout to create dynamically sizing table cells and table view controllers
  • Using GitHub Submodules to integrate the AlamoFire HTTP networking library
  • Writing basic Async tests using XCTest
  • Basics of the Swift programming language
  • Simple UIAutomation with Xcode 6 instruments

Thanks for stopping by my site, I hope you enjoy the ebook and find it to be a useful starting point.

Chapter 1: Lets Network!

In this chapter, I will be exploring the fundamentals of REST API calls using the Swift programming language, the AlamoFire networking library and the JamBase Intel Mashery API. Click here to read it.

Chapter 2: Let There Be Tables!

In this chapter, we will explore creating a Universal Storyboard, displaying the results we got from our JamBase API calls in a table and then viewing details of each data item when the user clicks on the table cell. Coming soon…

Chapter 3: Lets Test!

Much like eating our broccoli, testing is good for us but we may not feel like doing it. Lets set up some basic testing for our new UI and REST API calls to ensure that we are keeping our code modular and reusable. Coming soon…

Additional Reading

I recommend all beginners with iOS to buy the Swift and iOS 8 by Tutorials books from Ray Wenderlich’s website (he ain’t even paying me to say that!). There are many other resources online but those books are a great starting place.

MoDevWear Hacks

Getting Wi-Fi with Intel Edison On Yosemite / OSX

Pre-Wi-fi Checklist

  • Make sure you are on an open Wi-Fi network with no HTML login screens
  • Make sure you have BOTH Micro-USB cables plugged into your computer from your Intel Edison + Breakout board of choice (Note: The Micro-USB power cable can be plugged into something other than your computer but the other cable must go into your computer)
  • Nice to have but optional: Make sure the Wi-Fi network you are on has “Isolation Mode” turned off – this will prevent you from pairing your computer with Edison over the local network

Simple Wi-Fi Setup

  1. Plug in two Micro-USB cables from Edison into your computer (Note: Make sure both cables plugged in, not just one). Plug in power first, then the other cable.
  2. Flash your Edison if you haven’t already
  3. Open a terminal / console and type “screen /dev/cu.usbserial” then hit “tab” to autocomplete the port (if you are on Windows you may have to install additional drivers)
    1. Add 115200 -L to the end of that, should look like this:
    2. ex. “screen /dev/usbserial.cu-XXXXXX 115200 -L”
  4. Hit “enter”
    1. If Edison is awake and ready to go, you should see a blank screen, hit “enter” two more times to reveal the prompt
    2. Default password is “root”
  5. Now run “configure_edison” or “configure_edison –setup”
    1. Follow the instructions to setup your device and scan for a wi-fi connection
  6. Once you have finished, try running “ping www.google.com” while connected to Edison via the terminal to test connectivity. You should see activity indicating that your Edison is online.

DubHacks Wrap-Up

So much win, not only did team LineLight win Mashery’s “Best use of APIs” award at the first ever DubHacks, they also won the grand prize for the entire event using our USA Today and The Guardian APIs!