SnapKit icon indicating copy to clipboard operation
SnapKit copied to clipboard

Error: Cannot assign value of type 'ConstraintMakerEditable' to type 'Constraint?' when following docs

Open kakubei opened this issue 6 years ago • 3 comments

New Issue Checklist

  • [x] I have looked at the Documentation
  • [x] I have read the F.A.Q.
  • [x] I have filled out this issue template.

Issue Info

Info Value
Platform iOS
Platform Version 11
SnapKit Version 4.0.0
Integration Method cocoapods

Issue Description

Following the docs to create a reusable (updatable and uninstallable) constraint. I get the following error:

Cannot assign value of type 'ConstraintMakerEditable' to type 'Constraint?'

This this bit of code:

var destinationAddressViewBottom: Constraint? = nil
 destinationAddressViewBottom = make.bottom
                    .equalTo(titleBackgroundView.snp.bottom)
                    .offset(-16)

kakubei avatar Feb 12 '18 09:02 kakubei

Hello, I think you are forgetting the tail of the expression to get the Constraint object out of it (.constraint), such as:

 destinationAddressViewBottom = make.bottom
                    .equalTo(titleBackgroundView.snp.bottom)
                    .offset(-16).constraint

Vektrat avatar Feb 16 '18 10:02 Vektrat

Wow that is easy to miss!!

warpling avatar Oct 19 '18 21:10 warpling

Raywenderlich's tutorial also misses this part

akhrameev-picsart avatar Aug 06 '21 13:08 akhrameev-picsart