Skip to content

Instantly share code, notes, and snippets.

@sferrini
Last active March 31, 2016 20:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sferrini/a15b853c1f1ed65dad4ef82e3d8d08ac to your computer and use it in GitHub Desktop.
Save sferrini/a15b853c1f1ed65dad4ef82e3d8d08ac to your computer and use it in GitHub Desktop.
//: Playground - noun: a place where people can play
typealias CompletionBlock = (Bool) -> ()
class BlockStorage {
var blocks = [CompletionBlock]()
func addBlock(block: CompletionBlock) {
blocks.append(block)
}
deinit {
print("BlockStorage deinit")
}
}
class Client {
var blockStorage = BlockStorage()
func start() {
blockStorage.addBlock() { [unowned self](success: Bool) in
print("\(self) First block")
}
blockStorage.addBlock() { [unowned self](success: Bool) in
self.doSomeThing(success)
}
}
func doSomeThing(success: Bool) {
print("Do Something")
}
deinit {
print("Client deinit")
}
}
func playground() {
let client = Client()
client.start()
}
playground()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment