iOS in Practice
Bear P. Cahill
  • October 2012
  • ISBN 9781617291265
  • 304 pages
  • printed in black & white

The direct path to getting your app into the App Store … hands-on and real-world.

Jonas Bandi, TechTalk

iOS in Practice is a hands-on guide with 98 specific techniques to help solve the specific problems you'll encounter over and over as you work on your iPhone and iPad apps. You'll dig into the practical nuts and bolts of applying views, view controllers, table views and cells, audio, images, graphics, file structure—and more. Examples written for iOS 6.

Table of Contents show full



about this book

about the cover illustration

Part 1 Getting started

1. Getting started with iOS development

1.1. The iOS development environment

1.2. Using Xcode

1.3. A quick Hello World app

1.4. Summary

2. Creating an iOS application

2.1. Source code files

2.2. Adding a button to your app

2.3. Connecting your button to an action

2.4. Connecting your label as an outlet

2.5. Implementing your button action

2.6. Delegation

2.7. Summary

Part 2 Putting iOS into practice

3. Using view controllers and images in PicDecor

3.1. UI design concepts

3.2. Creating view controllers and other widgets

Technique 1 Designing a view controller with IB

Technique 2 Adding an ImageView and toolbar to a view

Technique 3 Adding buttons to a view

3.3. Developing actions and outlets

Technique 4 Declaring actions and outlets in Xcode

Technique 5 Connecting actions and outlets to code

3.4. Using the camera/photo album

Technique 6 Adding camera/photo album access

Technique 7 Presenting a view controller modally

Technique 8 Dismissing a modally displayed view controller

3.5. Displaying and handling images

Technique 9 Displaying selected images

Technique 10 Detecting a device without a camera

3.6. Providing email capabilities

Technique 11 Adding in-app email

Technique 12 Scaling an image for email

Technique 13 Using the activity indicator

3.7. Summary

4. Accessing the address book/contacts in Dial4

4.1. Creating a master-detail application with a table view

Technique 14 Creating a master-detail application

4.2. Presenting data using a table view

Technique 15 Displaying data in a table view

Technique 16 Handling table view cell selection

4.3. Accessing the address book

Technique 17 Retrieving the address book entries

Technique 18 Obtaining address book image property

Technique 19 Obtaining grouped properties from the address book

Technique 20 Making a call

Technique 21 Displaying address book record details

4.4. Managing table data

Technique 22 Deleting and rearranging table view rows

Technique 23 Filtering displayed table view data

4.5. Summary

5. MapKit and the camera in WhereIsMyCar

5.1. Using maps with the user’s location

Technique 24 Adding a MapView to a project

Technique 25 Centering and zooming a MapView

Technique 26 Finding the user’s location via CoreLocation

5.2. Displaying details on MapView locations and storing user’s notes

Technique 27 Displaying MapView pins

Technique 28 Storing and retrieving the user’s location

Technique 29 Reverse geocoding

Technique 30 Adding pin callouts

Technique 31 Typing and storing user’s note

5.3. Storing, retrieving, and displaying camera images

Technique 32 Adding a camera control

Technique 33 Receiving and storing the picture

Technique 34 Displaying a picture

5.4. Summary

6. Settings, audio, and shake detection in TimeDown

6.1. Settings bundle in iOS projects

Technique 35 Adding settings to an Xcode project

Technique 36 Initializing iOS settings

Technique 37 Accessing settings values in an app

Technique 38 Setting the app settings icon

6.2. Runtime and time-based UI changes

Technique 39 Rounding corners of a view

Technique 40 Updating the UI with a repeating timer

6.3. Playing audio and vibrating the device

Technique 41 Playing an MP3 file

Technique 42 Vibrating the iPhone

6.4. Detecting and handling device motion

Technique 43 Detecting shaking with the accelerometer

Technique 44 Handling shaking with an action sheet

6.5. Summary

7. CoreData, iPod access, and playing music—PlayMyLists

7.1. Creating a table view project

Technique 45 Create a project with table navigation

Technique 46 Defining entities in CoreData

Technique 47 Creating relationships in CoreData

Technique 48 Inserting and deleting CoreData objects

Technique 49 Creating classes for CoreData entities

7.2. Displaying CoreData for data-driven apps

Technique 50 Display selected item details

