Optionals, value types, protocols and concurrency in Swift.
A chat server keeps one Session object per logged-in user in a
dictionary. Write a Session class whose initialiser logs
"open <user>" and whose deinit logs "close <user>", and use it in
To explain ARC to a new teammate, simulate reference counts by hand.
Write refCountLog(ops: [String]) -> [String] that processes these
operations in order:
In a school app, a Teacher owns its students through a strong array,
and each points back to its teacher with a
reference. Build these classes and write
StudentSwift manages memory for class instances with ARC. What does ARC do,
and at what moment is an instance of a class such as ProfileViewModel
freed?
Most delegate properties are declared as
weak var delegate: DownloadDelegate?. What is the difference
between a weak and a normal (strong) reference, and why is a
delegate usually weak?
In a sports app, a Team class has var players: [Player] and the
Player class has var team: Team?. Both are normal properties. What
problem does this cause when the team screen is closed, and how do you
fix it?