Swiftpack.co - vsanthanam/WeakReference as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by vsanthanam.
vsanthanam/WeakReference 1.0.2
An existential weak reference wrapper for Swift
⭐️ 1
🕓 51 weeks ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/vsanthanam/WeakReference.git", from: "1.0.2")


MIT License Package Releases Build Results Swift Version Supported Platforms

An existential weak reference. Use this wrapper class to pass around weakly-referenced instances of an object.


WeakReference is currently distributed exclusively through the Swift Package Manager.

To add WeakReference as a dependency to an existing Swift package, add the following line of code to the dependencies parameter of your Package.swift file:

dependencies: [
    .package(url: "https://github.com/vsanthanam/WeakReference.git", .upToNextMajor(from: "1.0.0"))

To add AnyAsyncSequence as a dependency to an Xcode Project:

Other distribution mechanisms like CocoaPods or Carthage may be added in the future.

Additional installation instructions are available on the Swift Package Index


import WeakReference

var obj: MyObj? = .init( ... )
let weakReference = weak(obj!)

assert(weakReference.obj != nil)

obj = nil

assert(weakReference.obj == nil)

See the complete documentation for more information.


WeakReference is available under the MIT license. See the LICENSE file for more information.


Stars: 1
Last commit: 51 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

51 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics