Building a Coffee Shop App with Swift, Foursquare API and Realm

It’s often said that coders turn coffee into computer programs. Let’s take that to the next level by coding an app that shows you the nearest coffeeshop!

In this coding guide, you’ll use the following techniques:

  • Swift, Xcode and Interface Builder (Auto Layout, Constraints and Storyboards)
  • Realm, the lightweight Core Data replacement for local data storage
  • Foursquare, with “Das Quadrat” library to connect to their REST API
  • CocoaPods and Geolocation

The app monitors your location in a 500 by 500 meter region, and fetches venue data from Foursquare accordingly. You’ll use a map view (MKMapView) and a table view (UITableView) to display the data. Also, you’ll filter data with Realm and then sort it with a closure.


You can check out the full source code and Xcode project for this guide on GitHub: reinderdevries/CoffeeGuide.

Neat, right? Let’s get started!

[Read more…]

How To Create an Expandable Table View in iOS

A common feature of almost all apps is the fact that they provide multiple view controllers to users to navigate and work with. Those view controllers can be used in many ways, such as to simply display some kind of information on-screen, or to gather complex data from user input. Creating new view controllers for different functionalities of an app is often mandatory, and several times a little bit daunting task. However, sometimes it’s possible to avoid creating new view controllers (and their respective scenes in storyboard) if you just make use of expandable tableviews.

As the term suggests, an expandable tableview is a tableview that “allows” its cells to expand and collapse, showing and hiding that way other cells that in any other case would be always visible. Creating expandable tableviews is a nice alternative when it’s required to gather simple data, or to display on-demand information to users. With them, it’s not necessary to create new view controllers just to ask users for data that in any case should exist in one, default view controller. For example, with expandable cells you can show and hide options of a form that collects data without having to leave that view controller at all.


Whether you should use an expandable tableview or not always depends on the nature of the app you develop. However, as the UI of the cells can be customized by subclassing the UITableViewCell class and creating extra xib files, the look and feel of the app should normally not be a problem. So, at the end, it’s just a matter of requirements.

In this tutorial I’m going to show you a simple but efficient way to create expandable tableviews. Note that what you’ll see here does not consist of a unique method for implementing such a feature. Pretty much the implementation is based on the app needs, but my goal here is to present a quite general way that can be reused in most cases. So, by having said that, move to the next part to get a taste of what we’re about to deal with in this tutorial.

[Read more…]

3D Touch Introduction: Building a Digital Scale App and Quick Actions

With the iPhone 6s and 6s Plus, Apple introduced us an entirely new way to interact with our phones: a hard-press gesture. As you may know, this feature was already available on the Apple Watch and MacBook under the name Force Touch. It — literally — added a new dimension to the user interface.

If you’re wondering why Force Touch was renamed 3D touch on the iPhone, you’re not alone. Shortly after Craig Federighi, who was also clearly baffled on the naming, presented this new capability, the first tweets arose. What was wrong with the Force Touch name? Too many Star Wars jokes?

But there is a difference! Apparently 3D Touch is more sensitive in the way that Force Touch can only detect hard presses, whereas 3D Touch can distinguish multiple levels of touches based on how firmly you press.


Though the change may seem unimportant, it allows developers to make more precise measurements on the iPhone. Take this app called Gravity for example that turns your iPhone into a digital scale with Force Touch. Though it was rejected by Apple for not so clear reasons, the idea is wonderful. So to show you how 3D Touch works, let’s try to make a similar app!

[Read more…]

Introduction to tvOS: Building Your First tvOS App

At last month’s Apple Event in San Francisco, Apple announced the fourth generation Apple TV.  This new update, however, is unlike any previous version of the set top box.  Apple’s new TV will sport an App Store allowing users to download apps and games.

Naturally, such an announcement brings a lot of excitement to the developer community.  With the new Apple TV, the Cupertino based giant has introduced a new operating system, based off iOS, called tvOS.  tvOS is essentially iOS but modified.  Using common frameworks and the your favorite programming language (Swift, of course!) we will explore tvOS by writing a few simple apps.

tvOS Apple TV

[Read more…]

Building a ToDo App Using Realm and Swift

After the big evolution in smart phones in the last years, a lot of tools have been developed to make life easier and simpler for developers to deliver the best performance and quality. To rock in the app store today is not an easy job. And to make your app ready for scalability is more harder. When you succeed in have millions of users to your app, you have to care about everything in your app and perform all operations in no time. So one of the problems that face many developers nowadays, is dealing with Database. It really causes a terrible headache for each one of us and I think nowadays you hav only two options: SQLite and Core Data. I was a big fan of Core Data and its power to deal with records and persisting data but I realized that I waste much time dealing with it while developing apps. Recently, I have come across with Realm, a new better replacement for SQLite and Core Data.


[Read more…]

A Beginner’s Guide to NSDate in Swift

If I was ever asked what’s one of the most common stuff I do among all projects, then I would have answered that dealing with dates is definitely one of them. Undoubtably, there’s no developer out there who doesn’t really need to “play” with the NSDate class and handle dates in some manner, no matter how much or little the work on dates is. From simply converting a date value into a string up to performing calculations with dates, there’s always one constant fact: Developers have to be acquainted with this side of programming in iOS. It’s not hard to master, and eventually can lead in gaining time in other more important programming tasks. Working with dates might seem like a hassle to new programmers; however that’s not true. All you need is to get the grasp of it.

