Skip to content

vsanthanam/WeakReference

Repository files navigation

WeakReference

MIT License Package Releases Build Status Swift Version Supported Platforms

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

Installation

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",
        from: "2.0.0"
    )
]

To add WeakReference as a dependency to an Xcode Project:

  • Choose FileAdd Packages...
  • Enter package URL https://github.com/vsanthanam/WeakReference.git and select your release and of choice.

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

Additional installation instructions are available on the Swift Package Index

Usage

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.

License

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

About

An existential weak reference wrapper for Swift

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages