mas/Tests/MasKitTests/Strongify.swift

15 lines
386 B
Swift
Raw Normal View History

2019-01-09 05:43:33 +00:00
//
// Strongify.swift
// MasKitTests
//
// Created by Ben Chatelain on 1/8/19.
// Copyright © 2019 mas-cli. All rights reserved.
//
// https://medium.com/@merowing_/stop-weak-strong-dance-in-swift-3aec6d3563d4
2021-05-06 20:26:11 +00:00
func strongify<Context: AnyObject>(_ context: Context?, closure: (Context) -> Void) {
2019-01-09 05:43:33 +00:00
guard let strongContext = context else { return }
closure(strongContext)
}