You are previewing Swift 2 for Absolute Beginners.
O'Reilly logo
Swift 2 for Absolute Beginners

Book Description

Swift 2 for Absolute Beginners is perfect for those with no programming background, those with some programming experience but no object-oriented experience, or those that have a great idea for an app but haven’t programmed since school, and it is now updated for Swift 2.

Gary Bennett and Brad Lees are full-time professional iOS developers and have developed a broad spectrum of apps for Fortune 500 companies. The authors have taken their combined 12 years of writing apps, teaching online iOS courses, the experience from their first three iOS books, along with their online instruction and free online forum at XcelMe.com to create an excellent training book.

Many people have a difficult time believing they can learn to write iOS apps or just staying motivated through learning the process. This book, along with the free, live online training sessions, helps students stay motivated and overcome obstacles while they learn to be great iOS developers.

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. Introduction
  11. Chapter 1: Becoming a Great iOS Developer
    1. Thinking Like a Developer
    2. Completing the Development Cycle
    3. Introducing Object-Oriented Programming
    4. Working with the Playground Interface
    5. Summary
    6. What’s Next
    7. Exercises
  12. Chapter 2: Programming Basics
    1. Touring Xcode
      1. Exploring the Workspace Window
      2. Navigating Your Workspace
      3. Editing Your Project Files
    2. Creating Your First Swift Playground Program
      1. Installing and Launching Xcode 7
      2. Using Xcode 7
    3. Xcode Playground IDE: Editor and Results Areas
    4. Summary
    5. Exercise
  13. Chapter 3: It’s All About the Data
    1. Numbering Systems Used in Programming
      1. Bits
      2. Bytes
      3. Hexadecimal
      4. Unicode
    2. Data Types
    3. Declaring Constants and Variables
    4. Optionals
    5. Using Variables in Playgrounds
    6. Summary
    7. Exercises
  14. Chapter 4: Making Decisions, Program Flow, and App Design
    1. Boolean Logic
      1. Truth Tables
      2. Comparison Operators
    2. Designing Apps
      1. Pseudocode
      2. Optionals and Forced Unwrapping
      3. Flowcharting
      4. Designing and Flowcharting an Example App
      5. The App’s Design
      6. Using Loops to Repeat Program Statements
    3. Coding the Example App in Swift
      1. Nested if Statements and else if Statements
      2. Removing Extra Characters
      3. Improving the Code Through Refactoring
      4. Running the App
      5. Design Requirements
    4. Summary
    5. Exercises
  15. Chapter 5: Object-Oriented Programming with Swift
    1. The Object
    2. What Is a Class?
    3. Planning Classes
      1. Planning Properties
      2. Planning Methods
      3. Implementing the Classes
    4. Inheritance
    5. Why Use OOP?
      1. OOP Is Everywhere
      2. Eliminate Redundant Code
      3. Ease of Debugging
      4. Ease of Replacement
    6. Advanced Topics
      1. Interface
      2. Polymorphism
    7. Summary
    8. Exercises
  16. Chapter 6: Learning Swift and Xcode
    1. A Newcomer
    2. Understanding the Language Symbols
    3. Implementing Objects in Swift
    4. Writing Another Program in Xcode
      1. Creating the Project
    5. Summary
    6. Exercises
  17. Chapter 7: Swift Classes, Objects, and Methods
    1. Creating a Swift Class
      1. Instance Variables
      2. Methods
    2. Using Your New Class
      1. Creating Your Project
      2. Adding Objects
      3. Writing the Class
      4. Creating the User Interface
      5. Hooking Up the Code
      6. Running the Program
      7. Taking Class Methods to the Next Level
    3. Accessing the Xcode Documentation
    4. Summary
    5. Exercises
  18. Chapter 8: Programming Basics in Swift
    1. Using let vs. var
    2. Understanding Collections
    3. Using Arrays
    4. Using the Dictionary Class
    5. Creating the BookStore Application
      1. Creating Your Class
      2. Introducing Properties
      3. Accessing Variables
    6. Finishing the BookStore Program
      1. Creating the View
      2. Adding Properties
      3. Adding a Description
      4. Creating a Simple Data Model Class
      5. Modifying MasterViewController
      6. Modifying the DetailViewController
    7. Summary
    8. Exercises
  19. Chapter 9: Comparing Data
    1. Revisiting Boolean Logic
    2. Using Relational Operators
      1. Comparing Numbers
      2. Creating an Example Xcode App
    3. Using Boolean Expressions
      1. Comparing Strings
    4. Using the switch Statement
      1. Comparing Dates
      2. Combining Comparisons
    5. Summary
    6. Exercises
  20. Chapter 10: Creating User Interfaces
    1. Understanding Interface Builder
    2. The Model-View-Controller Pattern
    3. Human Interface Guidelines
    4. Creating an Example iPhone App with Interface Builder
      1. Using Interface Builder
      2. The Document Outline
      3. The Library
      4. Inspector Pane and Selector Bar
      5. Creating the View
      6. Using Outlets
      7. Using Actions
      8. The Class
    5. Summary
    6. Exercises
  21. Chapter 11: Storing Information
    1. Storage Considerations
    2. Preferences
      1. Writing Preferences
      2. Reading Preferences
    3. Databases
    4. Storing Information in a Database
    5. Getting Started with Core Data
    6. The Model
      1. Managed Object Context
      2. Setting Up the Interface
    7. Summary
    8. Exercises
  22. Chapter 12: Protocols and Delegates
    1. Multiple Inheritance
    2. Understanding Protocols
    3. Protocol Syntax
    4. Delegation
    5. Protocol and Delegation Example
    6. Getting Started
    7. How It Works
    8. Summary
    9. Exercise
  23. Chapter 13: Introducing the Xcode Debugger
    1. Getting Started with Debugging
      1. Setting Breakpoints
      2. Using the Breakpoint Navigator
      3. Debugging Basics
      4. Working with the Debugger Controls
    2. Using the Step Controls
      1. Looking at the Thread Window and Call Stack
      2. Debugging Variables
    3. Dealing with Code Errors and Warnings
      1. Errors
      2. Warnings
    4. Summary
  24. Chapter 14: A Swift iPhone App
    1. Let’s Get Started
    2. App Summary
    3. Exercises
  25. Chapter 15: Apple Watch and watchKit
    1. Considerations When Creating a watchOS App
    2. Creating an Apple Watch App
    3. Adding More Functionality
    4. Summary
    5. Exercises
  26. Chapter 16: A Swift HealthKit iPhone App
    1. Introduction to Core Bluetooth
      1. Central and Peripheral Devices
      2. Peripheral Advertising
      3. Peripheral Data Structure
    2. Let’s Get Started and Build the App
    3. App Summary
    4. What’s Next?
    5. Exercises
  27. Index