Dispatch Queues

What? A queue that runs tasks FIFO.

Types? 

  • Serial – one at a time
    • system-provided: main queue
    • you can create your own
  • Concurrent – 1+ tasks at a time
    • system-provided: 4 queues (high, default, low, and background)
    • you can create your own, but 4 system ones should be good enough
Note: iOS 8+ should use QoS instead. 

    KVO

    Notify objects when changes to properties of other objects. Very similar to willSet and didSet, but they can be defined outside of the type defination.

    observation = observe(
    \.objectToObserve.myDate,
    options: [.old, .new]
    ) { object, change in
    print("myDate changed from: \(change.oldValue!), updated to: \(change.newValue!)")
    }

    Dynamic dispatch

    What? Since override is support by Swift, it has to be determined at runtime what methods/properties to call, so an indirect call cannot be avoid.
    When performance is important, to minimize and help compiler optimization, use private, final access levels to declare methods/properties.