Swift 2 Cookbook

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

Swift 2 Cookbook

This ebook is included in a Mapt subscription
Kyle Begeman

Over 50 hands-on recipes to help you create apps and build your portfolio of projects in Swift 2
$0.00
$39.99
$49.99
$29.99p/m after trial
RRP $39.99
RRP $49.99
Subscription
eBook
Print + eBook
Start 30 Day Trial
Subscribe and access every Packt eBook & Video.
 
  • 4,000+ eBooks & Videos
  • 40+ New titles a month
  • 1 Free eBook/Video to keep every month
Start Free Trial
 
Preview in Mapt

Book Details

ISBN 139781785889219
Paperback400 pages

Book Description

Swift is Apple’s innovative development language that was introduced at the WWDC (WorldWide Developers Conference) 2014 alongside Xcode 6 and iOS 8. This user-friendly language is packed with modern features to make programming easier and fun, with a lot of flexibility. With Swift 2 comes even better performance, a new error handling API, protocol extensions, and super support for availability checking.

This book will equip you with all the practical programming aspects of Swift 2. It covers the important features and paradigms that Swift provides to developers. You will begin by installing Xcode from the App Store and using Swift as an interpreter. Then, you will see how you can upgrade your existing Swift 1.2 code to Swift 2.0 with the help of Xcode. You will see how to use structs and generics, and work with different Design Patterns with Swift. Debug and test your code using Xcode and see how to use assembly code effectively with Swift.

By the end of this book, you will have the necessary skills to get the most out of Swift to develop effective mobile and web applications.

Table of Contents

Chapter 1: Getting Started with Xcode and Swift
Introduction
Installing Xcode from the App Store
Downloading the Xcode image
Starting a Swift project
Using the Swift project options
Creating conditional code
Migrating an existing project to Swift 2.0
Adding a developer account
Compiling from the command line
Using Swift as an interpreter
Adding a control version system to an existing project
Chapter 2: Standard Library and Collections
Introduction
Creating HTML manually
Printing your object description
Quizzing the user
Searching for perfect numbers
Sorting an array of products
Finding the way out
Creating your own set
Organizing a dinner room
Chapter 3: Using Structs and Generics
Introduction
Creating an exam app
Checking for the right answer
Avoiding the copying of structs
Creating a generic array initializer
Creating a priority list
Creating a protocol for the priority queue
Chapter 4: Design Patterns with Swift
Introduction
Writing into a log file
Creating a factory of musical notes
Simulating a home automation
Delivering some pizzas
Protocol-oriented programming
Chapter 5: Multitasking in Your App
Introduction
Word counting using threads
Creating an SEO app
Creating a CycloneChecker app
Checking links of our website
Chapter 6: Working with Playgrounds
Introduction
Creating the first playground
Watching some graphics
Watching a temperature with color
Stretching an image
Beautifying your text using Pangrams
Receiving JSONs
Creating our own class representations
Rich documentation
Navigating pages in playgrounds
Chapter 7: Swift Debugging with Xcode
Introduction
Validating the values – developing a tax income simulator app
Debugging with Xcode and Swift – the best checker movement
Debugging with LLDB
Profiling an app
Error handling in Swift 2.0
Custom error handling in Swift 2.0
Availability checking in Swift 2.0
Chapter 8: Integrating with Objective-C
Introduction
Calling a cab
Hiring a van
Porting your code from one language to another
Replacing the user interface classes
Upgrading the app delegate
Creating your own custom framework
Chapter 9: Dealing with Other Languages
Introduction
Using my old address book
Compressing a message
Using assembly code with Swift
Sharing C++ code with Swift
Chapter 10: Data Access
Introduction
Creating an SQLite database
Checking where your IP is from
Tracking your phone activity
Controlling your stocks
Designing a voting device using CouchDB
Chapter 11: Extensions, Photos, and More
Introduction
Developing the geekiest keyboard
Time to take your pill
Adding effects to your photos
Being a film critic
Leaving breadcrumbs
Creating the Currency Converter app
Method swizzling in Swift
Associated objects in Swift

What You Will Learn

  • Install Xcode from the App Store
  • Upgrade your existing Swift 1.2 code to Swift 2.0
  • Use the standard Swift 2.0 library and collections
  • Work with structs, generics, and design patterns in Swift
  • Use the new markup language to provide rich documentation of code
  • Write a book using Playgrounds and Swift
  • Debug and test your code using Xcode
  • Integrate your code with Objective-C and use assembly code with Swift
  • Leverage the Objective-C runtime when compiling Swift using associated objects

Authors

Table of Contents

Chapter 1: Getting Started with Xcode and Swift
Introduction
Installing Xcode from the App Store
Downloading the Xcode image
Starting a Swift project
Using the Swift project options
Creating conditional code
Migrating an existing project to Swift 2.0
Adding a developer account
Compiling from the command line
Using Swift as an interpreter
Adding a control version system to an existing project
Chapter 2: Standard Library and Collections
Introduction
Creating HTML manually
Printing your object description
Quizzing the user
Searching for perfect numbers
Sorting an array of products
Finding the way out
Creating your own set
Organizing a dinner room
Chapter 3: Using Structs and Generics
Introduction
Creating an exam app
Checking for the right answer
Avoiding the copying of structs
Creating a generic array initializer
Creating a priority list
Creating a protocol for the priority queue
Chapter 4: Design Patterns with Swift
Introduction
Writing into a log file
Creating a factory of musical notes
Simulating a home automation
Delivering some pizzas
Protocol-oriented programming
Chapter 5: Multitasking in Your App
Introduction
Word counting using threads
Creating an SEO app
Creating a CycloneChecker app
Checking links of our website
Chapter 6: Working with Playgrounds
Introduction
Creating the first playground
Watching some graphics
Watching a temperature with color
Stretching an image
Beautifying your text using Pangrams
Receiving JSONs
Creating our own class representations
Rich documentation
Navigating pages in playgrounds
Chapter 7: Swift Debugging with Xcode
Introduction
Validating the values – developing a tax income simulator app
Debugging with Xcode and Swift – the best checker movement
Debugging with LLDB
Profiling an app
Error handling in Swift 2.0
Custom error handling in Swift 2.0
Availability checking in Swift 2.0
Chapter 8: Integrating with Objective-C
Introduction
Calling a cab
Hiring a van
Porting your code from one language to another
Replacing the user interface classes
Upgrading the app delegate
Creating your own custom framework
Chapter 9: Dealing with Other Languages
Introduction
Using my old address book
Compressing a message
Using assembly code with Swift
Sharing C++ code with Swift
Chapter 10: Data Access
Introduction
Creating an SQLite database
Checking where your IP is from
Tracking your phone activity
Controlling your stocks
Designing a voting device using CouchDB
Chapter 11: Extensions, Photos, and More
Introduction
Developing the geekiest keyboard
Time to take your pill
Adding effects to your photos
Being a film critic
Leaving breadcrumbs
Creating the Currency Converter app
Method swizzling in Swift
Associated objects in Swift

Book Details

ISBN 139781785889219
Paperback400 pages
Read More

Read More Reviews