ZLWeakProxy.swift 649 B

12345678910111213141516171819202122232425262728293031
  1. //
  2. // ZLWeakProxy.swift
  3. // ZLPhotoBrowser
  4. //
  5. // Created by long on 2021/3/10.
  6. //
  7. import UIKit
  8. class ZLWeakProxy: NSObject {
  9. private weak var target: NSObjectProtocol?
  10. init(target: NSObjectProtocol) {
  11. self.target = target
  12. super.init()
  13. }
  14. class func proxy(withTarget target: NSObjectProtocol) -> ZLWeakProxy {
  15. return ZLWeakProxy.init(target: target)
  16. }
  17. override func forwardingTarget(for aSelector: Selector!) -> Any? {
  18. return target
  19. }
  20. override func responds(to aSelector: Selector!) -> Bool {
  21. return target?.responds(to: aSelector) ?? false
  22. }
  23. }