Skip to content

`WeakRef` is a type-safe alternative to `weak` properties that maintains a clean cross-boundary separation of concerns.

License

Notifications You must be signed in to change notification settings

essentialdevelopercom/swift-weak-ref

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WeakRef: A Swift type-safe alternative to weak properties

WeakRef is a type-safe alternative to weak properties that maintains a clean cross-boundary separation of concerns.

final class WeakRef<T: AnyObject> {
	weak var object: T?
	
	init(_ object: T) {
		self.object = object
	}
}

Usage example:

let vc = WeatherViewController()
let presenter = WeatherPresenter(view: WeakRef(vc))
vc.presenter = presenter

Learn more at: https://www.essentialdeveloper.com/articles/clean-ios-architecture-pt-4-clean-memory-management-in-swift-with-weakref

About

`WeakRef` is a type-safe alternative to `weak` properties that maintains a clean cross-boundary separation of concerns.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages