0.1 Basics


Swiftworks with iOS 7+
iOS 7iPhone 4
iOS 9iPhone 4S, iPad Mini, iPad 2&3, touch 5
iOS 10+iPhone 5+, iPad Mini 2+, iPad 4, touch 6
  • 95%+ devices are on iOS 10/11
  • iOS 10+ only requires 2x and 3x images (no need to include 1x images)

REPL – Read Evaluate Print Loop

  • command line input for quick testing
  • open terminal:
  • sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
  • xcrun swift

Naming Style Guide

  • use camel case
  • Class names are capitalized
  • don’t use all caps nor _’s
  • name parameters for functions/inits
  • spaces matter → do not put numbers right next to operation stmts
  • (ie. i>=4 should be i >= 4)


  • not attached to a file
  • more of a scratch pad for testing
  • cannot be used to test memory management


  • can access variables only in the portion of the program in which they are declared
  • can be limited to:  if stmts, for loops, functions, classes, global
  • global is the default if declared in an area that isn’t scoped

Data Types


  • type that can be given a particular name when it is defined
  • includes arrays, dictionaries, optionals, classes, structures, enumerations, and protocols


  • type without a name, defined in the Swift language itself
  • includes tuples, closures, & functions


var – used to create a variable
let – used to create a constant

  • use let whenever possible → performance improvements (fixed memory size)
  • when the type is obvious, let Swift infer it
  • types cannot be changed once set