Initialize with then

suggest change

This is similar in syntax to the example that initializes using positional constants, but requires the Then extension from (attached below).

let label = UILabel().then {
    $0.textAlignment = .Center
    $0.textColor = UIColor.blackColor(
    $0.text = "Hello, World!"

The Then extension:

import Foundation

public protocol Then {}

extension Then 
    public func then(@noescape block: inout Self -> Void) -> Self {
        var copy = self
        return copy

extension NSObject: Then {}

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents