Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time

SWIFT TOUR

  • implicit variables and immutable variables

  • explicit variables

  • values need to be explicitly converted

  • use () to convert a variable to a string (in quotes)

  • arrays and dictionaries

To Do

  • implicit and explicit variable data types
  • strings
  • string interpolation ()
  • chars (converting string to array of chars).
  • arrays
  • introspection (type)
  • enumerated
  • characters
  • repeat while
  • conditional (if)
  • optionals
  • exit (quit script with exit code)

Membership

  • enumerations (errors)
  • exception handling & throwing errors
  • guard let else
  • switch
  • type of

Contact

  • declaring functions
  • return types
  • unused vars _
  • functions that throw errors

Arrays

let colours:[String] = ["red", "orange", "green"]
print(colours.count)
print("\(colours)")

var shoppingList = [String]()
//shoppingList.append("bread")
shoppingList += ["Bread"]
shoppingList.append("butter")
print("\(shoppingList)")
for item in shoppingList {
  print("\(item)")
}

Dictionaries

var book   = [
  "isbn": "1491943122",
  "title": "Learning Node"
]

var ages = [String:Int]()
ages["john"] = 42
ages["jane"] = 24
print("\(ages)")
for (name, age) in ages {
  print("\(name) is \(age) years old")
}

struct

// normally functions use their parameter names as labels so you need to have a custom argument label before each parameter name.

func printPerson(withName name:String, andAge age:Int) {
  print("\(name) is \(age) years old")
}

printPerson(withName: "frank", andAge: 64)

// use _ if you want to omit the first argument label.
func add(_ num1:Int, and num2:Int) -> Int {
  return num1 + num2
}

print(add(24, and: 42))

OOP

  • objects and classes
  • importing from separate file
  • create instance by putting parenthesis before class name.
  • private instance variables
  • properties (getters and setters)
  • methods
  • static

Async

  • closures (callbacks)

Foundation Framework

Unit Testing

  • importing XCUnit