You are previewing Swift™ for Programmers.
O'Reilly logo
Swift™ for Programmers

Book Description

The professional programmer’s Deitel® guide to Apple’s new Swift programming language for the iOS® and OS X® platforms

¿

Written for programmers with a background in object-oriented programming in a C-based language like Objective-C, Java, C# or C++, this book applies the Deitel signature live-code approach with scores of complete, working, real-world programs to explore the new Swift language in depth. The code examples feature syntax shading, code highlighting, rich commenting, line-by-line code walkthroughs and live program outputs. The book features thousands of lines of proven Swift code, and tips that will help you build robust applications.

¿

Start with an introduction to Swift using an early classes and objects approach, then rapidly move on to more advanced topics. When you master the material, you’ll be ready to build industrial-strength object-oriented Swift applications.

About This Book

¿

The Swift programming language was arguably the most significant announcement at Apple’s 2014 Worldwide Developers Conference. Although apps can still be developed in Objective-C®, Apple says that Swift is its applications programming and systems programming language of the future.

¿

Swift is a contemporary language with simpler syntax than Objective-C. Because Swift is new, its designers were able to include popular programming language features from languages such as Objective-C, Java, C#, Ruby, Python® and many others. These features include automatic reference counting (ARC), type inference, optionals, String interpolation, tuples, closures (lambdas), extensions, generics, operator overloading, functions with multiple return values, switch statement enhancements and more. We’ve been able to develop apps more quickly in Swift than with Objective-C and the code is shorter, clearer and runs faster on today’s multi-core architectures.

¿

Swift also eliminates the possibility of many errors common in other languages, making your code more robust and secure. Some of these error-prevention features include no implicit conversions, ARC, no pointers, required braces around every control statement’s body, assignment operators that do not return values, requiring initialization of all variables and constants before they’re used, array bounds checking, automatic checking for overflow of integer calculations, and more. You can combine Swift and Objective-C in the same app to enhance existing Objective-C apps without having to rewrite all the code. Your apps will easily be able to interact with the Cocoa®/Cocoa Touch® frameworks, which are largely written in Objective-C.

¿

You can also use the new Xcode playgrounds with Swift. A playground is an Xcode window in which you can enter Swift code that compiles and executes as you type it. This allows you to see and hear your code’s results as you write it, quickly find and fix errors, and conveniently experiment with features of Swift and the Cocoa/Cocoa Touch frameworks.

¿

