Announcing Intermediate iOS 8 Programming with Swift

At the time of this writing, the Swift programming language and iOS 8 have been around for more than 6 months. The new programming language has gained a lot of traction and continues to evolve. It is definitely the future programming language of iOS. If you are planning to learn a programming language this year, Swift should be on the top of your list.

I love to read cookbooks. Most of them are visually appealing with pretty and delicious photos involved. That’s what gets me hook and makes me want to try out the recipes. When I started off writing this book, the very first thing that came into my mind was why most programming books were not well designed. iOS and its apps are all beautifully crafted. But why do a majority of technical books just look like an ordinary textbook?

Intermediate Swift Programming

I believe a visually stunning book will make learning programming much more effective and easy. With that in mind, I set out to make one that looks really great and is joyful to read. That being said, it doesn’t mean I just focus on the visual elements. With over 300 pages and 30 Xcode projects, the book is written for developer with some programming experience on the Swift programming language and with an interest in developing iOS apps. The tips and solutions covered in this book will help you learn more about iOS 8 programming and empower you to build fully functional apps more quickly.

[Read more…]

App Showcase #2: Runr by Sam Spencer

Here comes to the second app showcase. Previously, we showed you an app created by a 17 year old developer. Since we published that story, we received emails from several young developers who also wanted to share their programming experience and app development stories. The world needs more programmers. It’s truly wonderful to see more young people learn to code and create something amazing.

In this app showcase, we talked to Sam Spencer, a 16 year old iOS developer who has released an app called Runr. The app allows you not just to track your runs, jogs and walks but save calories and distance of your runs to the Health app. Runr app is beautifully designed and has been featured by Apple in Health & Fitness “Apps For Your Run”.

runr-featured

Read on and check out Sam’s app development story.

[Read more…]

Creating a Sidebar Menu Using SWRevealViewController in Swift

As promised, here is the Swift version of the slide out sidebar menu tutorial. Again we will make use of an open source library called SWRevealViewController to build the sidebar menu. Though the library was written in Objective-C, you can easily integrate it into any Swift project. You will see how easy you can access and interact with Objective-C classes using Swift.

Okay, let’s get started.

In this tutorial, I will show you how create a slide-out navigation menu similar to the one you find in the Gmail app. If you’re unfamiliar with slide out navigation menu, take a look at the figure on the right. Ken Yarmost gave a good explanation and defined it as follows:

“Slide-out navigation consists of a panel that slides out from underneath the left or the right of the main content area, revealing a vertically independent scroll view that serves as the primary navigation for the application.”

Slideout sidebar menu demo in swift

From what I know, the slide-out sidebar menu was first introduced by Facebook. Since then it quickly becomes a standard way to implement navigation menu. Nowadays, you can easily find this design pattern in most of the popular content-related apps such as Inbox, Digg, LinkedIn, etc.
The slide-out design pattern lets you build a navigation menu in your apps but without wasting the screen real estate. Normally, the navigation menu is hidden behind the front view. The menu can then be triggered by tapping a list button in the navigation bar. Once the menu is expanded and becomes visible, users can close it by using the list button or simply swiping left on the content area.

You can build the sidebar menu from the ground up. But with so many free pre-built solutions on GitHub, we’re not going to build it from scratch. Instead, we’ll make use of a library called SWRevealViewController. Developed by John Lluch, this excellent library provides a quick and easy way to put up a slide-out navigation menu in your apps. Best of all, the library is available for free.
The library was written in Objective-C. But it is very straightforward to integrate it in your Swift project. You will learn how it can be done in a minute.

[Read more…]

App Showcase #1: AffordIt Budget Tracker by Andrew Walker

