I was setting the constraints of a button using a storyboard. I saw an option, \"Identifier\" in the constraint\'s properties.
Swift 3
I wrote a quick NSView extension which handles this nicely.
extension NSView {
func constraint(withIdentifier: String) -> NSLayoutConstraint? {
return self.constraints.filter { $0.identifier == withIdentifier }.first
}
}
Usage:
if let c = button.constraint(withIdentifier: "my-button-width") {
// do stuff with c
}