playgrounds swift introduction

21
Playgrounds: A Swift Introduction Jeremy Curcio MobileDC - 4/2/2015

Upload: jeremy-curcio

Post on 16-Jul-2015

302 views

Category:

Technology


2 download

TRANSCRIPT

Playgrounds: A Swift Introduction

Jeremy CurcioMobileDC - 4/2/2015

Who Am I?

Software Developer from Baltimore, Maryland

Works for Planit Advertising

Writing iOS Apps since 2008

Hockey Player

Pokémon Player

Agenda

Overview of Swift

Learn a bit about Playgrounds

See what you can do in Playgrounds

Build a small app in Swift, utilizing Playgrounds

What Is Swift?

New programming language developed by Apple

Introduced at WWDC14

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

Powerful and Fast

Swift Quick Look

Variables

“let” vs “var”

Type Annotations

Swift infers type when possible

Swift Quick Look

Functions

Basic

With Parameters

With Return Value

What Are Playgrounds?

A File Wrapper

Contains Swift file

Resources

Timeline

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

Why Use Playgrounds?

Great way to:

Learn

Explore

Visualize

Much quicker than creating a Project

How Do Playgrounds Work?

Code is on the left

Results are on the right

Every code change recompiles

Timelines show results in more detail

Features Of Playgrounds

Quick Look

Available for:

Colors

Strings

Images

Views

Arrays/Dictionaries

And many more…

Features Of Playgrounds

Timeline

Preview code as it’s written

View changes in real time

Scrub through codes execution in time

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

Let’s Play?

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!

What Else Can Playgrounds Do?

XCPlayground

Custom Quick Looks

Quick Look you custom objects

Use Resources

API’s

Images

Asynchronous Code

Let’s Build Something

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

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

Let’s Build!

`

Resources

WWDC14 Session 408 - Swift Playgrounds

The Swift Programming Language - iBooks

Code/Slides available at www.jcurcio.com