Home > Store

Gourmet iOS Developer's Cookbook, The: Even More Recipes for Better iOS App Development

Register your product to gain access to bonus material or receive a coupon.

Gourmet iOS Developer's Cookbook, The: Even More Recipes for Better iOS App Development

eBook (Watermarked)

  • Your Price: $25.59
  • List Price: $31.99
  • Includes EPUB and PDF
  • About eBook Formats
  • This eBook includes the following formats, accessible from your Account page after purchase:

    ePub EPUB The open industry format known for its reflowable content and usability on supported mobile devices.

    Adobe Reader PDF The popular standard, used most often with the free Adobe® Reader® software.

    This eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.


  • Copyright 2015
  • Dimensions: 7" x 9"
  • Edition: 1st
  • eBook (Watermarked)
  • ISBN-10: 0-13-408515-9
  • ISBN-13: 978-0-13-408515-9

The Gourmet iOS Developer’s Cookbook offers a fresh banquet of delicious cutting-edge iOS programming recipes for projects both big and small. Renowned iOS programming expert Erica Sadun brings together  reliable, proven code for creating today’s richest, most robust apps.

Sadun presents innovative ways to make the most of AVFoundation, Text Kit, animation, adaptive interface programming, and much more. As in all of her iOS best-sellers, this pragmatic guide translates modern best practices into working code, distilling key concepts into recipes you can understand and build on.

This is more than just cut-and-paste; using examples, Sadun offers a deep dive into the “how” and “why” of advanced iOS development. The code reflects iOS’s latest capabilities, and every chapter groups related tasks together, so you can jump straight to your solution.

Coverage includes

  • Providing advanced speech generation and barcode recognition features through AVFoundation
  • Automatically updating app text presentation based on user preferences and expectations
  • Extending rich, flexible text throughout your apps with UIKit and Text Kit
  • Seamlessly migrating text designs between  iOS screens and other destinations
  • Generating attributed text strings from  HTML sources
  • Integrating real-world physics for exciting  animations and interactions
  • Creating better interfaces with dynamic animators--and overcoming their pitfalls
  • Achieving greater visual impact with improved user alerts and popovers
  • Implementing clever and compelling effects with non-rectangular views
  • Building adaptive apps that gracefully respond  to any iOS display, orientation, or screen
  • Streamlining development with expert  methods, functions, and techniques
  • Exploring the core concepts you’ll need to migrate successfully to Swift

This book’s source code is frequently updated by the author and can be downloaded at  https://github.com/erica/iOS-Gourmet-Cookbook.

Sample Content

Table of Contents

Preface     xiii

Chapter 1: Media     1

Speech     1

Other Options     3

Delegate Callbacks     3

Dictation     5

Creating Barcodes     5

Filter Parameters     5

Building Codes     6

Reading Barcodes     8

Listening for Metadata Objects     10

Responding to Metadata     11

Extracting Bounds     13

Enhancing Recognition     14

Detecting Faces     14

Building AVFoundation Movies     14

Creating a Pixel Buffer     16

Drawing into the Pixel Buffer     17

Expressive Drawing     18

Building Movies from Frames     19

Adding Images to Movies     23

Wrap-up     24

Chapter 2: Dynamic Typography     25

Type Size and User Needs     25

How Dynamic Type Works     25

Listening for Type Updates     28

Handling Dynamic Type with Attributes     31

Scanning for Text Style Ranges     32

Applying Text Style Ranges     34

Attribute-Ready Dynamic Elements     35

Custom Fonts Faces     36

Dynamic Text Views     37

Custom Sizing     38

Font Descriptors     39

Descriptor Challenges     40

Fonts with Multiple Variations     41

Using String Attributes to Modify Fonts     42

Dynamic Type Gotchas     43

Wrap-up     43

Chapter 3: Text Kit     45

Creating Complex Text Layouts     45

Glyphs     46

Text Storage     55

Layout Managers     56

Text Containers     56

Adaptive Flow     58

Insets     60

Exclusion Paths     60

Bounding Rectangles     62

Using Text Kit to Add Touch to Labels     63

Establishing Text Kit     63

Synchronizing     64

Translating Coordinates     65

Glyphs and Characters     66

Checking for Links     67

Adding Visual Feedback     67

Draggable Exclusion Zones     69

Building PDFs with Text Kit     71

Printing Text View Data     73

Printing PDF Data     74

Wrap-up     74

Chapter 4: Attributed Strings and Document Containers     75

Class Enhancements     75

String Attachments     77

Building Attributed Strings from HTML     78

Document Type Dictionaries     79

Converting HTML Source to Attributed Strings     80

Converting Attributed Strings to Document Representations     81

Generating HTML from Attributed Strings     82

Markup Initialization     83

RTF and RTFD     83

The RTFD Container     84

Initializing Attributed Strings from a File     84

Converting RTFD Text to Data     85

Writing RTFD Containers from Data     86

Inspecting Attributes     87

Establishing Document Attributes     89

Enhancing Attributed Strings     91

Returning Copies with New Attributes     92

Adjusting Attributes     93

Extending Mutable Attributed Strings     94

Text Ranges     95

Calculating Positions     95

Position Geometry     95

Updating Selection Points     97

Hardware Key Support     97

Wrap-up     99

Chapter 5: Animation     101

Keyframe Animation     101

Building Physics with Keyframes     103

Blocking Animators     105

UIKit Spring-Based Animations     106

Practical Uses for Spring Animations     108

System Animations     109

Motion Effects     109

Building Planes     110

Shadow Effects     111

Custom Transition Animations     113

Delegation     114

Building Transitioning Objects     114

Implicit Animations     116

Building an Animation-Ready Layer     116

Building a View Around a Layer     118

Timing     118

Coordinating Animations     119

Building Implicit Completion Blocks     120

Animating Custom Properties     121

Intercepting Updates     122

Drawing Properties     123

Wrap-up     124

Chapter 6: Dynamic Animators     125

Physics-Based Behaviors     125

Building Dynamics     126

Detecting Pauses     127

Creating a Frame-Watching Dynamic Behavior     131

Implementing Snap Zones     133

Leveraging Real-World Physics     135

Connecting a Gravity Behavior to Device Acceleration     137

Creating Boundaries     138

Enhancing View Dynamics     138

Custom Behaviors     139

Creating Custom Dynamic Items     139

Subverting Dynamic Behaviors     141

Better Custom Dynamic Behaviors     142

Custom Secondary Behaviors     144

Collection Views and Dynamic Animators     147

Custom Flow Layouts     147

Returning Layout Attributes     148

Updating Behaviors     149

Building a Dynamic Alert View     150

Connecting Up the Jelly     150

Drawing the View     152

Deploying Jelly     154

Wrap-up     154

Chapter 7: Presentations     155

Alerts     155

Class Deprecations     155

Building Alerts     156

Enabling and Disabling Alert Buttons     161

Adding Text Fields     162

Mask Views     164

Shape Layer Masking     164

Building Mask Views     166

Building Effect Views     169

Building a Blur Effect     170

Adding Vibrancy Effects     171

Animating Effect Views     172

Building Popovers     175

Supporting Bubbles     176

Presenting Popovers     177

Wrap-up     177

Chapter 8: Shape Magic     179

How to Shape a View     179

Expanding Beyond Circles     180

Resizing Bezier Paths     180

Building a Bezier-Based Shape Image View     184

Working with Unclosed Shapes     185

Adding Borders to Shaped Views     187

Building Shaped Buttons     190

Adding Attention-Grabbing Animations to Shaped Views     193

Wrap-up     199

Chapter 9: Adaptive Deployment     201

Traits     201

Trait Properties     202

Defining Traits     202

Combining Trait Collections     203

Designing for Traits     204

UIScreen Properties     205

Coordinate Spaces     205

Application Frame     206

Screen Bounds     206

Scale     207

Rotation     207

Size Classes and Assets     208

Basic Deployment     208

UIKit and Image Views     210

The UIImageAsset Class     210

Building Images from PDFs     211

Overriding Trait Collections     214

Building Side-by-Side iPhone Split Views     215

A Bit More About iOS 8 Split View Controllers     218

Wrap-up     219

Chapter 10: Development Helpers     221

All the Lorems     221

Placeholder Text     221

Image Ipsums     223

Generating Random User Data     225

Bulk Names     225

Generating Random Feeds     227

Random Everything     228

Directives     229

Converting Comments to Warnings     229

Warnings     231

Testing for the Simulator     232

Errors     232

Testing for Inclusion     233

Messages     234

Wrapping Pragmas     234

Overriding Diagnostics     235

Unused Variable Warnings     235

Marking Non-null and Nullable Items     236

Developer Tweaks     236

Saving Files from the Simulator     237

Tighter Logging     238

Wrap-up     238

Chapter 11: A Taste of Swift     239

Swift Versus Objective-C     239

Building iOS Apps in Swift     240

Optionals     243

Inferred Types     244

The Optional Enumeration     245

Unwrapping Optionals     246

Assigning Values to Non-optionals     248

Cocoa Touch Patterns     248

Hybrid Language Development     251

Calling Objective-C from Swift     252

Accessing Classes     252

Calling Swift from Objective-C     253

Preparing Swift for Objective-C     254

Class Descent     255

Building the Basics     256

Watching Progress     257

Learning Swift     259

Wrap-up     260

Index     261


Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information

Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


This site is not directed to children under the age of 13.


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure

Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact

Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice

We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020