Book Image

Swift Essentials - Second Edition

By : Alex Blewitt
Book Image

Swift Essentials - Second Edition

By: Alex Blewitt

Overview of this book

Swift was considered one of the biggest innovations last year, and certainly with Swift 2 announced at WWDC in 2015, this segment of the developer space will continue to be hot and dominating. This is a fast-paced guide to provide an overview of Swift programming and then walks you through in detail how to write iOS applications. Progress through chapters on custom views, networking, parsing and build a complete application as a Git repository, all by using Swift as the core language
Table of Contents (17 chapters)
Swift Essentials Second Edition
Credits
About the Author
Acknowledgments
About the Reviewer
www.PacktPub.com
Preface
Index

Advanced techniques


The playground has its own XCPlayground framework, which can be used to perform certain tasks. For example, individual values can be captured during loops for later analysis. It also permits asynchronous code to continue to execute once the playground has finished running.

Capturing values explicitly

It is possible to explicitly add values to the timeline by importing the XCPlayground framework and using XCPlaygroundPage.currentPage, and calling captureValue with a value that should be displayed in the timeline. This takes an identifier, which is used both as the title and to group related data values in the same series. When the value history button is selected, it essentially inserts a call to captureValue with the value of the expression as the identifier.

For example, to add the logo to the timeline automatically:

import XCPlayground
let page = XCPlaygroundPage.currentPage
let alblue = UIImage(named:"alblue")
page.captureValue(alblue, withIdentifier:"Al Blue")

Opening...