You are previewing Swift Cookbook.
O'Reilly logo
Swift Cookbook

Book Description

Over 50 hands-on recipes to help you create apps, solve problems, and build your portfolio of projects in Swift

In Detail

If you have been looking for a book to help you develop apps for iOS on native iOS platforms, this is the book that you've been looking for! This practical guide will supply you with the building blocks that you can turn to when conceptualizing and writing applications for iOS/OS X. You'll master Swift programming as you progress through the various recipes in this book.

Starting with recipes that use the basic features, you will move on to interesting and engaging recipes that will make use of the more complex features of Swift. You will learn how to make use of Swift's diverse features, from the way you can configure your projects to the usage of design patterns and different types of databases. Complete with tips and tricks on Xcode, this example-based guide will help you develop and debug faster.

What You Will Learn

  • Install the latest version of Xcode and use all of its tools

  • Develop a multi-language project using Swift, Objective-C, C, and other languages

  • Plan your Swift project and explore the nuts and bolts of the Swift syntax

  • Use Swift playgrounds to see and hear your code's results as you write it

  • Localize your issues using the LLDB debugger and explore different possibilities of code with Swift playgrounds

  • Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

    Table of Contents

    1. Swift Cookbook
      1. Table of Contents
      2. Swift Cookbook
      3. Credits
      4. About the Author
      5. About the Reviewers
      6. www.PacktPub.com
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Sections
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        5. Conventions
        6. Reader feedback
        7. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      8. 1. Getting Started with Xcode and Swift
        1. Introduction
        2. Installing Xcode from the App Store
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        3. Downloading the Xcode image
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        4. Starting a Swift project
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        5. Using Swift project options
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        6. Creating conditional code
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        7. Adding a developer account
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        8. Compiling from the command line
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        9. Using Swift as an interpreter
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        10. Adding a control version system to an existing project
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
      9. 2. Standard Library and Collections
        1. Introduction
        2. Creating HTML manually
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        3. Printing your object description
          1. How to do it...
          2. How it works...
          3. There's more...
        4. Quizzing the user
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        5. Searching for perfect numbers
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        6. Sorting an array of products
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        7. Finding the way out
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        8. Working with sets
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        9. Creating your own set
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        10. Organizing a dinner room
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
      10. 3. Using Structs and Generics
        1. Introduction
        2. Creating an exam app
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        3. Checking the right answer
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        4. Avoiding copying of structs
          1. Getting ready
          2. How to do it...
          3. How it works...
        5. Creating a generic array initializer
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        6. Creating a priority list
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        7. Creating a protocol for the priority queue
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
      11. 4. Design Patterns with Swift
        1. Introduction
        2. Writing into a log file
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        3. Creating a factory of musical notes
          1. Getting ready
          2. How to do it...
          3. How it works
          4. There's more...
        4. Simulating a home automation
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        5. Delivering some pizzas
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
      12. 5. Multitasking
        1. Introduction
        2. Working of a device while you navigate
          1. Getting ready
          2. How to do it…
          3. How it works...
          4. There's more...
        3. Creating an SEO app
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        4. Being aware of cyclones
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more
        5. Links on our website
          1. Getting ready
          2. How to do it…
          3. How it works...
          4. There's more
      13. 6. Playground
        1. Introduction
        2. Creating the first playground
          1. Getting ready...
          2. How to do it...
          3. How it works...
          4. There's more...
        3. Watching some graphics
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        4. Watching the temperature
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        5. Stretching an image
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        6. Beautifying your text
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        7. Receiving JSONs
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        8. Dangerous moves
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
      14. 7. Swift Debugging with Xcode
        1. Introduction
        2. The Tax income simulator
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more…
        3. The best checker movement
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more…
        4. Debugging with LLDB
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        5. Profiling an app
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
      15. 8. Integrating with Objective-C
        1. Introduction
        2. Calling a cab
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        3. Hiring a van
          1. Getting ready
          2. How to do it...
          3. How it works...
        4. Porting from one language to another
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        5. Replacing the UI classes
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        6. Upgrading the app delegate
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        7. Creating a framework
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
      16. 9. Dealing with Other Languages
        1. Introduction
        2. Using your old address book
          1. Getting ready
          2. How to do it...
          3. How it works...
        3. Compressing a message
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        4. Using assembly code with Swift
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        5. Sharing C++ code with Swift
          1. Getting ready
          2. How to do it...
          3. How it works...
      17. 10. Data Access
        1. Introduction
        2. Creating an SQLite database
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        3. Checking where your IP is from
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        4. Tracking your phone activity
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        5. Controlling your stock
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        6. Voting devices
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
      18. 11. Miscellaneous
        1. Introduction
        2. The geekest keyboard
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        3. Time to take your pill
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        4. Adding effects to your photos
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        5. Being a film critic
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        6. Leaving breadcrumbs
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        7. Exchanging money
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more…
      19. Index