You are previewing More iPhone Development with Swift: Exploring the iOS SDK.
O'Reilly logo
More iPhone Development with Swift: Exploring the iOS SDK

Book Description

Interested in iPhone and iPad apps development? Want to learn more? Whether you are a relative newcomer to iPhone and iPad or iOS development or an old hand looking to expand your horizons, we have the perfect Swift-flavored book for you.

The update to the bestselling More iPhone Development by Dave Mark and Jeff LaMarche, More iPhone Development with Swift digs deeper into the new Apple Swift programming language and iOS 8 SDK, explaining complex concepts and techniques in the same friendly, easy-to-follow style you’ve come to expect.

More iPhone Development with Swift covers topics like Swift, Core Data, peer-to-peer networking using Multipeer Connectivity, working with data from the web, MapKit, in-application e-mail, Camera Live-Previews integration, Barcode scanning, Face recognition and more. All the concepts and APIs are clearly presented with code snippets you can customize and use, as you like, in your own apps. You’ll journey through coverage of concurrent programming and some advanced techniques for debugging your applications.

Table of Contents

  1. Cover
  2. Title
  3. Copyright
  4. Dedication
  5. Contents at a Glance
  6. Contents
  7. About the Authors
  8. About the Technical Reviewer
  9. Acknowledgments
  10. Chapter 1: Here We Go Round Again
    1. What This Book Is
    2. What You Need To Know
    3. What You Need Before You Can Begin
    4. What’s In This Book
  11. Chapter 2: Core Data: What, Why, and How
    1. A Brief History of Core Data
    2. Creating a Core Data Application
    3. Core Data Concepts and Terminology
    4. The Data Model
      1. Entities
      2. Fetch Requests
      3. Configurations
      4. The Data Model Class: NSManagedObjectModel
      5. The Persistent Store and Persistent Store Coordinator
      6. Reviewing the Data Model
    5. Managed Objects
    6. Key-Value Coding
    7. Managed Object Context
      1. Saves On Terminate
      2. Load Data from the Persistent Store
      3. The Fetched Results Controller
      4. Creating and Inserting a New Managed Object
      5. Deleting Managed Objects
    8. Putting Everything in Context
  12. Chapter 3: A Super Start: Adding, Displaying, and Deleting Data
    1. Setting Up the Xcode Project
      1. Adding a Scene
      2. Scenes and Segues
      3. Storyboard Document Outline
    2. Application Architecture
    3. Designing the View Controller Interface
    4. Creating HeroListController
      1. Making the Connections and Outlets
      2. Navigation Bar Buttons
      3. Tab Bar and User Defaults
    5. Designing the Data Model
      1. Adding an Entity
      2. Editing the New Entity
      3. Adding Attributes to the Hero Entity
    6. Declaring the Fetched Results Controller
    7. Implementing the Fetched Results Controller
    8. Fetched Results Controller Delegate Methods
    9. Making It All Work
      1. Error Handling
      2. Implementing Edit and Add
      3. Coding the Table View Data Source and Delegate
      4. Sorting the Table View
      5. Loading the Fetch Request at Launch
    10. Let ’Er Rip
    11. Done, but Not Done
  13. Chapter 4: The Devil in the Detail View
    1. View Implementation Choices
    2. Creating the Detail View Controller
      1. Wiring Up the Segue
      2. HeroDetailController
    3. Detail View Challenges
    4. Controlling the Table Structure with Property Lists
    5. Property Lists Explained
      1. Modeling Table Structure with a Property List
    6. Defining the Table View via Property List
    7. Parsing the Property List
      1. Pushing the Details
    8. Showing the Details
    9. Editing the Details
    10. Editing Mode in the Detail View
    11. Creating a Custom UITableViewCell Subclass
    12. Saving Your Changes
    13. Specialized Input Views
      1. DatePicker SuperDBEditCell Subclass
      2. Using the DatePicker SuperDBEditCell Subclass
      3. Implementing a Selection Picker
    14. Devil’s End
  14. Chapter 5: Preparing for Change: Migrations and Versioning
    1. About Data Models
      1. Data Models Are Compiled
      2. Data Models Can Have Multiple Versions
      3. Creating a New Data Model Version
      4. The Current Data Model Version
      5. Data Model Version Identifiers
    2. Migrations
      1. Lightweight vs. Standard
      2. Standard Migrations
    3. Setting Up Your App to Use Lightweight Migrations
    4. Time to Migrate On
  15. Chapter 6: Custom Managed Objects
    1. Updating the Data Model
      1. Adding the Age Attribute
      2. Adding the Favorite Color Attribute
      3. Adding a Minimum Length to the Name Attribute
    2. Creating the Hero Class
      1. Tweaking the Hero Header
      2. Defaulting
    3. Validation
      1. Single-Attribute Validations
      2. Multiple-Attribute Validations
    4. Adding Validation Feedback
    5. Updating the Detail View
    6. Creating SuperDBNonEditableCell
      1. Creating a Subclass
      2. Moving Code Around
      3. Editable Property
    7. Creating a Color Table View Cell
      1. Custom Color Editor
      2. Custom Color Table View Cell
    8. Cleaning Up the Picker
    9. One More Thing
    10. Color Us Gone
  16. Chapter 7: Relationships, Fetched Properties, and Expressions
    1. Expanding Your Application: Superpowers and Reports
    2. Relationships
      1. To-One Relationships
      2. To-Many Relationships
      3. Inverse Relationships
      4. Fetched Properties
      5. Creating Relationships and Fetched Properties in the Data Model Editor
      6. Delete Rules
    3. Expressions and Aggregates
    4. Adding the Power Entity
    5. Creating the Powers Relationship
    6. Creating the Inverse Relationship
    7. Creating the olderHeroes Fetched Property
      1. What Is a Predicate?
    8. Creating the youngerHeroes Fetched Property
    9. Creating the sameSexHeroes Fetched Property
    10. Creating the oppositeSexHeroes Fetched Property
    11. Adding Relationships and Fetched Properties to the Hero Class
    12. Updating the Detail View
      1. Rethinking Configuration
      2. Encapsulation and Information Hiding
      3. Data-Driven Configuration
      4. Adding Powers
    13. Refactoring the Detail View Controller
      1. Renaming the Configuration Class
      2. Refactoring the Detail Controller
      3. Refactoring the Hero Instance Variable
      4. A Little More Abstraction
      5. A New HeroDetailController
    14. The Power View Controller
      1. Navigating to the PowerViewController
    15. Fetch Properties
    16. The Finer Details
    17. Wonderful to the Core
  17. Chapter 8: Behind Every iCloud
    1. Data Storage with iCloud
    2. iCloud Basics
    3. iCloud Backup
    4. Enabling iCloud in Your Application
    5. Key-Value Data Storage
    6. Document Storage
      1. UIDocument
      2. UIDocument with iCloud
      3. NSMetadataQuery
    7. Core Data with iCloud
    8. Enhancing SuperDB
      1. Entitlements
      2. Enabling iCloud and Creating the Relevant Files
      3. Updating the Persistent Store
      4. Updating the Managed Object Context
      5. Updating the UI on DataChanged
      6. Testing the Data Store
      7. Keep Your Feet on the Ground
  18. Chapter 9: Peer-to-Peer Using Multipeer Connectivity
    1. Peer-to-Peer Connectivity
    2. This Chapter’s Application
    3. Network Communication Models
      1. Client-Server Model
      2. Peer-to-Peer Model
      3. Hybrid Client-Server/Peer-to-Peer
    4. The Multipeer Connectivity Peer
    5. The Multipeer Connectivity Session
      1. Creating the Session
      2. Finding and Connecting to Other Sessions
      3. Listening for Other Sessions
      4. Connecting Peers
      5. Sending Data to a Peer
      6. Packaging Up Information to Send
      7. Receiving Data from a Peer
      8. Closing Connections
      9. Handling a Peer Connection
    6. Creating the Project
      1. Turning Off the Idle Timer
      2. Designing the Interface
      3. Defining Application Constants
      4. Designing the Game Board
      5. Creating the Packet Object
      6. Setting Up the View Controller
      7. Implementing the Tic-Tac-Toe View Controller
    7. Trying It
    8. Game On!
  19. Chapter 10: Map Kit
    1. This Chapter’s Application
    2. Overview and Terminology
    3. The Map View
      1. Map Types
      2. Location Authorization
      3. User Location
      4. Coordinate Regions
      5. Setting the Region to Display
      6. The Map View Delegate
    4. Annotations
      1. The Annotation Object
      2. The Annotation View
      3. Adding and Removing Annotations
      4. Selecting Annotations
      5. Providing the Map View with Annotation Views
    5. Geocoding and Reverse Geocoding
    6. Building the MapMe Application
      1. Building the Interface
      2. Finishing the View Controller Interface
      3. Writing the Annotation Object Class
      4. Implementing the MapMe ViewController
    7. Go East, Young Programmer
  20. Chapter 11: Messaging: Mail, Social, and iMessage
    1. This Chapter’s Application
    2. The MessageUI Framework
      1. Creating the Mail Compose View Controller
      2. Populating the Subject Line
      3. Populating Recpiients
      4. Setting the Message Body
      5. Adding Attachments
      6. Presenting the Mail Compose View
      7. The Mail Compose View Controller Delegate Method
      8. Message Compose View Controller
      9. Message Attachments
      10. Disabling Message Attachments
    3. The Social Framework
      1. SLComposeViewController
      2. SLRequest
    4. The Activity View Controller
    5. Building the MessageImage Application
      1. Building the User Interface
      2. Taking the Picture
      3. Calling the Camera
      4. Picking the Message Sender
    6. Mailing It In...
  21. Chapter 12: Media Library Access and Playback
    1. The MediaPlayer Framework
      1. Media Items
      2. Media Item Collections
      3. Media Queries and Media Property Predicates
      4. The Media Picker Controller
      5. The Music Player Controller
    2. Simple Music Player
      1. Building the SimplePlayer Application
      2. Building the User Interface
      3. Declaring Outlets and Actions
    3. MPMoviePlayerController
    4. MPMediaPlayer
    5. AVFoundation
    6. TL;DR: AVKit
    7. Playing Video
    8. AVMediaPlayer
    9. AVMediaPlayer v2
    10. Photo Library
    11. Modifying the Photo Library
    12. Are You Talking to Me?
    13. Avast! Rough Waters Ahead!
  22. Chapter 13: Lights, Camera, and Action
    1. Lights
    2. Camera
    3. Changing Settings
      1. Putting It All Together
    4. Choosing a Camera
    5. Choosing an Output
    6. Scanning Barcodes
    7. Generating Barcodes
    8. Make Some Noise
    9. Recording Audio
    10. The Show Must Go On
  23. Chapter 14: Interface Builder and Storyboards
    1. Storyboard View Controllers
      1. Container View Controller
    2. Segues
    3. Controls
      1. Inspectable
      2. Designable
      3. A More Useful BasicControl
    4. View Controllers
      1. Transitions
    5. Cue ’em Up
  24. Chapter 15: Unit Testing, Debugging, and Instruments
    1. Unit Tests
    2. Debugging
      1. Breakpoints
      2. The Debug Navigator
      3. The Debug Area
      4. Trying the Debug Controls
      5. The Breakpoint Navigator and Symbolic Breakpoints
      6. Conditional Breakpoints
      7. Breakpoint Actions
      8. One More Thing About Debugging
    3. Profiling with Instruments
    4. End of the Road
  25. Chapter 16: The Road Goes Ever On…
    1. Getting Unstuck
    2. Apple’s Documentation
    3. Mailing Lists
    4. Discussion Forums
    5. Web Sites
    6. Blogs
    7. Books (Apress)
    8. Farewell
  26. Index