The most common operation when using date (NSDate) objects in applications, is to convert them into string objects so they can be properly formatted and shown to the users. Quite common is the reverse action as well; converting strings to date objects. However, these are not the only tasks regarding dates. Here’s a sample list of what else can be done when messing with dates:

  • Compare dates.
  • Calculate dates in the future or in the past, simply by using a reference date (e.g. the current date) and adding or subtracting periods of time (days, months, years, etc).
  • Calculate date differences (e.g. find the elapsed time between two specific dates).
  • Break a date into its components and access each date part separately (day, month, etc).

All the above, including the conversions to and from strings, are subject for discussion in this tutorial. Through the next parts, you’ll see that is actually easy to do whatever you wish with dates, as long as you know what your tools are and how you should use them.


For your reference, I give you next a list of links with some important documentation. Don’t forget to pay a visit in case you need more information on specific topics:

[Read more…]

Working with App Thinning in iOS 9

Update: iOS 9 launched with a bug preventing app thinning from working properly.  As of iOS 9.0.2, this bug has been patched and app thinning works as intended. Please note this when downloading apps from the app store.

iOS 9 is out and it’s already become a massive hit. Only mere weeks after its launch, the new system has been installed on over half of all iOS devices.  That makes it the fastest adoption rate for any version of iOS ever – surpassing iOS 7’s record in 2013.

Following up on my recent post on Search APIs and SFSafariViewController in iOS 9, today we will be working with App Thinning, another exciting feature in iOS 9.  In this tutorial, we’ll explore app thinning, why it is important, and how to take advantage of this exciting new feature in your own apps.


Announced at WWDC, App Thinning is an exciting new technology that will change the entire download process. With users saying big bucks for cellular data contracts, limited storage on iOS devices, and faster downloads, App Thinning is a crucial new feature to learn.  Further, because app thinning has been delayed (more on this later), it’s never been a better time to learn about this exciting new technology.

[Read more…]

A First Look at Contacts Framework in iOS 9

As every iOS release, the version 9, which is officially here for just a few weeks, presents new features and improvements to existing technologies for both users and developers. As we’ve all witnessed, there’s a number of new stuff that has been first-introduced in this version, but there are changes and updates to existing frameworks and libraries as well. Additionally, and that’s always surprising, there are cases where old APIs are left aside and become deprecated, making room for new ones that have been implemented from ground up to fill in the gap instead. The greatest example in iOS 9 is the all brand new Contacts framework, which is here to replace the old AddressBook framework in a fashion modern, simple and a lot more straightforward.

Every developer that has dealt with the AddressBook API in the past can definitely say that it wasn’t the most easy part of the iOS SDK to work with. In general, the AddressBook was difficult to understand and manage, and that fact was even more intense in new developers. All that belongs to history, as the new Contacts framework is way simpler to understand and use; contacts can be fetched, created or updated in no time at all, the contacts-related development time can be dramatically decreased, changes and modification can be done really fast.


In the next few paragraphs we’ll highlight the most important aspects of the Contacts framework. I won’t go into much details, as you can find them all in the official Apple documentation, and the WWDC 2015 session 223 video.

So, first of all, I’ll begin by something crucial, and that is the user privacy. Users are always being asked if they grant access to their contacts data through an application. If they do so, then the app can freely interact with the user’s contacts database. If, on the other hand, users prohibit access to the contacts data, then this decision must be respected by the app and not interact with it at all. In a while we’ll talk more specifically about it, and we’ll see how all possible situations are handled programmatically. Furthermore, keep in mind that the user is always eligible to change the authorization state of the app through the device Settings, so you should always check if your app has the required permissions to access the contacts data or not right before you perform any related task.

[Read more…]

Our Swift Programming Book for Beginners Now Supports iOS 9, Xcode 7 and Swift 2

Our flagship book, Beginning iOS Programming with Swift, has been fully updated for iOS 9, Swift 2 and Xcode 7. Not only is it compatible with latest version of Xcode and iOS, we will walk you through some new features of the SDK such as Stack Views and SFSafariViewController.

But one thing doesn’t change is our “learn by doing” teaching approach. We need you to take actions and write code. You will learn how to build a real world app from scratch. During the process, it will allow you to master Swift 2, Xcode 7, and iOS 9 programming.

The book is now available in PDF, ePub and HTML versions. For our existing customers, you should already receive the free updates.


As a high school AP computer science teacher I work mainly with Java but I also teach several other programming languages so I tend to keep a large library of books on-hand. While many of the other books and online video tutorials I purchased these past years were very good, I found AppCoda’s to be far above all others. Simon has a way of presenting a topic in such a manner where I felt he was teaching me in a classroom environment rather than just me reading words on a screen.
– Ricky Martin, Gulf Coast High School

Take a peek at the book, check out the sample chapters here. If you enjoy reading the sample, now is the best time to order the book!

Getting Started with Search APIs and SFSafariViewController in iOS 9

With iOS 9’s public launch earlier this week, it’s never been a better time to understand how to take advantage of the new and exciting APIs!

When Apple Senior Vice President Craig Federighi announced Search APIs at WWDC 2015 in June, many extolled them as the most powerful feature in iOS 9.

Search APIs offer an exciting new way to interact with users. With iOS 9, Apple has optimized Spotlight with incredible new features that indexes more content than ever. For instance users can fire up spotlight to search web content or data deep within apps. Using popular keywords they can easily access apps (even if they’re not certain the name of the app)! Search APIs help you do this.


Search in iOS 9 will be a major feature for developers. With the release of iOS 9, it’s never been a better time to jump on. Apple’s never been known to be big in the search engine industry, but with Search APIs in iOS 9, that might be about to change!

[Read more…]