0%

Book Description

Unlock the full potential of iOS 10 programming with Swift 3.0 to build rich and powerful applications

About This Book

  • This practical guide will help you make the transition to professional iOS developer
  • Implement numerous powerful iOS 10 and Swift 3 techniques to build high-quality apps through this book
  • Get the most in-depth, advanced-level guide on the latest version of iOS and take a hands-on approach

Who This Book Is For

This book is for developers who have some experience with iOS and want to take their skills to next level by unlocking the full potential of latest version of iOS with Swift to build impressive applications.

What You Will Learn

  • Write beautiful Swift code with Protocol-Oriented Programming and best practices
  • Create rich views and layouts with responsive animations and transitions.
  • Handle data, both from the web and offline
  • Integrate with iOS and improve the user experience with app extensions
  • Make sure that your app is of outstanding quality with XCTest
  • Measure and improve performance by using Xcode Instruments
  • Embrace the latest extension features in iOS 10 such as the new rich notifications, SiriKit, and iMessage

In Detail

With usage of apps growing rapidly, mobile application development has become the most sought-after skill set. Within the mobile market, iOS commands a massive presence and is a highly lucrative platform. The goal of our book is to help you become a professional developer by unleashing the full potential of iOS 10 to build applications.

Written with the latest Swift version and following the latest Swift API design guidelines, you won’t just learn how to program for iOS 10—you’ll also learn how to write beautiful, readable, and maintainable Swift code that’s in line with the industry’s best-practices. The progression of the book reflects the real-world development flow: it will quickly brush on the essentials at the beginning and then move on to the advanced concepts crucial to building powerful applications.

Within the book, you will build a couple of small applications that resemble applications you might want to build in the real world. You will be reading a mix of thorough background information and practical examples, so you’ll know how to make use of a certain technique right away while you also get a great understanding of the how and why.

Style and approach