Last year, we published a series of developer stories to share the learning experience of some first-time app developers. We got great feedback about the stories and their experience inspired others to learn iOS programming. Starting this year, we’re going to bring you more developer stories and showcase their apps on a regular basis. The purpose of these developer stories is twofold:

  • Some said iOS programming is hard to learn. It’s true. It’ll take a lot of hard work to become a competent developer. However, iOS programming is not rocket science. With the release of Swift, it’s now even more approachable to beginners. As long as you put your effort in and are committed to take action, we believe you can build an app from scratch. The developers we interviewed are mostly amateur app developers. We hope their stories would encourage aspiring developers to learn programming and build their own apps.
  • Other than helping our readers learn programming, we always think how to help you promote your apps. With over 1,000,000 apps, the App Store is now extremely competitive. You probably have released your first app on App Store but only got a few downloads. Even if you have a high quality product, it’s not easy to break into the top 100. In the developer stories, we’ll feature an app created by the app developer. In average, we have over 200,000 monthly readers. This is not a big number but we are quite sure it would help your apps gain some exposure. From time to time, we’ll also share the stories with our email subscribers and on our Facebook page. Together we can help each other succeed.
affordit-featured

Without further ado, here comes to the first app showcase – AffortIt.
[Read more…]

Building a QR Code Reader in Swift

So, what’s QR code? I believe most of you know what a QR code is. In case you haven’t heard of it, just take a look at the image below. That’s QR code.

QR (short for Quick Response) code is a kind of 2-dimensional bar code developed by Denso. Originally designed for tracking parts in manufacturing, QR code has gained popularity in consumer space in recent years as a way to encode URL of a landing page or marketing information. Unlike the basic barcode that you’re familiar with, QR code contains information in both horizontal and vertical direction. Thus this contributes to its capability of storing larger amount of data in both numeric and letter form. Here I don’t want to go into the technical details of QR code. If you’re interested, you can check out the official website of QR code to learn more.

qrcode-featured

In recent years, the use of QR code has been on the rise. It appears in magazines, newspapers, advertisement, billboards and even name cards. As an iOS developer, you may wonder how to empower your app to read QR code. Some time earlier, Gabriel wrote a great tutorial on QR code. In this tutorial, we will build a similar QR code reader app but in Swift. After going through the tutorial, you will understand how to use the AVFoundation framework to discover and read QR code in real-time.

Let’s get started.

[Read more…]

Creating Hello World App in Swift Using Xcode 6

The Hello World tutorial was the first programming article written for our iOS programming course. As Apple released Xcode 6, the tutorial is no longer up-to-date. We received quite a lot of emails about the tutorial update. So here you are. Instead rewriting the same tutorial in Objective-C, we’ll show you how to create the Hello World app in Swift. What’s more, we create a screencast for you.

If this is the first time you come across the tutorial, you may wonder why we teach you building a Hello World app. This programming tutorial is written for absolute beginners. We want to encourage you to learn programming. So the first app should be very simple. Despite its simplicity, the “Hello World” app serves a few purposes:

  • It gives you an overview about the syntax and structure of Swift, the new programming language of iOS.
  • It also gives you a basic introduction to the Xcode 6 environment. You’ll learn how to create a Xcode project and lay out your user interface using Storyboard. Even if you’ve used Xcode 5 before, you’ll learn what’s new in the latest version of Xcode.
  • You’ll learn how to compile a program, build the app and test it using the Simulator.
  • Lastly, it makes you think programming is not difficult. I don’t want to scare you away from learning programming. It’ll be fun.

You’ll need to use Xcode 6 (or up) to work on the Hello World project. If you haven’t upgraded to Xcode 6, just download it via this direct iTunes link.

Okay, let’s get started.
[Read more…]

How to Beta Test Your App Using TestFlight

Suppose you built an app and completed the testing of your app on a real device. So what’s next? Submit your app directly to App Store and make it available for download? Yes, you can if your app is a simple one. However, if you’re developing a high quality app, don’t rush to get your app out. I suggest you beta test the app before the actual release.

A beta test is a step in the cycle of a software product release. I know you’ve tested your app using the built-in simulator and on your own device. Interestingly, you may not be able to uncover some of the bugs, even though you’re the app creator. By going through beta test, you would be amazed at the number of flaws discovered at this stage. Beta testing is generally opened to a select number of users. They may be your potential app users, your blog followers, your colleagues, friends or even family members. The whole point of beta testing is to let a small group of real people get their hands on your app, test it and provide feedback. You want your beta tester to discover as many bugs as possible in this stage so that you can fix them before rolling out your app to the public.

You may be wondering how can you conduct a beta test for your app, how beta testers run your app before it’s available on App Store and how testers report bugs?

