If I have a NSLayoutConstraint which I retrieved from self.view.constraints is it possible to get the object that constraint is applied to? Edit: To clarify what I am trying to do: Reposition a UILabel from off screen to on and then change the content of that label
So I have this constraint:
<NSLayoutConstraint:0x600000e337f0 'lblTeamFieldTop' V:[UILabel:0x7f9d5a826120' Add A Team']-(75)-[UILabel:0x7f9d5a8256f0'Team Name'] (active)>
I know this is the label it is applied to: [UILabel:0x7f9d5a8256f0
is there a way I can get a reference to that object from the constraint?
To expand on this a little more. When you create a constraint programmatically you can set these properties:
+ (instancetype)constraintWithItem:(id)view1
attribute:(NSLayoutAttribute)attr1
relatedBy:(NSLayoutRelation)relation
toItem:(id)view2
attribute:(NSLayoutAttribute)attr2
multiplier:(CGFloat)multiplier
constant:(CGFloat)c;
but WithItem and toItem don't seem to be readable properties of the constraint.
I found it, firstitem and seconditem.
Edit: To clarify my solution. fistitem and seconditem are properties of the NSLayoutConstraint. firstitem could be, for example, Superview and seconditem could be the item you are aligning to the firstitem, say for example a UILabel. So in my case, the UILabel I was looking for was the seconditem (you can see these in Storyboard, just click on a NSLayoutConstraint and view its information panel). I did have to cast it back to a UILabel as I think NSLayoutConstraint cast them to Any.