Reputation: 3841
I'm trying to set a constraint on 2 views
so that they touch each other like this:
I tried setting constraints programmatically:
[self addConstraint:[NSLayoutConstraint constraintsWithVisualFormat:@"[_firstView][_secondView]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(_firstView, _secondView)]];
But I get the following warning:
Incompatible pointer types sending 'NSArray *' to parameter of type 'NSLayoutConstraint'
What am I doing wrong?
Upvotes: 4
Views: 755
Reputation: 62072
The addConstraint:
method expect a single constraint, however the constraintsWithVisualFormat:
returns an NSArray
of zero or more constraints.
Try adding an s.
[self addConstraints:/*your NSLayoutConstraint constraintsWithVisualFormat: call */];
Apple's naming conventions can usually help you out here. Notice that constraintsWithVisualFormat
is plural while addConstraint:
was singular (and addConstraints:
is plural). Use these as your clue in the future.
Upvotes: 2