Created
April 7, 2018 23:32
-
-
Save khanlou/a00714d9595c1e78199a49dc67a05ffe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import UIKit | |
public protocol Configure {} | |
extension Configure { | |
/// Makes it available to set properties with closures just after initializing. | |
/// | |
/// let frame = UIView().configure { | |
/// $0.backgroundColor = .red | |
/// } | |
public func configure(_ block: (inout Self) -> Void) -> Self { | |
var copy = self | |
block(©) | |
return copy | |
} | |
} | |
extension NSObject: Configure {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment