Skip to content

Instantly share code, notes, and snippets.

@inso-
Created July 7, 2020 14:53
Show Gist options
  • Save inso-/fbe1b30266e19d968ff534546007ec42 to your computer and use it in GitHub Desktop.
Save inso-/fbe1b30266e19d968ff534546007ec42 to your computer and use it in GitHub Desktop.
Weak property Wrapper
@propertyWrapper
public struct Weak<Wrapped: AnyObject> {
private weak var value: AnyObject?
public init(_ value: Wrapped? = nil) {
self.value = value
}
public var wrappedValue: Wrapped? {
get { value as? Wrapped }
set { value = newValue }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment