O'Reilly logo

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

iOS Programming Cookbook

Book Description

Over 50 exciting and powerful recipes to help you unearth the promise of iOS programming

About This Book

  • Create high performance iOS apps with a focus on application development APIs and techniques
  • Enrich your UI skills with UIStoryboard, Autolayout, Size classes, and Container view
  • Produce enhanced results with iOS 10 as a result of learning and implementing pro-level practices, techniques, and solutions

Who This Book Is For

If you are an iOS developer on a quest to develop your perfect iOS app, then this book is for you. It would also prove to be a valuable resource for those who want to get up and running with iOS development through a clear, practical approach. In order to unleash the full potential of this book, basic Swift programming knowledge is necessary.

What You Will Learn

  • Build your own custom UIViews through code or the interface builder
  • Implement a dynamic and interactive interface in an iOS app
  • Work on various graphics related elements and the process of using them together to make meaningful shapes.
  • Use the side over and split view to interact with multiple apps concurrently
  • Encrypt JSON calls to make the app more secure
  • Work on web markup feature to enhance search optimization

In Detail

Do you want to understand all the facets of iOS programming and build complex iOS apps? Then you have come to the right place. This problem-solution guide will help you to eliminate expensive learning curves and focus on specific issues to make you proficient at tasks and the speed-up time involved.

Beginning with some advanced UI components such as Stack Views and UICollectionView, you will gradually move on to building an interface efficiently.

You will work through adding gesture recognizer and touch elements on table cells for custom actions. You will work with the Photos framework to access and manipulate photos. You will then prepare your app for multitasking and write responsive and highly efficient apps. Next, you will integrate maps and core location services while making your app more secure through various encryption methods. Finally, you will dive deep into the advanced techniques of implementing notifications while working with memory management and optimizing the performance of your apps. By the end of the book, you will master most of the latest iOS 10 frameworks.

Style and approach

This is the best practical resource on iOS 10 development. This book, with its no nonsense approach and a clear practical focus, will be your best friend on your quest to develop your perfect iOS app. The best thing about this book is that in addition to recipes on iOS programming techniques and app development essentials, it will take you on a complete guided tour of all the new app development APIs that are shipped with iOS 10.

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

