Let's talk swift - an introduction

41
Let’s Talk SWIFT 30 min / 30 slides

description

Slides used for introduction to swift given at "Let's Talk Apple" in Aarhus

Transcript of Let's talk swift - an introduction

Page 1: Let's talk swift - an introduction

Let’s Talk SWIFT 30 min / 30 slides

Page 2: Let's talk swift - an introduction

Hej! Mig?

�  linkedin.com/jacobhhansen

�  IT-Minds siden 2011

�  iOS siden 2012

1.

Page 3: Let's talk swift - an introduction

Definition

“builds on the best of C and Objective-C”

“Swift has been years in the making.”

“a new language for the future of Apple software development.”

2.

Page 4: Let's talk swift - an introduction

Definition

“builds on the best of C and Objective-C”

“Swift has been years in the making.”

“a new language for the future of Apple software development.”

2.

Page 5: Let's talk swift - an introduction

Ny syntax! 3.

Page 6: Let's talk swift - an introduction

Deklarer en variable �  Variabler og konstanter

Var myInt : Int = 2

Let myString : String = “Hej”

�  Strongly Typed

�  Type Inference

�  Og....Emojies

4.

Page 7: Let's talk swift - an introduction

Funktioner 5.

Page 8: Let's talk swift - an introduction

NSLog(@”Hej”);

Println(“Hej”)

NSLog(@”Hej %@”, navn);

Println(“Hej \(navn)”)

6. Print Variabler

Page 9: Let's talk swift - an introduction

Standard Types �  String

�  Character

�  Int (32 / 64 bits)

�  Double / Float

�  Bool

�  Array

�  Dictionary

7.

Page 10: Let's talk swift - an introduction

Array / Dictionary �  Has a type!

�  Short Hand

�  Shortest Hand

�  Mutable / Immutable

8.

Page 11: Let's talk swift - an introduction

Objective-C kompabilitet �  Bridge Header filer

�  Generated Header (#import “appname-swift.h”

9.

Page 12: Let's talk swift - an introduction

Platform

�  iOS7 + 8

�  OS X Yosemite + Mavericks

10.

Page 13: Let's talk swift - an introduction

PlayGrounds

11.

Page 14: Let's talk swift - an introduction

PlayGrounds

11.

Page 15: Let's talk swift - an introduction

PlayGrounds 11.

Page 16: Let's talk swift - an introduction

PlayGrounds

11.

Page 17: Let's talk swift - an introduction

PlayGrounds

11.

Page 18: Let's talk swift - an introduction

Enum

12.

Page 19: Let's talk swift - an introduction

Switch �  Must be exhaustive

�  Don’t falll through on its own

�  Pattern Matching

13.

Page 20: Let's talk swift - an introduction

Associated/Raw Values

14.

Page 21: Let's talk swift - an introduction

Optionals �  Alt kan være nil

15.

Page 22: Let's talk swift - an introduction

Optional binding

16.

Page 23: Let's talk swift - an introduction

Optional Chaining 17.

Page 24: Let's talk swift - an introduction

Protocols �  No optionals

�  Er typer (Delegation)

�  Blueprint

Metoder

Operatorer

Subscripts

Properties

18.

Page 25: Let's talk swift - an introduction

Protocols 18.

Page 26: Let's talk swift - an introduction

REPL �  Read-Eval-Print-Loop

�  Kør Scripts!

19.

Page 27: Let's talk swift - an introduction

Closures �  Fungerer som blocks / lambdas

�  Global / Nested / Expressions

20.

Page 28: Let's talk swift - an introduction

Tuple �  Midlertidig datastruktur

21.

Page 29: Let's talk swift - an introduction

Ranges �  Shortcut!

22.

Page 30: Let's talk swift - an introduction

Ranges �  Shortcut!

22.

Page 31: Let's talk swift - an introduction

Operators �  Overload Operators (class / struct level)

�  Custom operators

Infix / Prefix / Postfix

/, =, -, +, !, *, %, <, >, &, |, ^, or ~

23.

Page 32: Let's talk swift - an introduction

Struct / Class

�  Class er reference (heap)

�  Struct er værdi (stack) + ingen nedarvning

24.

Page 33: Let's talk swift - an introduction

No Header! �  Show what it is

25.

Page 34: Let's talk swift - an introduction

Init / Deinit �  Alt skal initialiseres!

26.

Page 35: Let's talk swift - an introduction

Init / Deinit �  Alt skal initialiseres!

26.

Page 36: Let's talk swift - an introduction

Init / Deinit �  Alt skal initialiseres!

26.

Page 37: Let's talk swift - an introduction

Init more

27.

Page 38: Let's talk swift - an introduction

Generics

28.

Page 39: Let's talk swift - an introduction

Generics

+Type Constraints

28.

Page 40: Let's talk swift - an introduction

Og meget mere…

�  Private / Public

�  Property Observers

�  Subscripts

�  Extensions

29.

Page 41: Let's talk swift - an introduction

Lær Mere! �  https://developer.apple.com/swift/

�  The Swift Programming Language

�  Using Swift with Cocoa and Objective-C

�  WWDC14

30.