testflight-featured

In iOS 8, Apple released a new tool called TestFlight to streamline the beta testing. You may have heard of TestFlight before. It has been around for several years as an independent mobile platform for mobile app testing. In February 2014, Apple acquired TestFlight’s parent company, Burstly. With the official release of Xcode 6 and iOS 8, TestFlight is now integrated into iTunes Connect that allows you to invite beta testers using just their email addresses.

TestFlight allows you to arrange testing with external testers and internal users. Conceptually, both can be your testers at the beta testing stage. However, TestFlight refers internal users as members of your development team who have been assigned the Technical or Admin role in iTunes Connect. You’re allowed to invite up to 25 internal users to test your app. An external tester, on the other hand, is considered as an user outside your team and company. You can invite up to 1,000 users to beta test your app. There is a catch, though. Your app must be approved by Apple before you can invite your external testers for testing. This restriction doesn’t apply to internal users. Your internal users can begin beta testing once you upload your app to iTunes Connect.

In this tutorial, I will walk you through the beta test process using TestFlight. At the time of this writing, you can only arrange beta test for internal users only. So we will focus on beta testing with internal users. In general, you need to go through the below tasks to distribute an app for beta testing:

  • Create an app record on iTunes Connect.
  • Update the build string.
  • Archive and upload your app.
  • Manage beta testing in iTunes Connect.

Let’s get started.
[Read more…]

Announcing Our New Book: Beginning iOS 8 Programming with Swift

I’m thrilled to share this great news with you. Our second AppCoda book – Beginning iOS 8 Programming with Swift is now live and ready for purchases!

During the WWDC 2014, Apple surprised every iOS developer by launching a new programming language called Swift. I didn’t expect a new programming language to come out this year. I was expecting to see new APIs for iOS 8 along with a newer version of Xcode. This really surprised me and my friends too. I remember what one of my friends said to me. He told me, “You will have to rewrite your whole book again!”

Seriously. That’s a lot of work. So here comes the new book.

The first AppCoda book was basically an assortment of tutorials, which were published in this blog. It covered everything from the fundamental of Objective-C programming to more advance ones, where each programming technique was accompanied by a fully working app. I am really grateful that the practical approach has gained very positive feedback.

Beginning iOS 8 Programming with Swift

[Read more…]

Understanding Self Sizing Cells and Dynamic Type in iOS 8

In iOS 8, Apple introduces a new feature for UITableView known as Self Sizing Cells. To me, this is seriously one of the most exciting features for the new SDK. Prior to iOS 8, if you want to display dynamic content in table view with variable height, you would need to calculate the row height manually. Now with iOS 8, Self Sizing Cell provides a solution for displaying dynamic content. In brief, here are what you need to do when using self sizing cells:

  • Define auto layout constraints for your prototype cell
  • Specify the estimatedRowHeight of your table view
  • Set the rowHeight of your table view to UITableViewAutomaticDimension

If we express the last two points in code, it looks like this:

1
2
tableView.estimatedRowHeight = 44.0
tableView.rowHeight = UITableViewAutomaticDimension

With just two lines of code, you instruct the table view to calculate the cell’s size matching its content and render it dynamically. This self sizing cell feature should save you tons of code and time. You’re gonna love it.

Introduction to UIAlertController, Swift Closures and Enumeration

Among all the changes in iOS 8 SDK, the changes of two commonly-used APIs in UIKit framework are less known. Both UIActionSheet and UIAlertView classes are now replaced by the UIAlertController class.

In iOS 8, whenever you want to display an alert message in your app, you should use UIAlertController instead the two deprecated classes. The action sheet and alert view become the style of the UIAlertController. You choose one of the styles when creating an alert controller. The way to handle button action is redesigned. You no longer use delegate (e.g. UIAlertViewDelegate) to handle user response. When using UIAlertController, you associate actions with the controller and that the action is expressed as a block in Objective-C or closures in Swift.

In this tutorial, I’ll give you an introduction to the UIAlertController and cover how to use the class to present an alert message, as well as, an action sheet. On top of that, I’ll take this opportunity to cover the basics of closures and enumeration in Swift.

UIAlertController Introduction

Okay, let’s get started.
[Read more…]