Swift Pocket Reference

Book description

Get quick answers for developing and debugging applications with Swift, Apple’s multi-paradigm programming language. This pocket reference is the perfect on-the-job tool for learning Swift’s modern language features, including type safety, generics, type inference, closures, tuples, automatic memory management, and support for Unicode.

Table of contents

  1. Introduction
  2. Conventions Used in This Book
  3. Using Code Examples
  4. Safari® Books Online
  5. How to Contact Us
  6. Acknowledgments
  7. Getting Started with Swift
    1. The Swift REPL
    2. Swift as a Scripting Language
    3. Swift Playgrounds
  8. A Taste of Swift
  9. Basic Language Features
    1. Comments
    2. Semicolons
    3. Whitespace
    4. Importing Code from Other Modules
  10. Types
    1. Specific Integer Types
    2. Numeric Literals
    3. Character and String Literals
    4. Type Aliases
    5. Nested Types
    6. Other Types
  11. Variables and Constants
    1. Computed Variables
    2. Variable Observers
  12. Tuples
    1. Tuple Variables and Constants
    2. Extracting Tuple Components
    3. Naming Tuple Components
    4. Using Type Aliases with Tuples
    5. Tuples as Return Types
  13. Operators
    1. No Implicit Type Conversion
    2. Arithmetic Operators
    3. Bitwise Operators
    4. Assignment Operators
    5. Comparison Operators
    6. Logical Operators
    7. Overflow Operators
    8. Type Casting Operators
    9. Range Operators
    10. Ternary Conditional Operator
    11. Operator Precedence
  14. Strings and Characters
    1. String Properties
    2. Comparing Strings
    3. Escaped Characters in Strings
    4. String Interpolation
  15. Arrays
    1. Accessing Array Elements
    2. Array Properties
    3. Modifying a Mutable Array
    4. Iterating Over Arrays
    5. Array Algorithms
  16. Dictionaries
    1. Accessing Dictionary Elements
    2. Dictionary Properties
    3. Modifying a Mutable Dictionary
    4. Iterating Over Dictionaries
  17. Functions
    1. Parameter Types
    2. Returning Optional Values
    3. Returning Multiple Values by using Tuples
    4. Local and External Parameter Names
    5. Default Parameter Values
    6. Variadic Parameters
    7. Function Types
  18. Closures
    1. Automatic Argument Names
    2. Trailing Closures
    3. Capturing Values
    4. Capturing Values by Reference
  19. Optionals
    1. Unwrapping Optionals
    2. Implicitly Unwrapped Optionals
    3. Optional Binding
    4. Optional Chaining
  20. Program Flow
    1. Loops
    2. Conditional Execution
  21. Classes
    1. Defining a Base Class
    2. Instances
    3. Properties
    4. Methods
    5. Subscripts
    6. Member Protection
    7. Inheritance: Deriving One Class from Another
    8. Overriding Superclass Entities
    9. Preventing Overrides and Subclassing
    10. Initialization
    11. Initialization and Inheritance
    12. Deinitialization
  22. Structures
    1. Properties in Structures
    2. Methods in Structures
    3. Mutating Methods
    4. Type Methods for Structures
    5. Initializers in Structures
  23. Enumerations
    1. Raw Member Values
    2. Associated Values
    3. Methods in Enumerations
    4. Type Methods for Enumerations
  24. Access Control
    1. Specifying Access Control Levels
    2. Default Access Control Levels
  25. Extensions
    1. Computed Property Extensions
    2. Initializer Extensions
    3. Method Extensions
    4. Subscript Extensions
  26. Checking and Casting Types
    1. Any and AnyObject
    2. Checking Types
    3. Downcasting Types
  27. Protocols
    1. Required Properties
    2. Required Methods
    3. Optional Methods and Properties
    4. Adopting Protocols with Extensions
    5. Inheritance and Protocols
    6. Using a Protocol as a Type
    7. Checking Protocol Conformance
    8. Built-In Protocols
  28. Memory Management
    1. How Reference Counting Works
    2. Retain Cycles and Strong References
    3. Weak References
    4. Unowned References
    5. Retain Cycles and Closures
  29. Generics
    1. Generic Functions
    2. Generic Types
    3. Constraining Types
    4. Generic Protocols
  30. Operator Overloading
    1. Overloading Unary Operators
    2. Custom Operators
    3. Custom Operator Precedence
  31. Ranges, Intervals, and Strides
    1. Ranges
    2. Intervals
    3. Strides
  32. Global Functions
  33. Index

Product information

  • Title: Swift Pocket Reference
  • Author(s):
  • Release date: December 2014
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781491915424