Practical, Example-Rich Coverage of:

  • Classes, Objects, Methods, Properties

  • Initializers, Deinitializers, Bridging

  • Tuples, Array and Dictionary Collections

  • Structures, Enumerations, Closures, ARC

  • Inheritance, Polymorphism, Protocols

  • Type Methods, Type Properties

  • Generics; Strings and Characters

  • Operator Overloading, Operator Functions, Custom Operators, Subscripts

  • Access Control; Type Casting and Checking

  • Nested Types, Nested Methods

  • Optionals, Optional Chaining, Extensions

  • Xcode, Playgrounds, Intro to Cocoa Touch® with a Fully Coded iOS® 8 Tip Calculator App

  • Overflow Operators, Attributes, Patterns

  • More topics online

  • ¿

    Be sure to review the companion book: iOS 8 for Programmers, also in the Safari reference library.

    Visit www.deitel.com

  • Download code examples

  • For information on Deitel’s Dive Into® Series programming training courses delivered at organizations worldwide visit www.deitel.com/training or to deitel@deitel.com

  • Join the Deitel social networking communities on Facebook® at facebook.com/DeitelFan, Twitter® at @deitel, Google+ at google.com/+DeitelFan, LinkedIn® at bit.ly/DeitelLinkedIn, YouTube™ at youtube.com/user/DeitelTV and subscribe to the Deitel® Buzz Online e-mail newsletter at www.deitel.com/newsletter/ subscribe.html

  • ¿

    Table of Contents

    1. About This eBook
    2. Title Page
    3. Copyright Page
    4. Deitel® Series Page
      1. Deitel® Developer Series
      2. How To Program Series
      3. Simply Series
      4. CourseSmart Web Books
      5. LiveLessons Video Learning Products
    5. Dedication Page
    6. Contents
    7. Preface
      1. Swift Programming Language
      2. Software Used in Swift for Programmers
      3. Swift Fundamentals: Parts I, II and III LiveLessons Video Training
      4. Explosive Growth of the iPhone and iPad Is Creating Opportunity for Developers
      5. Our Research Sources
      6. Teaching Approach
      7. Acknowledgments
        1. Deitel Team
        2. Pearson Education Team
        3. Reviewers
        4. A Special Thank You to Reviewer Charles Brown
        5. Keeping in Touch with the Authors
      8. About the Authors
      9. About Deitel® & Associates, Inc.
    8. Before You Begin
      1. Conventions
        1. Font and Naming
      2. Conventions for Referencing Menu Items in a Menu
      3. Software Used in this Book
        1. A Note Regarding the Xcode 6 Toolbar Icons
      4. Becoming a Registered Apple Developer
      5. Fee-Based iOS Developer Programs
        1. iOS Developer Program
        2. iOS Developer Enterprise Program
        3. iOS Developer University Program
      6. Adding Your Paid iOS Developer Program Account to Xcode
      7. Obtaining the Code Examples
      8. Xcode Playgrounds and Projects for the Code Examples
        1. Use Playgrounds for Learning
        2. Viewing Output in a Playground
        3. Playground and Project Naming Conventions
      9. Configuring Xcode to Display Line Numbers
    9. 1. Introduction to Swift and Xcode 6
      1. 1.1 Introduction
      2. 1.2 Apple’s OS X® and iOS® Operating Systems: A Brief History
      3. 1.3 Objective-C
      4. 1.4 Swift: Apple’s Programming Language of the Future
        1. 1.4.1 Key Features of Many Popular Languages
        2. 1.4.2 Performance
        3. 1.4.3 Error Prevention
        4. 1.4.4 Swift Standard Library
        5. 1.4.5 Swift Apps and the Cocoa® and Cocoa Touch® Frameworks
        6. 1.4.6 Swift and Objective-C Interoperability
        7. 1.4.7 Other Apple Swift Resources
      5. 1.5 Can I Use Swift Exclusively?
        1. 1.5.1 Objective-C Programmers Who Are Developing New iOS and OS X Apps
        2. 1.5.2 Objective-C Programmers Who Are Enhancing Existing iOS and OS X Apps
        3. 1.5.3 Java, C++ and C# Programmers Who Are New to iOS and OS X App Development
        4. 1.5.4 Significant Language Changes Expected
        5. 1.5.5 A Mixture of Swift and Objective-C
      6. 1.6 Xcode 6 Integrated Development Environment
      7. 1.7 Creating Swift Apps with Xcode 6
      8. 1.8 Web Resources
    10. 2. Introduction to Swift Programming
      1. 2.1 Introduction
      2. 2.2 A First Swift Program: Printing a Line of Text
      3. 2.3 Modifying Your First Program
      4. 2.4 Composing Larger Strings with String Interpolation
      5. 2.5 Another Application: Adding Integers
      6. 2.6 Arithmetic
        1. 2.6.1 Automatic Arithmetic Overflow Checking
        2. 2.6.2 Operator Precedence
      7. 2.7 Decision Making: The if Conditional Statement and the Comparative Operators
      8. 2.8 Wrap-Up
    11. 3. Introduction to Classes, Objects, Methods and Functions
      1. 3.1 Introduction
      2. 3.2 Account Class
        1. 3.2.1 Defining a Class
        2. 3.2.2 Defining a Class Attribute as a Stored Property
        3. 3.2.3 Defining a public Stored Property with a private Setter
        4. 3.2.4 Initializing a Class’s Properties with init
        5. 3.2.5 Defining a Class’s Behaviors as Methods
      3. 3.3 Creating and Using Account Objects
        1. 3.3.1 Importing the Foundation Framework
        2. 3.3.2 Creating and Configuring an NSNumberFormatter to Format Currency Values
        3. 3.3.3 Defining a Function—formatAccountString
        4. 3.3.4 Creating Objects and Calling an Initializer
        5. 3.3.5 Calling Methods on Objects—Depositing into Account Objects
        6. 3.3.6 Calling Methods on Objects—Withdrawing from Account Objects
      4. 3.4 Value Types vs. Reference Types
      5. 3.5 Software Engineering with Access Modifiers
      6. 3.6 Wrap-Up
    12. 4. Control Statements; Assignment, Increment and Logical Operators
      1. 4.1 Introduction
      2. 4.2 Control Statements
      3. 4.3 if Conditional Statement
      4. 4.4 if...else Conditional Statement
      5. 4.5 Compound Assignment Operators
      6. 4.6 Increment and Decrement Operators
      7. 4.7 switch Conditional Statement
        1. 4.7.1 Using a switch Statement to Convert Numeric Grades to Letter Grades
        2. 4.7.2 Specifying Grade Ranges with the Closed-Range Operator (...)
        3. 4.7.3 The default Case
        4. 4.7.4 Other Patterns in the case Label
        5. 4.7.5 No Automatic Fall Through as in Other C-Based Languages
      8. 4.8 while Loop Statement
      9. 4.9 do...while Loop Statement
      10. 4.10 for...in Loop Statement and the Range Operators
        1. 4.10.1 Iterating Over Collections of Values with Closed Ranges, Half-Open Ranges and the Global stride Function
        2. 4.10.2 Compound-Interest Calculations with for...in
        3. 4.10.3 Formatting Strings with Field Widths and Justification
        4. 4.10.4 Performing the Interest Calculations
        5. 4.10.5 A Warning about Displaying Rounded Values
      11. 4.11 for Loop Statement
        1. 4.11.1 General Format of a for Statement
        2. 4.11.2 Scope of a for Statement’s Control Variable
        3. 4.11.3 Expressions in a for Statement’s Header Are Optional
      12. 4.12 break and continue Statements
        1. 4.12.1 break Statement Example
        2. 4.12.2 continue Statement Example
      13. 4.13 Logical Operators
        1. 4.13.1 Logical AND (&&) Operator
        2. 4.13.2 Logical OR (||) Operator
        3. 4.13.3 Short-Circuit Evaluation of Complex Conditions
        4. 4.13.4 Logical NOT (!) Operator
      14. 4.14 Wrap-Up
    13. 5. Functions and Methods: A Deeper Look; enums and Tuples
      1. 5.1 Introduction
      2. 5.2 Modules in Swift
      3. 5.3 Darwin Module—Using Predefined C Functions
      4. 5.4 Multiple-Parameter Function Definition
      5. 5.5 Random-Number Generation
      6. 5.6 Introducing Enumerations and Tuples
        1. 5.6.1 Introducing Enumeration (enum) Types
        2. 5.6.2 Tuples and Multiple Function Return Values
        3. 5.6.3 Tuples as Function Arguments
        4. 5.6.4 Accessing the Raw Value of an enum Constant
      7. 5.7 Scope of Declarations
      8. 5.8 Function and Method Overloading
      9. 5.9 External Parameter Names
      10. 5.10 Default Parameter Values
      11. 5.11 Passing Arguments by Value or by Reference
      12. 5.12 Recursion
      13. 5.13 Nested Functions
      14. 5.14 Wrap-Up
    14. 6. Arrays and an Introduction to Closures
      1. 6.1 Introduction
      2. 6.2 Arrays
      3. 6.3 Creating and Initializing Arrays
      4. 6.4 Iterating through Arrays
      5. 6.5 Adding and Removing Array Elements
      6. 6.6 Subscript Expressions with Ranges
      7. 6.7 Sorting Arrays; Introduction to Closures
        1. 6.7.1 Closures and Closure Expressions
        2. 6.7.2 Array Methods sort and sorted
        3. 6.7.3 Sorting with Function ascendingOrder
        4. 6.7.4 Using a Fully Typed Closure Expression
        5. 6.7.5 Using a Closure Expression with Inferred Types
        6. 6.7.6 Using a Closure Expression with Inferred Types and an Implicit return
        7. 6.7.7 Using a Closure Expression with Shorthand Argument Names
        8. 6.7.8 Using an Operator Function as a Closure Expression
        9. 6.7.9 Reversing an Array’s Elements
      8. 6.8 Array Methods filter, map and reduce
        1. 6.8.1 Filtering an Array
        2. 6.8.2 Mapping an Array’s Elements to New Values
        3. 6.8.3 Reducing an Array’s Elements to a Single Value
        4. 6.8.4 Combining Filtering, Mapping and Reducing
      9. 6.9 Card Shuffling and Dealing Simulation; Computed Properties; Optionals
        1. 6.9.1 Class Card
        2. 6.9.2 Class DeckOfCards
        3. 6.9.3 DeckOfCards Initializer
        4. 6.9.4 DeckOfCards Method shuffle
        5. 6.9.5 DeckOfCards Method dealCard and Optional Return Values
        6. 6.9.6 Shuffling and Dealing Cards
        7. 6.9.7 Unwrapping Optional Values with Optional Binding and the if or while Statements
      10. 6.10 Passing Arrays to Functions
        1. 6.10.1 Passing an Entire Array By Value
        2. 6.10.2 Passing One Array Element By Value
        3. 6.10.3 Passing an Entire Array By Reference
        4. 6.10.4 Passing One Array Element By Reference
      11. 6.11 Notes on Pass-By-Value and Pass-By-Reference
      12. 6.12 Multidimensional Arrays
      13. 6.13 Variadic Parameters
      14. 6.14 Wrap-Up
    15. 7. Dictionary
      1. 7.1 Introduction
        1. 7.1.1 What Is a Dictionary?
        2. 7.1.2 Dictionary Examples
        3. 7.1.3 Dictionary is a Generic Type
        4. 7.1.4 Dictionary Is a Value Type
        5. 7.1.5 Dictionary Is Implemented as a Hash Table
        6. 7.1.6 Dictionary Is Type Safe
      2. 7.2 Declaring a Dictionary: Key–Value Pairs and Dictionary Literals
        1. 7.2.1 Dictionary Key–Value Pairs and Dictionary Literals
        2. 7.2.2 Declaring a Dictionary with Generics and Explicit Typing
        3. 7.2.3 Declaring a Dictionary with Type Inference
        4. 7.2.4 Invoking Dictionary’s description Property Explicitly and Implicitly
      3. 7.3 Declaring and Printing Empty Dictionary Objects
      4. 7.4 Iterating through a Dictionary with for...in
      5. 7.5 General-Purpose Generic Dictionary Printing Function
      6. 7.6 Dictionary Equality Operators == and !=
      7. 7.7 Dictionary count and isEmpty Properties
      8. 7.8 Dictionary Whose Values Are Arrays
      9. 7.9 Dictionary’s keys and values Properties
      10. 7.10 Inserting, Modifying and Removing Key–Value Pairs with Subscripting
        1. 7.10.1 Updating the Value of an Existing Key–Value Pair
        2. 7.10.2 Adding a New Key–Value Pair
        3. 7.10.3 Removing a Key–Value Pair
        4. 7.10.4 Subscripting Returns an Optional Value
        5. 7.10.5 Processing an Optional Value
        6. 7.10.6 Inserting a New Key–Value Pair in an Empty Dictionary
      11. 7.11 Inserting, Removing and Modifying Key–Value Pairs
        1. 7.11.1 Inserting a Key–Value Pair with Dictionary Method updateValue
        2. 7.11.2 Updating a Key–Value Pair with Dictionary Method updateValue
        3. 7.11.3 Removing a Key–Value Pair with Dictionary Method removeValueForKey
        4. 7.11.4 Attempting to Remove a Nonexistent Key–Value Pair with Method removeValueForKey
        5. 7.11.5 Emptying a Dictionary with Method removeAll
      12. 7.12 Building a Dictionary Dynamically: Word Counts in a String
      13. 7.13 Bridging Between Dictionary and Foundation Classes
      14. 7.14 Hash Tables and Hashing
      15. 7.15 Wrap-Up
    16. 8. Classes: A Deeper Look and Extensions
      1. 8.1 Introduction
      2. 8.2 Time Class: Default Initializers and Property Observers
        1. 8.2.1 Stored Property Initialization and the Default Initializer
        2. 8.2.2 willSet and didSet Property Observers for Stored Properties
        3. 8.2.3 Computed Read-Only Properties universalDescription and description
        4. 8.2.4 Using Class Time
      3. 8.3 Designated and Convenience Initializers in Class Time
        1. 8.3.1 Class Time with Overloaded Initializers
        2. 8.3.2 Designated Initializers
        3. 8.3.3 Convenience Initializers and Initializer Delegation with self
        4. 8.3.4 Using Class Time’s Designated and Convenience Initializers
      4. 8.4 Failable Initializers in Class Time
        1. 8.4.1 Failable Designated Initializers
        2. 8.4.2 Failable Convenience Initializers
        3. 8.4.3 Implicitly Unwrapped Failable Initializers
        4. 8.4.4 Invoking Failable Initializers
      5. 8.5 Extensions to Class Time
        1. 8.5.1 Class Time with Extensions
        2. 8.5.2 Testing Class Time’s Extensions
        3. 8.5.3 Extensions and Access Modifiers
      6. 8.6 Read-Write Computed Properties
      7. 8.7 Composition
        1. 8.7.1 Class Employee
        2. 8.7.2 Testing Class Employee
      8. 8.8 Automatic Reference Counting, Strong References and Weak References
      9. 8.9 Deinitializers
      10. 8.10 Using NSDecimalNumber for Precise Monetary Calculations
      11. 8.11 Type Properties and Type Methods
        1. 8.11.1 Type Scope
        2. 8.11.2 Motivating Type Properties
        3. 8.11.3 Creating Type Properties and Type Methods in Classes
        4. 8.11.4 Using Type Properties and Type Methods
      12. 8.12 Lazy Stored Properties and Delayed Initialization
      13. 8.13 Wrap-Up
    17. 9. Structures, Enumerations and Nested Types
      1. 9.1 Introduction
      2. 9.2 Structure Definitions
        1. 9.2.1 Time struct Definition with Default and Memberwise Initializers
        2. 9.2.2 Custom Initializers extension to struct Time
        3. 9.2.3 Computed Properties extension to struct Time
        4. 9.2.4 Mutating Methods extension to struct Time
        5. 9.2.5 Testing the Time struct
      3. 9.3 Enumerations and Nested Types
        1. 9.3.1 Card struct with Nested Suit and Face enum Types
        2. 9.3.2 DeckOfCards struct
        3. 9.3.3 Testing the struct Types Card and DeckOfCards, and the enum Types Suit and Face
      4. 9.4 Choosing Among Structures, Enumerations and Classes in Your Apps
      5. 9.5 Associated Values for enums
      6. 9.6 Wrap-Up
    18. 10. Inheritance, Polymorphism and Protocols
      1. 10.1 Introduction
        1. 10.1.1 Superclasses and Subclasses
        2. 10.1.2 Polymorphism
        3. 10.1.3 Implementing for Extensibility
        4. 10.1.4 Programming in the Specific
        5. 10.1.5 Protocols
      2. 10.2 Superclasses and Subclasses
      3. 10.3 An Inheritance Hierarchy: CommunityMembers
      4. 10.4 Case Study: Using Inheritance to Create Related Employee Types
        1. 10.4.1 Superclass CommissionEmployee
        2. 10.4.2 Subclass BasePlusCommissionEmployee
        3. 10.4.3 Testing the Class Hierarchy
      5. 10.5 Access Modifiers in Inheritance Hierarchies
      6. 10.6 Introduction to Polymorphism: A Polymorphic Video Game Discussion
      7. 10.7 Case Study: Payroll System Class Hierarchy Using Polymorphism
        1. 10.7.1 Base Class Employee
        2. 10.7.2 Subclass SalariedEmployee
        3. 10.7.3 Subclass CommissionEmployee
        4. 10.7.4 Indirect Subclass BasePlusCommissionEmployee
        5. 10.7.5 Polymorphic Processing
      8. 10.8 Case Study: Creating and Using Custom Protocols
        1. 10.8.1 Protocol Capabilities Must Be Defined in Each Conforming Type
        2. 10.8.2 Protocols and Is-a Relationships
        3. 10.8.3 Relating Disparate Types Via Protocols
        4. 10.8.4 Accounts-Payable Application
        5. 10.8.5 Developing a Payable Hierarchy
        6. 10.8.6 Declaring Protocol Payable
        7. 10.8.7 Creating Class Invoice
        8. 10.8.8 Using extensions to Add Printable and Payable Protocol Conformance to Class Employee
        9. 10.8.9 Using Protocol Payable to Process Invoices and Employees Polymorphically
      9. 10.9 Additional Protocol Features
        1. 10.9.1 Protocol Inheritance
        2. 10.9.2 Class-Only Protocols
        3. 10.9.3 Optional Capabilities in Protocols
        4. 10.9.4 Protocol Composition
        5. 10.9.5 Common Protocols in Swift
      10. 10.10 Using final to Prevent Method Overriding and Inheritance
      11. 10.11 Initialization and Deinitialization in Class Hierarchies
        1. 10.11.1 Basic Class-Instance Initialization
        2. 10.11.2 Initialization in Class Hierarchies
        3. 10.11.3 Initialization of a BasePlusCommissionEmployee Object
        4. 10.11.4 Overriding Initializers and Required Initializers
        5. 10.11.5 Deinitialization in Class Hierarchies
      12. 10.12 Wrap-Up
    19. 11. Generics
      1. 11.1 Introduction
      2. 11.2 Motivation for Generic Functions
      3. 11.3 Generic Functions: Implementation and Specialization
      4. 11.4 Type Parameters with Type Constraints
      5. 11.5 Overloading Generic Functions
      6. 11.6 Generic Types
      7. 11.7 Note About Associated Types for Protocols
      8. 11.8 Wrap-Up
    20. 12. Operator Overloading and Subscripts
      1. 12.1 Introduction
      2. 12.2 String Operators and Methods
        1. 12.2.1 String Variables and Constants
        2. 12.2.2 String Comparative Operators
        3. 12.2.3 Custom String Unary Prefix Operator !
        4. 12.2.4 String Concatenation with Operators + and +=
        5. 12.2.5 String Subscript ([]) Operator for Creating Substrings
        6. 12.2.6 Other String Methods
      3. 12.3 Custom Complex Numeric Type with Overloaded Arithmetic Operators
        1. 12.3.1 Overloaded Operator Functions +, - and *
        2. 12.3.2 Overloading the Arithmetic Assignment Operator +=
        3. 12.3.3 Performing Arithmetic with Complex Numbers
      4. 12.4 Overloading Arithmetic Operators for Class NSDecimalNumber
        1. 12.4.1 Overloading the Multiplication Operator (*)
        2. 12.4.2 Overloading the Addition Operator (+)
        3. 12.4.3 Using the Overloaded Operators
        4. 12.4.4 Overloading the *= Multiplication Assignment Operator
      5. 12.5 Overloading Unary Operators: ++ and --
        1. 12.5.1 Overloading Unary Prefix Operators That Modify Their Operands
        2. 12.5.2 Overloading Unary Postfix Operators That Modify Their Operands
        3. 12.5.3 Swift’s AnyObject Type—Bridging Between Objective-C and Swift
      6. 12.6 Overloading Subscripts
        1. 12.6.1 Box Type with Custom Subscripts
        2. 12.6.2 Subscript Syntax
        3. 12.6.3 Type Box’s Int Subscript and the precondition Function
        4. 12.6.4 Type Box’s String Subscript
        5. 12.6.5 Using Type Box’s Subscripts
      7. 12.7 Custom Operators
        1. 12.7.1 Precedence and Associativity
        2. 12.7.2 Symbols Used in Custom Operators
        3. 12.7.3 Defining a Custom Exponentiation Operator for Type Int
      8. 12.8 Custom Generic Operators
      9. 12.9 Wrap-Up
    21. 13. iOS 8 App Development: Welcome App
      1. 13.1 Introduction
      2. 13.2 Technologies Overview
        1. 13.2.1 Xcode and Interface Builder
        2. 13.2.2 Labels and Image Views
        3. 13.2.3 Asset Catalogs and Image Sets
        4. 13.2.4 Running the App
        5. 13.2.5 Accessibility
        6. 13.2.6 Internationalization
      3. 13.3 Creating a Universal App Project with Xcode
        1. 13.3.1 Xcode Projects and App Templates
        2. 13.3.2 Creating and Configuring a Project
      4. 13.4 Xcode Workspace Window
        1. 13.4.1 Navigator Area
        2. 13.4.2 Editor Area
        3. 13.4.3 Utilities Area and Inspectors
        4. 13.4.4 Debug Area
        5. 13.4.5 Xcode Toolbar
        6. 13.4.6 Project Navigator
        7. 13.4.7 Keyboard Shortcuts
      5. 13.5 Storyboarding the Welcome App’s UI
        1. 13.5.1 Configuring the App for Portrait and Landscape Orientations
        2. 13.5.2 Providing an App Icon
        3. 13.5.3 Creating an Image Set for the App’s Image
        4. 13.5.4 Overview of the Storyboard and the Xcode Utilities Area
        5. 13.5.5 Adding an Image View to the UI
        6. 13.5.6 Using Inspectors to Configure the Image View
        7. 13.5.7 Adding and Configuring the Label
        8. 13.5.8 Using Auto Layout to Support Different Screen Sizes and Orientations
      6. 13.6 Running the Welcome App
        1. 13.6.1 Testing on the iOS Simulator
        2. 13.6.2 Testing on a Device (for Paid Apple iOS Developer Program Members Only)
      7. 13.7 Making Your App Accessible
        1. 13.7.1 Enabling Accessibility for the Image View
        2. 13.7.2 Confirming Accessibility Text with the Simulator’s Accessibility Inspector a
      8. 13.8 Internationalizing Your App
        1. 13.8.1 Locking Your UI During Translation
        2. 13.8.2 Exporting Your UI’s String Resources
        3. 13.8.3 Translating the String Resources
        4. 13.8.4 Importing the Translated String Resources
        5. 13.8.5 Testing the App in Spanish
      9. 13.9 Wrap-Up
    22. 14. iOS 8 App Development: Tip Calculator App
      1. 14.1 Introduction
      2. 14.2 Test-Driving the Tip Calculator App in the iPhone and iPad Simulators
      3. 14.3 Technologies Overview
        1. 14.3.1 Swift Programming
        2. 14.3.2 Swift Apps and the Cocoa Touch® Frameworks
        3. 14.3.3 Using the UIKit and Foundation Frameworks in Swift Code
        4. 14.3.4 Creating Labels, a Text Field and a Slider with Interface Builder
        5. 14.3.5 View Controllers
        6. 14.3.6 Linking UI Components to Your Swift Code
        7. 14.3.7 Performing Tasks After a View Loads
        8. 14.3.8 Bridging Between Swift and Objective-C Types
      4. 14.4 Building the App’s UI
        1. 14.4.1 Creating the Project
        2. 14.4.2 Configuring the Size Classes for Designing a Portrait Orientation iPhone App
        3. 14.4.3 Adding the UI Components
        4. 14.4.4 Adding the Auto Layout Constraints
      5. 14.5 Creating Outlets with Interface Builder
      6. 14.6 Creating Actions with Interface Builder
      7. 14.7 Class ViewController
        1. 14.7.1 import Declarations
        2. 14.7.2 ViewController Class Definition
        3. 14.7.3 ViewController’s @IBOutlet Properties
        4. 14.7.4 Other ViewController Properties
        5. 14.7.5 Overridden UIViewController method viewDidLoad
        6. 14.7.6 ViewController Action Method calculateTip
        7. 14.7.7 Global Utility Functions Defined in ViewController.swift
      8. 14.8 Wrap-Up
    23. A. Keywords
    24. B. Operator Precedence Chart
    25. C. Labeled break and continue Statements
      1. C.1 Introduction
      2. C.2 Labeled break Statement
      3. C.3 Labeled continue Statement
    26. Index
    27. Code Snippets