Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //: Playground - noun: a place where people can play
- import UIKit
- class Test {
- public var call: (() -> ())? = nil
- public init() {
- self.call = { [weak self] in
- guard let `self` = self else { return print("No self") }
- print(String(describing: self))
- }
- }
- }
- var str = "Hello, playground"
- var test: Test? = Test()
- weak var test2 = test
- var call = (test?.call)!
- test?.call?() ?? print("No Test instance")
- test = nil
- call() ?? print("No Test instance")
- test2?.call?() ?? print("No Test instance")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement