Sign in to FlowVella

Forgot password?
Sign in with Facebook

New? Create your account

Sign up for FlowVella

Sign up with Facebook

Already have an account? Sign in now


By registering you are agreeing to our
Terms of Service

Share This Flow

Loading Flow

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Unwrapping

Optional variables must be unwrapped using ! to access their value

Swift: Trying hard to help you avoid doing something dumb and getting NPEs

// Optional integer,

// allowed to be nil

var myOptionalVar : Int? = nil


myOptionalVar = 100


println (myOptionalVar! + 1)

Required Values

Variables in Swift are required to

have values (usually, see below)

Optional Variables

Optional variables are explicitly declared that they may have the value of nil

Use ! to Unwrap Optional Variables

Note the use of the exclamation point (!) at the end of the variable name in the last line

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...

Downloading Image /

loading...
  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10

  • 11

  • 12

  • 13

  • 14

  • 15

  • 16

  • 17

  • 18

  • 19

  • 20

  • 21

  • 22

  • 23

  • 24

  • 25

  • 26

  • 27

  • 28

  • 29

  • 30

Introduction to the Swift Language - Chicago Swift Developer Meetup

By Matt Houser

v 2015-04-13a