Table of Contents

  1. iOS Programming Cookbook
    1. iOS Programming Cookbook
    2. Credits
    3. About the Author
    4. About the Reviewer
    5. www.PacktPub.com
      1. Why subscribe?
    6. Customer Feedback
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Sections
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
        5. See also
      5. Conventions
      6. Reader feedback
      7. Customer support
        1. Downloading the example code
        2. Downloading the color images of this book 
        3. Errata
        4. Piracy
        5. Questions
    8. 1. Swift Programming Language
      1. Introduction
      2. Using closures to create self-contained code
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Inferring type
          2. Omitting the return keyword
          3. Shorthand arguments
      3. Creating enumerations to write readable code
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Enum raw values
            1. Assigning raw values
            2. Using Enums with raw values
          2. Enums with associated values
      4. Working with protocols and delegates
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Mutating methods
          2. Delegation
          3. Class-only protocols
          4. Checking protocol conformance
          5. Optional requirements
      5. Using extensions to extend classes functionality
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Mutating instance methods
          2. Adding new initializer
          3. Define subscripts
      6. Working with memory management and ARC
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      7. Using error handling
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Multiple catch statements
          2. Disable error propagation
      8. Using generics to write generic and reusable code
        1. Getting ready
        2. How to do it...
        3. How it works...
    9. 2. The Essentials
      1. Introduction
      2. Using UIView via code or interface builder to build your own custom views
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      3. Working with navigation controller and navigation bar
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Push and pop
          2. Hiding navigation bar
          3. Navigation bar color
      4. Working with stack views
        1. How to do it
        2. How it works...
      5. Working with UICollectionView
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Customizable layouts
      6. Working with gestures like swipe, pan, rotation, and tap
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      7. Using 3D touch
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Home screen quick actions
    10. 3. Integrating with Messages App
      1. Introduction
      2. Integrating iMessage app with sticker pack
        1. Getting ready
          1. Stickers
        2. How to do it...
        3. How it works...
        4. There's more...
      3. Integrating iMessage app with iMessage app
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Showing progress indicator
          2. Request files with pagination
    11. 4. Working with Interface Builder
      1. Introduction
      2. Using storyboards
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Segues attributes
          2. Preparing for a segue
          3. Unwind segues (exit segues)
          4. Custom segues
      3. Working with Autolayout and constraints
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Updating constraints
      4. Designing your interface builder for any size classes in one storyboard
        1. Getting ready
        2. How to do it...
        3. How it works...
      5. Embedding view controllers using container view
        1. How to do it...
        2. How it works...
        3. There's more...
    12. 5. Working with UITableView
      1. Introduction
      2. Working with scroll view
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      3. Using TableView sections, headers and footers
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Custom section header and footer
      4. Using custom cells
        1. Getting ready
        2. How to do it...
        3. How it works...
      5. Resizing table view cells dynamically
        1. How to do it...
        2. How it works...
      6. Editing table views
        1. Getting ready
        2. How to do it...
          1. Inserting cells with animation
          2. Removing cells with animation
          3. Dragging and dropping to reorder cells
        3. How it works...
        4. There's more...
    13. 6. Animations and Graphics
      1. Introduction
      2. Drawing text, images, lines, rectangles, and gradients
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      3. Animating shapes drawn with UIBezierPath
        1. Getting ready
        2. How to do it...
        3. How it works...
      4. Animating UIViews
        1. How to do it...
        2. How it works...
    14. 7. Multimedia
      1. Introduction
      2. Working with audio capabilities
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Recognizing speech
      3. Playing videos
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Slide Over
          2. Split View
          3. Picture-in-Picture
      4. Capturing photos and videos
        1. How to do it...
        2. How it works...
      5. Using filters with CoreImage
        1. How to do it...
        2. How it works...
    15. 8. Concurrency
      1. Introduction
      2. Using Dispatch queues
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      3. Using Operation queues
        1. Getting ready
        2. How to do it...
        3. How it works...
      4. Using Operation subclassing
        1. How to do it...
        2. How it works...
    16. 9. Location Services
      1. Introduction
      2. Detecting user location
        1. How to do it...
        2. How it works...
      3. Displaying pins in map view
        1. Getting ready
        2. How to do it...
        3. How it works...
      4. Getting directions between locations
        1. How to do it...
        2. How it works...
      5. Working with geofencing
        1. How to do it...
        2. How it works...
    17. 10. Security and Encryption
      1. Introduction
      2. Using Touch ID for user authentication
        1. Getting ready
        2. How to do it...
        3. How it works...
      3. Working with Keychain
        1. Getting ready
        2. How to do it...
        3. How it works...
      4. Encryption
        1. Getting ready
        2. How to do it...
        3. How it works...
    18. 11. Networking
      1. Introduction
      2. Using NSURLSession API for network connections
        1. Getting ready
        2. How to do it...
        3. How it works...
      3. Parsing JSON data
        1. Getting ready
        2. How to do it...
        3. How it works...
      4. Social sharing
        1. Getting ready
        2. How to do it...
        3. How it works...
    19. 12. Persisting Data with Core Data
      1. Introduction
      2. Designing data models
        1. How to do it...
        2. How it works...
      3. Reading and inserting records to Core Data
        1. How to do it...
        2. How it works...
      4. Updating and deleting records from Core Data
        1. How to do it...
        2. How it works...
    20. 13. Notifications
      1. Introduction
      2. Setting up Push Notifications
        1. Getting ready
        2. How to do it...
        3. How it works...
      3. Setting up a local server to send Push Notifications
        1. Getting ready
        2. How to do it...
        3. How it works...
      4. Working with interactive Push Notifications
        1. How to do it...
        2. How it works...
      5. Working with local notifications
        1. How to do it...
        2. How it works...
    21. 14. App Search
      1. Introduction
      2. App indexing using NSUserActivity
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      3. App indexing using Core Spotlight APIs
        1. How to do it...
        2. How it works...
    22. 15. Optimizing Performance
      1. Introduction
      2. Memory management with ARC
        1. Getting ready
          1. Retain cycles
          2. Working with closures
        2. How to do it...
        3. How it works...
      3. Measuring performance
        1. How to do it...
        2. How it works...
      4. Measuring energy impact
        1. How to do it...
        2. How it works...
      5. On-demand resources
        1. Getting ready
        2. How to do it...
        3. How it works...