Then

public protocol Then

接口

  • with(_:) Extension method

    值类型数据初始化属性

    let frame = CGRect().with {
      $0.origin.x = 10
      $0.size.width = 100
    }
    
    Declaration

    Swift

    public func with(_ block: (inout Self) throws -> Void) rethrows -> Self
  • do(_:) Extension method

    初始化动作,与初始化属性不同在于此没有返回值

    UserDefaults.standard.do {
      $0.set("devxoul", forKey: "username")
      $0.set("devxoul@gmail.com", forKey: "email")
      $0.synchronize()
    }
    
    Declaration

    Swift

    public func `do`(_ block: (Self) throws -> Void) rethrows
  • then(_:) Extension method

    引用类型数据初始化属性

    let label = UILabel().then {
      $0.textAlignment = .center
      $0.textColor = UIColor.black
      $0.text = "Hello, World!"
    }
    
    Declaration

    Swift

    public func then(_ block: (Self) throws -> Void) rethrows -> Self