You are previewing The Gourmet iOS Developer’s Cookbook: Even More Recipes for Better iOS App Development.
O'Reilly logo
The Gourmet iOS Developer’s Cookbook: Even More Recipes for Better iOS App Development

Book Description

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.

    Table of Contents

    1. About This eBook
    2. Title Page
    3. Copyright Page
    4. Dedication Page
    5. Contents
    6. Preface
      1. How This Book Is Organized
      2. About the Sample Code
        1. Getting the Sample Code
        2. Contribute!
        3. Getting GitHub
      3. Contacting the Author
    7. Acknowledgments
    8. About the Author
    9. Editor’s Note: We Want to Hear from You!
    10. 1 Media
      1. Speech
        1. Other Options
        2. Delegate Callbacks
        3. Dictation
      2. Creating Barcodes
        1. Filter Parameters
        2. Building Codes
      3. Reading Barcodes
        1. Listening for Metadata Objects
        2. Responding to Metadata
        3. Extracting Bounds
        4. Enhancing Recognition
        5. Detecting Faces
      4. Building AVFoundation Movies
        1. Creating a Pixel Buffer
        2. Drawing into the Pixel Buffer
        3. Expressive Drawing
        4. Building Movies from Frames
        5. Adding Images to Movies
      5. Wrap-up
    11. 2 Dynamic Typography
      1. Type Size and User Needs
        1. How Dynamic Type Works
        2. Listening for Type Updates
      2. Handling Dynamic Type with Attributes
        1. Scanning for Text Style Ranges
        2. Applying Text Style Ranges
      3. Attribute-Ready Dynamic Elements
        1. Custom Fonts Faces
        2. Dynamic Text Views
      4. Custom Sizing
      5. Font Descriptors
        1. Descriptor Challenges
        2. Fonts with Multiple Variations
        3. Using String Attributes to Modify Fonts
      6. Dynamic Type Gotchas
      7. Wrap-up
    12. 3 Text Kit
      1. Creating Complex Text Layouts
      2. Glyphs
      3. Text Storage
      4. Layout Managers
      5. Text Containers
        1. Adaptive Flow
        2. Insets
        3. Exclusion Paths
        4. Bounding Rectangles
      6. Using Text Kit to Add Touch to Labels
        1. Establishing Text Kit
        2. Synchronizing
        3. Translating Coordinates
        4. Glyphs and Characters
        5. Checking for Links
        6. Adding Visual Feedback
      7. Draggable Exclusion Zones
      8. Building PDFs with Text Kit
      9. Printing Text View Data
        1. Printing PDF Data
      10. Wrap-up
    13. 4 Attributed Strings and Document Containers
      1. Class Enhancements
        1. String Attachments
      2. Building Attributed Strings from HTML
        1. Document Type Dictionaries
        2. Converting HTML Source to Attributed Strings
        3. Converting Attributed Strings to Document Representations
        4. Generating HTML from Attributed Strings
        5. Markup Initialization
      3. RTF and RTFD
        1. The RTFD Container
        2. Initializing Attributed Strings from a File
        3. Converting RTFD Text to Data
        4. Writing RTFD Containers from Data
        5. Inspecting Attributes
      4. Establishing Document Attributes
      5. Enhancing Attributed Strings
        1. Returning Copies with New Attributes
        2. Adjusting Attributes
        3. Extending Mutable Attributed Strings
      6. Text Ranges
        1. Calculating Positions
        2. Position Geometry
        3. Updating Selection Points
      7. Hardware Key Support
      8. Wrap-up
    14. 5 Animation
      1. Keyframe Animation
      2. Building Physics with Keyframes
      3. Blocking Animators
      4. UIKit Spring-Based Animations
        1. Practical Uses for Spring Animations
      5. System Animations
      6. Motion Effects
        1. Building Planes
        2. Shadow Effects
      7. Custom Transition Animations
        1. Delegation
        2. Building Transitioning Objects
      8. Implicit Animations
        1. Building an Animation-Ready Layer
        2. Building a View Around a Layer
        3. Timing
        4. Coordinating Animations
        5. Building Implicit Completion Blocks
        6. Animating Custom Properties
        7. Intercepting Updates
        8. Drawing Properties
      9. Wrap-up
    15. 6 Dynamic Animators
      1. Physics-Based Behaviors
        1. Building Dynamics
      2. Detecting Pauses
        1. Creating a Frame-Watching Dynamic Behavior
      3. Implementing Snap Zones
      4. Leveraging Real-World Physics
        1. Connecting a Gravity Behavior to Device Acceleration
        2. Creating Boundaries
        3. Enhancing View Dynamics
      5. Custom Behaviors
        1. Creating Custom Dynamic Items
        2. Subverting Dynamic Behaviors
        3. Better Custom Dynamic Behaviors
        4. Custom Secondary Behaviors
      6. Collection Views and Dynamic Animators
        1. Custom Flow Layouts
        2. Returning Layout Attributes
        3. Updating Behaviors
      7. Building a Dynamic Alert View
        1. Connecting Up the Jelly
        2. Drawing the View
        3. Deploying Jelly
      8. Wrap-up
    16. 7 Presentations
      1. Alerts
        1. Class Deprecations
        2. Building Alerts
        3. Enabling and Disabling Alert Buttons
        4. Adding Text Fields
      2. Mask Views
        1. Shape Layer Masking
        2. Building Mask Views
      3. Building Effect Views
        1. Building a Blur Effect
        2. Adding Vibrancy Effects
        3. Animating Effect Views
      4. Building Popovers
        1. Supporting Bubbles
        2. Presenting Popovers
      5. Wrap-up
    17. 8 Shape Magic
      1. How to Shape a View
        1. Expanding Beyond Circles
        2. Resizing Bezier Paths
        3. Building a Bezier-Based Shape Image View
        4. Working with Unclosed Shapes
      2. Adding Borders to Shaped Views
      3. Building Shaped Buttons
      4. Adding Attention-Grabbing Animations to Shaped Views
      5. Wrap-up
    18. 9 Adaptive Deployment
      1. Traits
        1. Trait Properties
        2. Defining Traits
        3. Combining Trait Collections
        4. Designing for Traits
      2. UIScreen Properties
        1. Coordinate Spaces
        2. Application Frame
        3. Screen Bounds
        4. Scale
      3. Rotation
      4. Size Classes and Assets
        1. Basic Deployment
        2. UIKit and Image Views
        3. The UIImageAsset Class
        4. Building Images from PDFs
      5. Overriding Trait Collections
        1. Building Side-by-Side iPhone Split Views
        2. A Bit More About iOS 8 Split View Controllers
      6. Wrap-up
    19. 10 Development Helpers
      1. All the Lorems
        1. Placeholder Text
        2. Image Ipsums
        3. Generating Random User Data
        4. Bulk Names
        5. Generating Random Feeds
      2. Random Everything
      3. Directives
        1. Converting Comments to Warnings
        2. Warnings
        3. Testing for the Simulator
        4. Errors
        5. Testing for Inclusion
        6. Messages
        7. Wrapping Pragmas
        8. Overriding Diagnostics
        9. Unused Variable Warnings
        10. Marking Non-null and Nullable Items
      4. Developer Tweaks
        1. Saving Files from the Simulator
        2. Tighter Logging
      5. Wrap-up
    20. 11 A Taste of Swift
      1. Swift Versus Objective-C
      2. Building iOS Apps in Swift
      3. Optionals
        1. Inferred Types
        2. The Optional Enumeration
        3. Unwrapping Optionals
        4. Assigning Values to Non-optionals
      4. Cocoa Touch Patterns
      5. Hybrid Language Development
        1. Calling Objective-C from Swift
        2. Accessing Classes
        3. Calling Swift from Objective-C
        4. Preparing Swift for Objective-C
        5. Class Descent
      6. Building the Basics
        1. Watching Progress
      7. Learning Swift
      8. Wrap-up
    21. Index
    22. Code Snippets