O'Reilly logo

iOS 7 Programming Cookbook by Vandad Nahavandipoor

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Organization of This Book

In this book, we will discuss frameworks and classes that are available in the iOS 7 SDK. This book does its best to teach you the latest and the greatest APIs. As you know, some users of your apps may still be on older versions of iOS, so please consider those users and choose your APIs wisely, depending on the minimum iOS version that you want to target with your apps.

Apple has recommended that you write your apps so that they support and run on iOS 6 and iOS 7. This means you need to use the latest SDK as your base SDK (the SDK that you use to compile your app) and choose iOS 6 as your target, if that’s what your business requirements dictate. If you are required to write your app to support only iOS 7, then you are in for a lot of fun, as you can use all the cool APIs that have been introduced in iOS 7 and discussed in this book.

Here is a concise breakdown of the material each chapter covers:

Chapter 1, Implementing Controllers and Views

Explains how Objective-C classes are structured and how objects can be instantiated. The chapter talks about properties and delegates and subscripting by keys and indexes. Even if you are competent in Objective-C, I strongly suggest that you read this chapter, even if you only skim through it, to understand the basic material that is used in the rest of the book. In this chapter, we will also explore the common usage of various UI components, such as alert views, segmented controls, switches, and labels. We will also talk about customizing these components with the latest APIs provided in the SDK.

Chapter 2, Creating Dynamic and Interactive User Interfaces

Talks about UIKit Dynamics, the newest addition to the UIKit framework. These dynamics allow you to add real-life physics and dynamics to your UI components. This will allow you to create even livelier user interfaces with very small effort on your side.

Chapter 3, Auto Layout and the Visual Format Language

Explains how you can take advantage of Auto Layout in the iOS SDK in order to construct your UI in such a way that it can be resized and stretched to pretty much any screen dimension.

Chapter 4, Constructing and Using Table Views

Shows how you can work with table views to create professional-looking iOS applications. Table views are very dynamic in nature, and as a result, programmers sometimes have difficulty understanding how they should work with them. By reading this chapter and trying out the example code, you will gain the knowledge that is required to comfortably work with table views.

Chapter 5, Building Complex Layouts with Collection Views

Collection views have been available to OS X programmers for quite some time now, and Apple decided to provide the same APIs to iOS programmers in the iOS SDK. Collection views are very much like table views, but they are much more configurable and dynamic. Where in table views we have the concept of sections and rows in each section, collection views bring columns to the equation as well, so that you can display many items in one row if you want to. In this chapter we will have a look at all the great user interfaces that you can create using collection views.

Chapter 6, Storyboards

Demonstrates the process of storyboarding, the new way to define the connections between different screens in your app. The great thing about storyboarding is that you don’t have to know anything about iOS programming to get a simple app running. This helps product analysts, product owners, or designers who work independently of developers to gain knowledge of the UI components iOS offers and to build more robust products. Programmers can also take advantage of storyboarding to easily create prototypes. Storyboarding is just fun, whether you do it on paper or using Xcode.

Chapter 7, Concurrency

As humans, we can do many things simultaneously without thinking much about it. With advances in computer technology, mobile devices are also able to multitask, and they provide programmers with tools and mechanisms that can accomplish more than one task at the same time. This is called concurrency. In this chapter, you will learn about Grand Central Dispatch, Apple’s preferred way of achieving concurrency in iOS. You will also learn about timers, threads, and operations.

Chapter 8, Security

iOS is a very secure operating system, and apps that we write for it also have to adhere to certain security standards and practices. In this chapter, we will discuss how you can take advantage of keychain APIs to make your apps more secure. We will also talk about various steps that you can take to make your user interface more secure.

Chapter 9, Core Location and Maps

Describes how you should use Map Kit and Core Location APIs to develop location-aware iOS applications. First you will learn about maps, and then you will learn how to detect a device’s location and tailor your maps with custom annotations. You will also learn about geocoding and reverse geocoding, as well as some of the methods of the Core Location framework, which are available only in iOS 7.

Chapter 10, Implementing Gesture Recognizers

