Swift for Absolute Beginners

Book description

The professional development team that brought you two editions of Objective-C for the Absolute Beginners and have taught thousands of developers around the world to write some of the most popular iPhone apps in their categories on the app store, have now leveraged their instruction for Swift.

Swift 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.

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 two iOS books, along with their free online instruction and free online forum to create an excellent training book.

Topics include:

  • How to be successful at learning Swift
  • Using Swift Playgrounds to learn iOS development quickly
  • What is Object Oriented Programming
  • What are Swift classes, properties, and functions
  • Proper user interface and user experience design
  • Swift data types: integers, floats, strings, booleans
  • How to use Swift data collections: arrays and dictionaries
  • Boolean logic, comparing data, and flow control
  • Writing iPhone apps from scratch
  • Avoiding Swift pitfalls
  • Many students 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 6
        2. Using Xcode 6
      3. Summary
      4. 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. It 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
        1. Using Array
        2. Dictionary
      3. Creating the BookStore Application
        1. Creating Your Class
        2. Introducing Instance Variables
        3. Accessing Variables
      4. Finishing the Bookstore Program
        1. Creating the View
        2. Adding Instance Variables
        3. Adding a Description
        4. Creating a Simple Data Model Class
        5. Modifying MasterViewController
        6. Modifying the DetailViewController
      5. Summary
      6. 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 Does It Work
      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
        5. Using the Step Controls
        6. Looking at the Thread Window and Call Stack
        7. Debugging Variables
      2. Dealing with Code Errors and Warnings
        1. Errors
        2. Warnings
      3. Summary
    24. Chapter 14: A Swif?t iPhone App
      1. Let’s Get Started
        1. Switches
        2. Alert Views
      2. App Summary
      3. What’s Next?
      4. Exercises
    25. Index

    Product information

    • Title: Swift for Absolute Beginners
    • Author(s):
    • Release date: December 2014
    • Publisher(s): Apress
    • ISBN: 9781484208861