This book takes a no-frill approach and is very code-specific. The focus is on teaching advanced concepts through a series of small projects and standalone examples that help you gain expertise with various aspects of iOS application development.

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. Mastering iOS 10 Programming
    1. Mastering iOS 10 Programming
    2. Credits
    3. About the Author
    4. About the Reviewer
    5. www.PacktPub.com
      1. Why subscribe?
    6. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Downloading the color images of this book
        3. Errata
        4. Piracy
        5. Questions
    7. 1. UITableView Touch Up
      1. Setting up the User Interface (UI)
      2. Fetching a user's contacts
      3. Creating a custom UITableViewCell for our contacts
        1. Designing the contact cell
        2. Creating the cell subclass
      4. Displaying the list of contacts
        1. Protocols and delegation
        2. Conforming to the UITableViewDataSource and UITableViewDelegate protocol
      5. Under the hood of UITableView performance
        1. Improving performance with prefetching in iOS 10
      6. UITableViewDelegate and interactions
        1. Responding to cell selection
        2. Implementing cell deletion
        3. Allowing the user to reorder cells
      7. Summary
    8. 2. A Better Layout with UICollectionView
      1. Converting from a UITableView to UICollectionView
      2. Creating and implementing a custom UICollectionViewCell
      3. Understanding the UICollectionViewFlowLayout and its delegate
      4. Creating a custom UICollectionViewLayout
        1. Pre-calculating the layout
        2. Implementing collectionViewContentSize
        3. Implementing layoutAttributesForElements(_:)
        4. Implementing layoutAttributesForItem(_:)
        5. Implementing shouldInvalidateLayout(_:)
        6. Assigning the custom layout to the collection view
        7. Final words on the custom layout
      5. UICollectionView performance
      6. User interactions with UICollectionView
        1. Cell selection
        2. Cell deletion
        3. Cell reordering
        4. Refactoring the long press handler
        5. Implementing the reorder method calls
        6. Implementing the data source methods
        7. Adding the edit button
      7. Summary
    9. 3. Creating a Contact Detail Page
      1. Universal applications
      2. Implementing navigation with segues
      3. Creating adaptive layouts with Auto Layout
        1. Auto Layout with the Interface Builder
          1. Adding a scroll view to make the layout scrollable
          2. Laying out the image and name label
          3. Adjusting the image and name label for large screens
          4. Laying out the bottom section
          5. Adjust the bottom section for small screens
        2. Auto Layout in code
          1. Implementing the compact size layout
          2. Implementing the regular size layout
      4. Easier layouts with UIStackView
        1. Containing labels in a UIStackView
        2. Varying columns and layouts for traits in UIStackView
      5. Passing data between view controllers
        1. Updating the data loading and model
        2. Passing the model to the detail page
        3. Implementing new outlets and display data
      6. Summary
    10. 4. Immersing Your Users With Animation
      1. UIView animation basics
        1. Using the UIView.animate method for animation
        2. Exploring UIView's animation options
      2. Adding vibrancy to animations with springs
      3. Taking control of animations with UIViewPropertyAnimator
      4. Customizing view controller transitions
        1. Implementing a custom modal presentation transition
        2. Making an interactive dismissal transition
        3. Implementing a custom UINavigationController transition
      5. Summary
    11. 5. Improving Your Code with Value Types
      1. Understanding reference types
      2. Understanding value types
        1. Differences between values and references in usage
        2. Memory differences between values and references
          1. Heap allocation
          2. Stack allocation
      3. Using structs to improve your code
        1. Starting your models as structs
        2. Using a struct if you don't need inheritance
        3. Enforcing immutability with structs
        4. Final words on structs
      4. Containing information in enums
      5. Summary
    12. 6. Avoiding Complex Inheritance with Protocols
      1. Defining your own protocols
      2. Checking for traits instead of types
        1. Extending your protocols with default behavior
        2. Improving your protocols with associated types
      3. Summary
    13. 7. Refactoring the HelloContacts Application
      1. Properly separating concerns
        1. Extracting the contact fetching code
        2. Extracting the bounce animation
      2. Adding protocols for clarity
        1. Defining the view effect animator protocol
        2. Defining a contact display protocol
      3. Summary
    14. 8. Adding Core Data to your App
      1. Understanding the Core Data stack
      2. Adding Core Data to an application
        1. Modeling data in the model editor
        2. Creating the basic models
        3. Defining relationships
        4. Creating NSManagedObject subclasses
      3. Summary
    15. 9. Storing and Querying Data in Core Data
      1. Inserting data with Core Data
        1. Understanding data persistence
        2. Persisting your models
        3. Refactoring the persistence code
      2. Reading data with a simple fetch request
      3. Filtering data with predicates
      4. Reacting to database changes
        1. Implementing an NSFetchedResultsController
      5. Summary
    16. 10. Fetching and Displaying Data from the Network
      1. Fetching data from the Web
        1. Understanding the URLSession basics
      2. Working with JSON in Swift
      3. Updating Core Data objects with fetched data
        1. Implementing the fetch logic
        2. Updating a movie with a popularity rating
        3. Visualizing multiple threads
      4. Wrapping the feature up
        1. Adding the rating to the movie cell
        2. Understanding App Transport Security
        3. Observing changes to movie ratings
      5. Summary
    17. 11. Being Proactive with Background Fetch
      1. Understanding how background fetch works
        1. Looking at background fetch from a distance
        2. Looking at background fetch in more depth
      2. Implementing the prerequisites for background fetch
        1. Adding the background fetch capabilities
        2. Asking iOS to wake our app up
      3. Updating movies in the background
        1. Updating the data model
        2. Refactoring the existing code
      4. Updating movies in the background
        1. Preparing the helper struct
        2. Updating the movies
      5. Summary
    18. 12. Enriching Apps with the Camera, Motion and Location
      1. Accessing and using the camera, the simple way
        1. Exploring the AVFoundation framework
          1. Playing audio with AVFoundation
          2. Playing video with AVFoundation
        2. Rendering the camera feed
          1. Understanding the building blocks of a video feed
          2. Implementing the video feed
      2. Implementing CoreMotion
        1. Tracking walks with the pedometer
        2. Reading sensor data with CoreMotion
        3. Creating the login interface
      3. Using CoreLocation to locate your users
        1. Obtaining a user's location
        2. Providing location based updates with geofencing
        3. Tracking the user's location while they're on the move
      4. Finishing the ArtApp login screen
      5. Summary
    19. 13. Displaying Contents of your App in Spotlight
      1. Understanding Spotlight search
      2. Adding your app contents to the Spotlight index
        1. Indexing your app through user activity
      3. Indexing with CSSearchableItem
        1. Containing information in CSSearchableItemAttributeSet
        2. Adding CSSearchableItem instances to the search index
        3. Safely combining indexing methods
        4. Handling searchable item selection
      4. Understanding Spotlight best practices and rating
        1. Adding metadata to your web links
        2. Registering as an indexing delegate
      5. Summary
    20. 14. Making the Web and your App Meet through Universal Links
      1. Understanding Universal Links
      2. Preparing your server for Universal Links
      3. Implementing Smart App Banners
      4. Handling Universal Links in your app
      5. Helping your users to log in seamlessly
      6. Summary
    21. 15. Instant Information with a Notification Center Widget
      1. Understanding the anatomy of a Today Extension
        1. Understanding app extensions
        2. Understanding Today Extensions
      2. Adding a Today Extension to your app
        1. Discovering your widget in iOS 10
      3. Sharing data with App Groups
      4. Summary
    22. 16. Implementing Rich Notifications
      1. Gaining a deep understanding of notifications
      2. Scheduling and handling notifications
        1. Registering for notifications
        2. Creating notification content
          1. Creating push notifications
          2. Creating local notifications
        3. Scheduling your notification
          1. Scheduling a timed notification
          2. Scheduling a calendar-based notification
          3. Scheduling a location-based notification
        4. Handling notifications
          1. Handling notifications in your app
          2. Managing pending and delivered notifications
          3. Adding actions to notifications
      3. Implementing Notification Extensions
        1. Adding a Service Extension to your app
        2. Adding a content extension to your app
      4. Summary
    23. 17. Extending iMessage
      1. Understanding iMessage apps
      2. Creating an iMessage sticker pack
        1. Optimizing assets for your stickers
        2. Creating a custom sticker app
      3. Implementing custom, interactive iMessage apps
        1. Understanding the iMessage app lifecycle
        2. Implementing the custom compact view
        3. Implementing the expanded view
      4. Understanding sessions, messages, and conversations
        1. Composing a message
        2. Sending a message
      5. Summary
    24. 18. Integrating Your App with Siri
      1. Understanding intents and vocabularies
        1. Adding intents to your extension
        2. Adding vocabularies to your app
          1. Adding vocabularies through a .plist file
          2. Teaching Siri vocabularies at runtime
      2. Handling intents in your extension
        1. Resolving the user's input
        2. Confirming the intent status
        3. Performing the desired action
      3. Adding a custom UI to Siri
      4. Summary
    25. 19. Ensuring App Quality with Tests
      1. Testing logic with XCTest
        1. Understanding what it means to test code
          1. Determining what to test
          2. Choosing the correct test type
            1. Unit tests
            2. Integration tests
          3. Isolating tests
            1. Arrange
            2. Act
            3. Assert
        2. Setting up a test suite with XCTest
        3. Optimizing code for testability
          1. Introducing the question loader
          2. Mocking API responses
          3. Using models for consistency
        4. Gaining insights through Code Coverage
      2. Testing the user interface with XCUITest
        1. Making your app accessible to your tests
        2. Recording UI tests
        3. Passing launch arguments to your app
        4. Making sure the UI updates as expected
      3. Summary
    26. 20. Discovering Bottlenecks with Instruments
      1. Exploring the Instruments suite
      2. Discovering slow code
      3. Closing memory leaks
        1. Understanding what a memory leak is
          1. Preventing objects from using infinite memory
          2. Avoiding reference cycles
        2. Discovering memory leaks
      4. Summary
    27. 21. Offloading Tasks with Operations and GCD
      1. Writing asynchronous code
        1. Understanding threads
        2. Using dispatch queues in your application
      2. Creating reusable tasks with Operations
        1. Using Operations in your apps
      3. Summary
    28. 22. Wrapping Up the Development Cycle and Submitting to the App Store
      1. Adding your application to iTunes Connect
      2. Packaging and uploading your app for beta testing
      3. Preparing your app for launch
      4. Summary
18.217.220.114