Top Banner
Playgrounds: A Swift Introduction Jeremy Curcio @Jeremy1026 jcurcio.com 5/8/2015
21
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Playgrounds: A Swift Introduction

Playgrounds: A Swift Introduction

Jeremy Curcio @Jeremy1026

jcurcio.com 5/8/2015

Page 2: Playgrounds: A Swift Introduction

Who Am I?

Software Developer from Baltimore, Maryland

Works for Planit Advertising

Writing iOS Apps since 2008

Hockey Player

Pokémaster

Page 3: Playgrounds: A Swift Introduction

Agenda

Overview of Swift

Learn a bit about Playgrounds

See what you can do in Playgrounds

Build a small app in Swift, utilizing Playgrounds

Page 4: Playgrounds: A Swift Introduction

What Is Swift?

New programming language developed by Apple

Introduced at WWDC14

Works alone, or side-by-side with Objective-C

Powerful and Fast

Page 5: Playgrounds: A Swift Introduction

Swift Quick Look

Variables

“let” vs “var”

Type Annotations

Swift infers type when possible

Page 6: Playgrounds: A Swift Introduction

Swift Quick Look

Functions

Basic

With Parameters

With Return Value

Page 7: Playgrounds: A Swift Introduction

What Are Playgrounds?

A File Wrapper

Contains Swift file

Resources

Timeline

Page 8: Playgrounds: A Swift Introduction

What Playgrounds Aren’t

Where to write full app

How to test code on a device

A way to test code that requires user interaction

A way to performance test your code

Page 9: Playgrounds: A Swift Introduction

Why Use Playgrounds?

Great way to:

Learn

Explore

Visualize

Much quicker than creating a Project

Page 10: Playgrounds: A Swift Introduction

How Do Playgrounds Work?

Code is on the left

Results are on the right

Every code change recompiles

Timelines show results in more detail

Page 11: Playgrounds: A Swift Introduction

Features Of Playgrounds

Quick Look

Available for:

Colors

Strings

Images

Views

Arrays/Dictionaries

And many more…

Page 12: Playgrounds: A Swift Introduction

Features Of Playgrounds

Timeline

Preview code as it’s written

View changes in real time

Scrub through codes execution in time

Page 13: Playgrounds: A Swift Introduction

Playground vs Project

Playground

File -> New -> Playground

Enter Name

Select Platform

Write Code

Project

Create Project

Choose Template

Save Project

Create Files

Write Code

Set Up Provisioning

Build

Run

Page 14: Playgrounds: A Swift Introduction

Let’s Play?

Page 15: Playgrounds: A Swift Introduction

Our Playground

What we did:

Used a for loop

Created and modified a UIColor variable

Created and previewed a UIView

What we didn’t do:

Create an Xcode Project

Never “built” the code

So much more!

Page 16: Playgrounds: A Swift Introduction

What Else Can Playgrounds Do?

XCPlayground

Custom Quick Looks

Quick Look you custom objects

Use Resources

API’s

Images

Asynchronous Code

Page 17: Playgrounds: A Swift Introduction

Let’s Build Something

XKCD #426: Geohashing“Saturday is game night.”

Page 18: Playgrounds: A Swift Introduction

Let’s Build Something

Goal

Create a fully functioning app in Swift

Use a Playground to test as we go

Caveats

Storyboard pre-made

Project already set up

Code is pre-written/pre-tested

Page 19: Playgrounds: A Swift Introduction

Let’s Build!

Page 20: Playgrounds: A Swift Introduction

Questions?

Page 21: Playgrounds: A Swift Introduction

Resources

WWDC14 Session 408 - Swift Playgrounds

The Swift Programming Language - iBooks

Code/Slides available at www.jcurcio.com

joind.in/13964