Swift

Learning

Blog

API

Servers

Server Technology

Serverless

Dependencies

CLI

Static Site Generators

Async

Databases

Evolution

Closures

Extensions

  • Use case: https://www.natashatherobot.com/using-swift-extensions/
  • Naming: http://stackoverflow.com/a/26320397/130638

Features

Performance

  • https://youtu.be/U248O0cN5iE
  • Use structs over classes (classes use heaps, structs and values use stack)
  • Use structs over concatenated strings (structs offer better memory management)
  • Any reference requires a heap, so values are much better as they use stack
  • Strings and classes store their contents on the heap
  • Enums that use strings are still better than just strings by themselves
  • To use static dispatch over dynamic dispatch:
    • Use final for classes (unless they are intended to be extended)
    • Avoid using classes when structs or protocols will do
    • If a class just defines an interface for future classes, it should be a protocol
    • Class inheritance structures can probably be struct and protocol structures instead
    • Structs and classes can both use protocols, not just classes, but structs too
  • Questions to always ask yourself:
    1. Is this going to be allocated to the stack or the heap
    2. When I pass this instance around, how much reference counting am I going to incur?
    3. When I call a method on this method on this instance, is it going to be statically or dynamically dispatched?
  • WHAT does guard do?

Value Semantics vs Reference Semantics

Realtime Collaboration

Watch

Animation

Example Apps

Personality Analysis

This project is maintained by balupton