Whether you are working with Swift as your first language or if you are coming from another language, Swift has some quirks setting it apart from other languages.
We will explore some of the reasonings, implementations and usages of these elements in the language through practical examples. Some of the Swift concepts we will be looking at are Optionals, Protocols and Extensions.
Swift by Example
from a High Level
Aims to be Objective-C
without the C
Swift is Type Safe
Provide compile-time check that would
prevent some common programming
errors happened at run-time.
Optionals require a
discussion about NIL
Reinforce the nil-check and
offer compile-time cues
Assumes a value must be
present, unless told otherwise
An optional must be
unwrapped using a ? or !
A blueprint of methods, properties,
and other requirements that suit a
particular task or piece of functionality
A guarantee of some terms that will
be satisﬁed. To the other party, the
contract is a set of obligations.
Allows us to Create
Class that adopts the protocol
is referred to as the ‘Delegate’
One class (a delegator class) would give
control or responsibility for some behavioral
logic to another class called a delegate.
1. Create a delegate protocol that
deﬁnes the responsibilities of the
2. Create a delegate property in
the delegating class to keep track
of the delegate.
3. Adopt and implement the
delegate methods in the delegate
4. Call the delegate from the
Added functionality to a
Class, Struct or Enum
Not overwriting it
NO Monkey Patching From Extensions