My question is about the creation of constraints: why creating an array of constraints to be activated later with the activate method is more efficient than activating each one by one with .isActive = true?
Activating a direct constraint, we're basically changing an attribute, a variable that's already instantiated in the UIView we're tinkering with:
@available(iOS 9.0, *)
open var topAnchor: NSLayoutYAxisAnchor { get }
But the definition shows that using the Array is more efficient:
/* Convenience method that activates each constraint in the contained array, in the same manner as setting active=YES.
This is often more efficient than activating each constraint individually. */
@available(iOS 8.0, *)
open class func activate(_ constraints: [NSLayoutConstraint])
I don't see how to create an array of a variable that is already in scope and then pass it in a loop to activate it. How is this more efficient than enabling direct constraint?