Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

I don't understand this Format String constraint error

This is my line of code (I believe I have copied exactly what Pasan has written):

view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V: [topLayoutGuide]-standardOffset-[blueView]-standardOffset-[orangeView]", options: [], metrics: metrics, views: views))

At run time, the app crashes and this is the beginning of the error I get:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse constraint format: Expected a view V: [topLayoutGuide]-standardOffset-[blueView]-standardOffset-[orangeView] ^'

Can someone tell me what I am doing wrong? Has the syntax changed since the video was uploaded?

1 Answer

I figured it out. If anyone is interested....the error is the space between H: [, instead the syntax has to be H:[