I have created a bunch of views and sliders in my page and as a result I have quite a few constraint constants. My friend noticed that after each group I would use
and then for the next set of items I would do the same.
He suggested that I just create an array like this
var allConstraints = [NSLayoutConstraint]()
and append each constraint to the array and then do it all at once
so after each constant that I create I am saying
What I am curious to know is when I create the NSLayoutConstraint constant can I, in the same line, automatically add it to allConstraints array?
That seems like it would be cleaner.
doing so will make your code hard to read so i suggest you don't! but yes you can achieve this in a single line
allConstraints.append(NSLayoutConstraint(item: AnyObject>, attribute: <NSLayoutAttribute>, relatedBy: <NSLayoutRelation>, toItem: <AnyObject?>, attribute: <NSLayoutAttribute>, multiplier: <CGFloat>, constant: <CGFloat>))