Swift Translation Guide for Objective-C Users: Develop and Design

Book description

APPLE DESIGNED SWIFT SO YOU wouldn’t need previous Apple programming experience, but many Apple developers will want to take advantage of Swift in existing projects—as well as start writing projects from scratch. In this compact, to-the-point guide, author and iOS developer Maurice Kelly steps existing Objective-C developers through the basics of the Swift language—including types, syntax, variables, strings, and classes—and explores how to use Swift with existing projects and create new apps written completely in Swift.

If you are an Apple developer, this book will quickly give you a solid foundation for writing Swift apps.

THIS BOOK INCLUDES:

  • Detailed instruction and clear examples

  • Real-world guidance and advice

  • Detailed directions for using Swift’s playgrounds to experiment with your code with a minimum of hassle

  • Emphasis on the core components of the language

  • COMPANION WEBSITE:

    http://swift-translation.guide/ includes additional resources.

    Table of contents

    1. Title Page
    2. Copyright Page
    3. Dedication Page
    4. Acknowledgments
    5. About the Author
    6. Contents
    7. Introduction
      1. A History
      2. How to Use This Book
        1. How You Will Learn
        2. What You Will Learn
    8. Welcome to Swift
      1. Swift’s Goals
      2. New Tools
    9. Chapter 1. Creating Swift Projects
      1. Your First Swift Project
      2. Fundamental Differences
        1. No More Header Files
        2. Main Is Missing
        3. Semicolons?
      3. Using Swift and Objective-C Together
      4. Wrapping Up
    10. Chapter 2. Playgrounds and the Swift REPL
      1. Swift Playgrounds
        1. A Quick Tour of Swift Playgrounds
        2. What Can You Do with Playgrounds?
        3. Creating Your Own Playgrounds
      2. The Swift REPL
        1. How to Use the REPL
        2. Possibilities
        3. Limitations
      3. Wrapping Up
    11. Chapter 3. Language Basics
      1. Types
        1. Primitive Types
        2. Strings
        3. Functions
        4. Blocks
        5. Tuples
        6. Classes, Structs, and Enumerations
        7. Collections
      2. Variable Declarations
        1. var and let
        2. Mutability
        3. Type Inference
      3. Syntax
        1. Semicolons
        2. Where Is @?
        3. No Longer Hip to Be Square
        4. Control Blocks
        5. The Post-Preprocessor Age
        6. Comments
      4. Operators
        1. Identical
        2. Different
        3. New
      5. Tuples
        1. Creating and Using Tuples
        2. Reusing Tuples
      6. Wrapping Up
    12. Chapter 4. Control Structures
      1. General Changes
        1. Parentheses Are Optional
        2. Braces Are Mandatory
        3. Boolean Conditions
      2. Loops
        1. for and for-in
        2. while and do-while
      3. Conditionals
        1. if
        2. switch
      4. To Integers and Beyond!
        1. Strings
        2. Enumerations
        3. Ranges
        4. Pattern Matching
        5. Safety Features
      5. Wrapping Up
    13. Chapter 5. Optionals
      1. Why Do We Need Optionals?
      2. Declaring an Optional
      3. Using an Optional
        1. Unwrapping
        2. Optional Binding
        3. Implicit Unwrapping
        4. Optional Chaining
      4. Things to Watch Out For
        1. nil Coalescing Operator
        2. No Need to Unwrap
      5. Wrapping Up
    14. Chapter 6. Functions
      1. Calling Functions
      2. Defining Functions
        1. Parameter Naming
        2. Default Parameter Values
        3. Return Values
        4. Modifying Function Parameters
        5. Variadic Parameters
      3. Function Scopes
        1. Global Scope
        2. Scope of Methods
        3. Nested Functions
      4. Using Functions
        1. Function Types
        2. Using Functions as Parameter Values
        3. Using Functions as Return Values
      5. Wrapping Up
    15. Chapter 7. Blocks and Closures
      1. Defining Closures
        1. Creating the Definition
        2. Assigning to Variables
        3. Receiving as Function Parameters
        4. Creating Type Aliases
        5. Executing Closures
      2. Optimizing Closures
        1. Implicit Returns
        2. Type Inference
        3. Shorthand Argument Names
        4. Trailing Closure Syntax
        5. Operator Functions
      3. Capturing Values
      4. Wrapping Up
    16. Chapter 8. Strings
      1. Constructing Strings
      2. Manipulating Strings
        1. Examining String Values
        2. Comparing Strings
        3. Modifying String Content
      3. Interacting with NSString
        1. Substrings
        2. Conversions
        3. Path Modification and URL Methods
        4. Explicitly Creating an NSString
      4. Unicode
      5. Wrapping Up
    17. Chapter 9. Classes
      1. Creating Classes
      2. Methods
      3. Properties
        1. Stored Properties
        2. Read-only Properties
        3. Think About Your Self
      4. Initializers
        1. Creating Initializers
        2. Using Convenience and Designated Initializers
        3. Deinitializing
      5. Inheritance
        1. Overriding a Method
        2. Calling to the Superclass
      6. Access Control
        1. Private
        2. Internal
        3. Public
      7. Subscripting
      8. Wrapping Up
    18. Chapter 10. Structures and Enumerations
      1. Structures
        1. Defining a Structure
        2. Modifying a Structure
      2. Enumerations
        1. Creating Enumerations
        2. Using Enumerations
        3. Associated Values
        4. Methods and Computed Properties
      3. Nesting Types
      4. Wrapping Up
    19. Chapter 11. Memory Management
      1. Swift Memory Management
      2. When to Use Weak and Unowned References
      3. Closures
      4. Wrapping Up
    20. Chapter 12. Collections
      1. General Comparisons
      2. Arrays
        1. Creating Arrays
        2. Reading Array Contents
        3. Manipulating Arrays
      3. Dictionaries
        1. Creating Dictionaries
        2. Reading from Dictionaries
        3. Manipulating Dictionaries
      4. Mutability
      5. Wrapping Up
    21. Chapter 13. Protocols, Extensions, and Generics
      1. Protocols
        1. Creating
        2. Conforming to Protocols
      2. Extensions
      3. Generics
        1. Generic Functions
        2. Generic Types
      4. Wrapping Up
    22. Chapter 14. There Isn’t a Word for That
      1. Only in Objective-C
        1. Exception Handling
        2. KVO
        3. Reflection
        4. Dynamic Dispatch
      2. New to Swift
        1. Namespaces
        2. Custom Operators
        3. filter, map, and reduce
      3. Wrapping Up
    23. Chapter 15. Interacting with Objective-C
      1. Introducing Swift to Objective-C
        1. Adding Swift Files
        2. Using Swift Code in Objective-C
      2. Using Objective-C with Swift
        1. Adding Objective-C Files
        2. Syntax Changes
        3. Type Changes
        4. Working with C Code
      3. Frameworks
      4. Wrapping Up
    24. Index
    25. Code Snippets

    Product information

    • Title: Swift Translation Guide for Objective-C Users: Develop and Design
    • Author(s): Maurice Kelly
    • Release date: December 2014
    • Publisher(s): Peachpit Press
    • ISBN: 9780134044811