Demonstrates how to use gesture recognizers, which enable your users to easily and intuitively manipulate the graphical interface of your iOS applications. In this chapter, you will learn how to use all available gesture recognizers in the iOS SDK, with working examples tested on iOS 7.

Chapter 11, Networking, JSON, XML, and Sharing

Demonstrates the built-in JSON and XML parsers. On top of that, this chapter talks about various networking APIs and how programmers can build social networking into our apps to allow our users to share their creations and data to social networks such as Facebook.

Chapter 12, Audio and Video

Discusses the AV Foundation and Media Player frameworks that are available on the iOS SDK. You will learn how to play audio and video files and how to handle interruptions, such as a phone call, while the audio or video is being played. This chapter also explains how to record audio using an iOS device’s built-in microphone(s). At the end of the chapter, you will learn how to access the Music Library and play its media content, all from inside your application.

Chapter 13, Address Book

Explains the Address Book framework and how to retrieve contacts, groups, and their information from the Address Book database on an iOS device. The Address Book framework is composed entirely of C APIs. Because of this, many Objective-C developers find it difficult to use this framework, as compared with frameworks that provide an Objective-C interface. After reading this chapter and trying the examples for yourself, you will feel much more confident using the Address Book framework.

Chapter 14, Files and Folder Management

One of the most important tasks that, as developers, we want to perform in our iOS apps is manipulating files and folders. Whether this means creating, reading from, writing to, or deleting them, this chapter contains enough material to get you up and running with file and folder management in the iOS SDK.

Chapter 15, Camera and the Photo Library

Demonstrates how you can determine the availability of front- and back-facing cameras on an iOS device. You will also learn how to access the photo library using the Assets Library framework. At the end of the chapter, you will learn about editing videos right on an iOS device using a built-in view controller.

Chapter 16, Multitasking

Shows multitasking-aware applications that run beautifully on iOS devices. You will learn about background processing, including how to play audio and retrieve users’ locations in the background, as well as how to download content from a URL while your application is running in the background. On top of that, we will explore some of the new APIs that iOS 7 provides to us, in order to enable our apps to download content periodically while in the background or even while our app is not even running.

Chapter 17, Notifications

Notifications are objects that can be composed by a source and delivered to multiple recipients. In this chapter, we will discuss notifications, including local notifications and push notifications, along with how you can use the latest capabilities built into Xcode to easily enable these features in your own apps.

Chapter 18, Core Data

Describes the details of Core Data stacks and what they are made out of. You will then be able to design your own object-oriented data models right into Xcode, using the Core Data model editor, and also create and retrieve your objects in Core Data. On top of that, you will learn how to add your own custom data to Core Data and how to search for data in the background thread, leaving your UI thread ready to process user events.

Chapter 19, Dates, Calendars, and Events

Demonstrates the use of the Event Kit and Event Kit UI frameworks in order to manage calendars and events on an iOS device. You will see how to create, modify, save, and delete events. You will also learn, through examples, how to add alarms to calendar events and how to set up CalDAV calendars so that you can share a single calendar among multiple devices.

Chapter 20, Graphics and Animations

Introduces the Core Graphics framework. You will learn how to draw images and text on a graphics context; draw lines, rectangles, and paths; and much more. You will also learn to use the new iOS SDK APIs to capture your views’ contents as screenshots.

Chapter 21, Core Motion

Explains the Core Motion framework. Using Core Motion, you will access the accelerometer and the gyroscope on an iOS device. You will also learn how to detect shakes on a device. Of course, not all iOS devices are equipped with an accelerometer and a gyroscope, so you will also learn how to detect the availability of the required hardware.

Chapter 22, iCloud

Shows how to use the iCloud service, which ties devices together and allows them to share data to provide a seamless user experience as the user moves from one device to another.

Chapter 23, Pass Kit

Describes Passbook: a virtual wallet, if you will, capable of managing your coupons, boarding passes, rail and bus tickets, and much more. In this chapter, you will learn all there is to know in order to be able to create your own digitally signed passes and distribute them to your users easily.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required