robb / Cartography

A declarative Auto Layout DSL for Swift :iphone::triangular_ruler:
Other
7.35k stars 525 forks source link

Make the replaceGroup argument optional #239

Closed strangeliu closed 7 years ago

strangeliu commented 7 years ago

while there is a optional constraintGroup that i have to replace it when it's not nil, i have do like this

var replaceGroup: ConstraintGroup?
if let replaceGroup = replaceGroup {
    constrain(view, replace: replaceGroup) { view in
        // new constrains
    }
} else {
    constrain(view) { view in
        // new constrains
    }
}

or

constrain(view, replace: replaceGroup ?? ConstraintGroup()) { view in
    // new constrains
}

both are not convenient, so make the replaceGroup argument optional for convenient

orta commented 7 years ago

👍 Awesome - thanks!