Technique 51 Passing a Playlist to the Detail View controller

Technique 52 Replacing the detail view controller

Technique 53 Managing tracks in the selected playlist

7.3. Accessing iPod music

Technique 54 Using the media picker to access music

Technique 55 Finding media info from the iPod

7.4. Playing music with iOS

Technique 56 Playing the playlist

Technique 57 Handling music player updates

7.5. Summary

8. Push notification and in-app purchase—Rock, Paper, Scissors

8.1. Using Apple Push Notification

Technique 58 Provisioning for push notification

Technique 59 Configuring UrbanAirship for APN

Technique 60 Registering your app for push notifications

Technique 61 Registering your app with UrbanAirship

Technique 62 Sending a batch push notification

8.2. In-app purchase

Technique 63 Setting up iTunesConnect for in-app purchase

Technique 64 Creating an in-app test account

Technique 65 Adding in-app purchases to the project

8.3. The Rock, Paper, Scissors game

Technique 66 Designing the game

Technique 67 Overturning a loss

8.4. Summary

9. GameCenter leaderboards and achievements—Rock, Paper, Scissors

9.1. Game Center authentication and leaderboards

Technique 68 Authenticating the player

Technique 69 Configuring leaderboards in iTunesConnect

Technique 70 Saving the player’s score

Technique 71 Displaying the leaderboard

9.2. GameCenter achievements

Technique 72 Adding an achievement in iTunesConnect

Technique 73 Reporting achievement progress

Technique 74 Displaying achievement boards

9.3. Matching and playing via GameCenter

Technique 75 Matching players

Technique 76 Inviting friends to play

Technique 77 Voice chat via the GameCenter

9.4. Summary

10. iTunes API, iPad, and iAd—MusicSearch

10.1. Searching for music with the iTunes API

Technique 78 Querying with the iTunes API

Technique 79 Displaying JSON results

Technique 80 Playing song preview

10.2. Converting an app to iPad

Technique 81 Converting the project in Xcode

Technique 82 Adding a split view to the app

Technique 83 Displaying items in the detail view

Adding iAds to an app

Technique 84 Configuring iTunes for iAds

Technique 85 Adding iAds to an app

10.3. Summary

11. Collection view, social, reminders, and state restoration—MeetSocial

11.1. Presenting data using a collection view

Technique 86 Creating a project to use a collection view

Technique 87 Fetching search results from

Technique 88 Displaying items in a collection view

11.2. Sharing via the Social Framework

Technique 89 Specifying activity items

Technique 90 Presenting the activity sharing interface

11.3. Creating calendar items in the OS

Technique 91 Creating the event store and calendar event

Technique 92 Creating a calendar reminder

11.4. Saving and restoring the UI state

Technique 93 Specify that an app will save/restore

Technique 94 Setting restoration IDs on objects

Technique 95 Assigning restoration classes

Technique 97 Table/collection datasource considerations

Technique 98 Additional app version and state data

11.5. Summary

Appendix A: The iOS developer program and app distribution


About the book

When you are building an iOS app, you want more than basic concepts—you want real answers to practical problems. You want iOS in Practice.

This book distills the hard-won experience of iOS developer Bear Cahill into 98 specific iOS techniques on key topics including managing data, using media, location awareness, and many more. And the sample apps are wonderful! As you pull them apart, you'll see two things: experienced app development and creative design savvy in action.

What's inside

  • WhereIsMyCar drives you through maps, CoreLocation, and camera access.
  • PlayMyLists tunes in on settings, audio, and shake detection.
  • Rock, Paper, Scissors explores networking, voice, in-app purchase, push notification, and invitations.
  • Examples written for iOS 6 using Xcode 4.5.

About the reader

Written for readers who know the basics of Objective-C and are interested in practical app development.

About the author

Bear Cahill is an independent iOS developer whose clients include both large and small companies. He has created or contributed to numerous popular apps and is a frequent speaker and presenter. He writes a blog at

combo $44.99 pBook + eBook
eBook $35.99 pdf + ePub + kindle

FREE domestic shipping on three or more pBooks

If you’re a web developer wanting to add iOS to your repertoire, Bear is the guide for you.

Stephen Aument, web and mobile consultant

A quick and easy way to get into the iOS mindset.

Christopher Haupt, Webvanta Inc.