Introduction - Learn iOS 8 App Development, Second Edition (2014)

Learn iOS 8 App Development, Second Edition (2014)

Introduction

I’m standing on a street corner in San Francisco, a city I visit far too infrequently. In my hand I hold an electronic device. The device is receiving status updates about the city’s public transportation system in real time. It is telling me that the F-line rail will arrive at the Market and 5th Street station in seven minutes. It displays a map of the city and, by timing radio waves it receives from outer space, triangulates and displays my exact location on that map. A magnetometer determines which direction I’m holding the device and uses that information to indicate the direction I should walk to meet the rail car in time to board it. My friends call me, wondering when I will arrive. A tiny video camera and microphone share my image and voice with them as I walk. I’m meeting them at a gallery opening. It’s an exhibition of new artwork, by artists from all over the world, created entirely using devices similar to the one I hold in my hand. When I arrive, I use my device to share my experiences with friends and family back home, exchange contact information with people I meet, and look up restaurant suggestions for where we might eat later.

This is a true story. A couple of decades ago, it would have been science fiction.

We live in a time in which personal electronics are changing how we work, travel, communicate, and experience the world. A day doesn’t go by without someone discovering another novel use for them. And while I’m sure you enjoy benefiting from this new technology, you’re reading this book because you want to participate in this revolution. You want to create apps.

You’ve come to the right place.

Who Is This Book For?

This book is for anyone who wants to learn the basic tools and techniques for creating exciting, dynamic applications for Apple products that run the iOS operating system. As of this writing, that includes the iPad, iPhone, and iPod Touch.

This book assumes you are new to developing iOS apps and that you have limited programming experience. If you’ve been learning Swift—Apple’s new programming language—that’s perfect. If you know Objective-C, C, Java, C#, or C++, you shouldn’t have too much trouble following along, and there’s a Swift primer in Chapter 20 that you’ll want to read. If you are completely new to programming computers, I suggest getting a basic Swift programming book—say, Swift for Absolute Beginners by Gary Bennett and Brad Lees—and read that first or in parallel. iOS app are developed using Objective-C or Swift, but this book uses Swift exclusively.

This book will explain the fundamentals of how iOS apps are designed, built, and deployed. You’ll pick up some good design habits, get some core programming skills, and learn your way around the development tools used to create apps.

This book is not an in-depth treatise on any one technology. It’s designed to stimulate your imagination by giving you a firm grounding in building apps that use a variety of device capabilities, such as finding your location on a map, using the accelerometer, taking pictures with the built-in camera, creating dynamic animation, participating in social networks, and storing information in the cloud. From there, you can leap beyond these examples to create the next great iOS app!

Too Cool for School

I’m an “old-school” programmer. I learned programming from the bit up (literally). At the risk of dating myself, the first program I wrote was on a 4-bit microcontroller using toggle switches to input the machine instructions. So, I pretty much knew everything there was to know about machine code before I started to program in “high-level” languages like BASIC and C. All that was well behind me before I wrote my first graphical user interface (GUI) application for the (then-revolutionary) Macintosh computer.

While I value this accumulated knowledge, and much of it is still useful, I realize that a strict “ground-up” approach isn’t necessary to develop great apps for iOS today. Many of the advances in software development over the past few decades have been in insulating the developer—that’s you—from the nitty-gritty details of CPU instructions, hardware interfaces, and software design. This frees you to concentrate on harnessing these technologies to turn your idea into reality, rather than spending all of your time worrying about register allocations and memory management.

So, the exciting news is that you can jump right in and create full-featured iOS apps with only a minimal knowledge of computer programming or the underlying technologies that make them possible. And that’s what this book is going to do in the first couple of chapters—show you how to create an iOS app without any traditional programming whatsoever.

That’s not to say you don’t need these skills in order to master iOS development. On the contrary; the more you know about programming, performance, and memory management, the more proficient you’re going to be. What’s changed is that these skills aren’t the prerequisites that they once were. Now, you can learn them in parallel while you explore new avenues of iOS development.

How to Use This Book

This book embraces an “explore as go” approach. Some chapters will walk you through the process of creating an iOS app that uses the camera or plays music. These chapters may gloss over many of the finer details. In between, you’ll find chapters on basic software development skills. There are chapters on good software design, making the most of sample code and the Swift programming language.

So, instead of the “traditional” order of first learning all of the basic skills and then building apps using those skills, this book starts out building apps and then explores the details of how that happened.

You can read the chapters in any order, skipping or returning to chapters as you need. If you really want to know more about objects in an earlier chapter, jump ahead and read the chapter on objects. If you’re already familiar with the Model-View-Controller design pattern, skip that chapter when you get to it. Treat this book as a collection of skills to learn, not a series of lessons that have to be taken in order.

Here’s a preview of the chapters ahead:

· Got Tools? shows you how to download and install the Xcode development tools. You’ll need those.

· Boom! App walks you through the core steps for creating an iOS app—no programming needed.

· Spin a Web creates an app that leverages the power of iOS’s built-in web browser.

· Coming Events discusses how events (touches, gestures, and movement) get from the device into your app and how you use them to make your app respond to the user.

· Table Manners shows you how data gets displayed in an app and how it gets edited.

· Object Lesson dishes the straight dope on objects and object-oriented programming.

· Smile! shows you how to integrate the camera and photo library into your app.

· Model Citizen explains the magic incantation that software engineers call Model-View-Controller.

· Sweet, Sweet Music jazzes up your mix by showing you how to add music, sounds, and iTunes to your apps.

· Got Views? takes you on a brief survey of the view objects (buttons, sliders, and so on) available in the Cocoa Touch framework.

· Draw Me a Picture shows you how to create your own views, unlocking the power to draw just about anything in an iOS app.

· There and Back Again lays out the basics of app navigation: how your users get from one screen to another and back again.

· Sharing Is Caring is all about getting your content out to the ’net, through services such as Twitter, SMS, and e-mail.

· Game On! dishes out a fun game with real-time animation.

· If You Build It… explains some of the magic behind Interface Builder.

· Apps with Attitude shakes up your apps with the accelerometer.

· Where Are You? draws you a map—literally.

· Remember Me? shows you how user preferences are set and saved and how to share them with other iOS devices using iCloud.

· Doc, You Meant Storage explains how app documents are stored, read, and updated.

· See Swift, See Swift Run is a crash course on the Swift programming language.

· Frame Up escapes the confines of your app to create an extension and teaches you a little about frameworks in the process.